MockParticipant[] participants = new MockParticipant[5];
for (int i = 0; i < 5; i++)
{
String instanceName = "localhost_" + (12918 + i);
ZkHelixTestManager manager =
new ZkHelixTestManager(clusterName,
instanceName,
InstanceType.PARTICIPANT,
ZK_ADDR);
participants[i] = new MockParticipant(manager, null);
participants[i].syncStart();
}
ZkHelixTestManager controller =
new ZkHelixTestManager(clusterName,
"controller_0",
InstanceType.CONTROLLER,
ZK_ADDR);
controller.connect();
boolean result;
result =
ClusterStateVerifier.verifyByPolling(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(ZK_ADDR,
clusterName));
Assert.assertTrue(result);
// participant session expiry
ZkHelixTestManager participantToExpire = (ZkHelixTestManager)participants[1].getManager();
System.out.println("Expire participant session");
String oldSessionId = participantToExpire.getSessionId();
ZkTestHelper.expireSession(participantToExpire.getZkClient());
String newSessionId = participantToExpire.getSessionId();
System.out.println("oldSessionId: " + oldSessionId + ", newSessionId: " + newSessionId);
Assert.assertTrue(newSessionId.compareTo(oldSessionId) > 0, "Session id should be increased after expiry");
ClusterSetup setupTool = new ClusterSetup(ZK_ADDR);
setupTool.addResourceToCluster(clusterName, "TestDB1", 10, "MasterSlave");