ExternalView externalView =
manager.getHelixDataAccessor().getProperty(kb.externalView("TestDB"));
// Test the DISABLE_INSTANCE alerts
String participant1 = "localhost_" + (START_PORT + 3);
String participant2 = "localhost_" + (START_PORT + 2);
ConfigAccessor configAccessor = manager.getConfigAccessor();
// scope = new
// ConfigScopeBuilder().forCluster(manager.getClusterName()).forParticipant(participant1).build();
scope =
new HelixConfigScopeBuilder(ConfigScopeProperty.PARTICIPANT)
.forCluster(manager.getClusterName()).forParticipant(participant1).build();
String isEnabled = configAccessor.get(scope, "HELIX_ENABLED");
Assert.assertFalse(Boolean.parseBoolean(isEnabled));
// scope = new
// ConfigScopeBuilder().forCluster(manager.getClusterName()).forParticipant(participant2).build();
scope =
new HelixConfigScopeBuilder(ConfigScopeProperty.PARTICIPANT)
.forCluster(manager.getClusterName()).forParticipant(participant2).build();
isEnabled = configAccessor.get(scope, "HELIX_ENABLED");
Assert.assertFalse(Boolean.parseBoolean(isEnabled));
for (String partitionName : externalView.getRecord().getMapFields().keySet()) {
for (String hostName : externalView.getRecord().getMapField(partitionName).keySet()) {
if (hostName.equals(participant1) || hostName.equals(participant2)) {
Assert.assertEquals(externalView.getRecord().getMapField(partitionName).get(hostName),
"OFFLINE");
}
}
}
// enable the disabled instances
setHealthData(metrics3, metrics3);
task.aggregate();
Thread.sleep(1000);
manager.getClusterManagmentTool().enableInstance(manager.getClusterName(), participant2, true);
manager.getClusterManagmentTool().enableInstance(manager.getClusterName(), participant1, true);
result =
ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(ZK_ADDR,
CLUSTER_NAME));
Assert.assertTrue(result);
// Test the DISABLE_PARTITION case
int[] metrics4 = {
22, 115, 22, 16, 163
};
setHealthData2(metrics4);
task.aggregate();
// scope = new
// ConfigScopeBuilder().forCluster(manager.getClusterName()).forParticipant(participant1).build();
scope =
new HelixConfigScopeBuilder(ConfigScopeProperty.PARTICIPANT)
.forCluster(manager.getClusterName()).forParticipant(participant1).build();
isEnabled = configAccessor.get(scope, "HELIX_ENABLED");
Assert.assertTrue(Boolean.parseBoolean(isEnabled));
// scope = new
// ConfigScopeBuilder().forCluster(manager.getClusterName()).forParticipant(participant2).build();
scope =
new HelixConfigScopeBuilder(ConfigScopeProperty.PARTICIPANT)
.forCluster(manager.getClusterName()).forParticipant(participant2).build();
isEnabled = configAccessor.get(scope, "HELIX_ENABLED");
Assert.assertTrue(Boolean.parseBoolean(isEnabled));
result =
ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(ZK_ADDR,
CLUSTER_NAME));