ExternalView ev = accessor.getProperty(accessor.keyBuilder().externalView(DB2));
Set<String> hosts = new HashSet<String>();
for (String p : ev.getPartitionSet()) {
for (String hostName : ev.getStateMap(p).keySet()) {
InstanceConfig config =
accessor.getProperty(accessor.keyBuilder().instanceConfig(hostName));
Assert.assertTrue(config.containsTag(DB2tag));
hosts.add(hostName);
}
}
Assert.assertEquals(hosts.size(), 2);
String DB3 = "TestDB3";
String DB3Tag = "TestDB3_tag";
partitions = 10;
replica = 3;
for (int i = 1; i < 5; i++) {
String instanceName = "localhost_" + (12918 + i);
_setupTool.getClusterManagementTool().addInstanceTag(CLUSTER_NAME, instanceName, DB3Tag);
}
_setupTool.addResourceToCluster(CLUSTER_NAME, DB3, partitions, STATE_MODEL);
_setupTool.rebalanceStorageCluster(CLUSTER_NAME, DB3, DB3Tag, replica);
result =
ClusterStateVerifier
.verifyByZkCallback((new ClusterStateVerifier.BestPossAndExtViewZkVerifier(ZK_ADDR,
CLUSTER_NAME)));
Assert.assertTrue(result, "Cluster verification fails");
ev = accessor.getProperty(accessor.keyBuilder().externalView(DB3));
hosts = new HashSet<String>();
for (String p : ev.getPartitionSet()) {
for (String hostName : ev.getStateMap(p).keySet()) {
InstanceConfig config =
accessor.getProperty(accessor.keyBuilder().instanceConfig(hostName));
Assert.assertTrue(config.containsTag(DB3Tag));
hosts.add(hostName);
}
}
Assert.assertEquals(hosts.size(), 4);
}