// start participants
for (int i = 0; i < 5; i++) {
String instanceName = "localhost_" + (12918 + i);
if (i == 4) {
participants[i] = new MockParticipant(_zkaddr, clusterName, instanceName);
participants[i].setTransition(new KillOtherTransition(participants[0]));
} else {
participants[i] = new MockParticipant(_zkaddr, clusterName, instanceName);
}
participants[i].syncStart();
}
boolean result =
ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(_zkaddr,
clusterName));
Assert.assertTrue(result);
// restart
Thread.sleep(500);
MockParticipant participant =
new MockParticipant(_zkaddr, participants[0].getClusterName(),
participants[0].getInstanceName());
System.err.println("Restart " + participant.getInstanceName());
participant.syncStart();
result =
ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(_zkaddr,
clusterName));
Assert.assertTrue(result);
// clean up
controller.syncStop();
for (int i = 0; i < 5; i++) {
participants[i].syncStop();
}
participant.syncStop();
System.out.println("START testRestartParticipant at " + new Date(System.currentTimeMillis()));
}