/** * Add fake partitions to the loaded catalog Assuming that there is one partition per site * * @param num_partitions */ protected void addPartitions(int num_partitions) throws Exception { // HACK! If we already have this many partitions in the catalog, then we won't recreate it // This fixes problems where we need to reference the same catalog objects in multiple test // cases if (CatalogUtil.getNumberOfPartitions(catalog_db) != num_partitions) { ClusterConfiguration cc = new ClusterConfiguration(); for (Integer i = 0; i < num_partitions; i++) { cc.addPartition("localhost", 0, i); // System.err.println("[" + i + "] " + Arrays.toString(triplets.lastElement())); } // FOR catalog = FixCatalog.addHostInfo(catalog, cc); this.init(this.last_type, catalog); } Cluster cluster = CatalogUtil.getCluster(catalog_db); assertEquals(num_partitions, cluster.getNum_partitions()); assertEquals(num_partitions, CatalogUtil.getNumberOfPartitions(cluster)); }
protected void initializeCluster(int num_hosts, int num_sites, int num_partitions) throws Exception { // HACK! If we already have this many partitions in the catalog, then we won't recreate it // This fixes problems where we need to reference the same catalog objects in multiple test // cases if (CatalogUtil.getNumberOfHosts(catalog_db) != num_hosts || CatalogUtil.getNumberOfSites(catalog_db) != (num_hosts * num_sites) || CatalogUtil.getNumberOfPartitions(catalog_db) != (num_hosts * num_sites * num_partitions)) { catalog = FixCatalog.addHostInfo(catalog, "localhost", num_hosts, num_sites, num_partitions); this.init(this.last_type, catalog); } Cluster cluster = CatalogUtil.getCluster(catalog_db); assertEquals(num_hosts, CatalogUtil.getNumberOfHosts(catalog_db)); assertEquals((num_hosts * num_sites), CatalogUtil.getNumberOfSites(catalog_db)); assertEquals( (num_hosts * num_sites * num_partitions), CatalogUtil.getNumberOfPartitions(cluster)); assertEquals((num_hosts * num_sites * num_partitions), cluster.getNum_partitions()); }