StateModelDefId.from("OnlineOffline"), new TestHelixConnection.MockStateModelFactory());
participants[i].start();
}
// Start the controller
HelixController controller =
connection.createController(ClusterId.from(clusterName), ControllerId.from("controller"));
controller.start();
Thread.sleep(500);
// Verify balanced cluster
boolean result =
ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(_zkaddr,
clusterName));
Assert.assertTrue(result);
// Drop a partition from the first participant
HelixAdmin admin = connection.createClusterManagementTool();
IdealState idealState = admin.getResourceIdealState(clusterName, RESOURCE_NAME);
Map<ParticipantId, State> participantStateMap =
idealState.getParticipantStateMap(PartitionId.from(RESOURCE_NAME + "_0"));
participantStateMap.remove(ParticipantId.from("localhost_12918"));
idealState.setParticipantStateMap(PartitionId.from(RESOURCE_NAME + "_0"), participantStateMap);
admin.setResourceIdealState(clusterName, RESOURCE_NAME, idealState);
Thread.sleep(1000);
// Verify balanced cluster
result =
ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(_zkaddr,
clusterName));
Assert.assertTrue(result);
// Drop a partition from the second participant
participantStateMap = idealState.getParticipantStateMap(PartitionId.from(RESOURCE_NAME + "_1"));
participantStateMap.remove(ParticipantId.from("localhost_12919"));
idealState.setParticipantStateMap(PartitionId.from(RESOURCE_NAME + "_1"), participantStateMap);
admin.setResourceIdealState(clusterName, RESOURCE_NAME, idealState);
Thread.sleep(1000);
// Verify balanced cluster
result =
ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(_zkaddr,
clusterName));
Assert.assertTrue(result);
// Clean up
controller.stop();
for (HelixParticipant participant : participants) {
participant.stop();
}
admin.dropCluster(clusterName);
System.out.println("END " + clusterName + " at " + new Date(System.currentTimeMillis()));