use of org.apache.helix.mock.participant.SleepTransition in project helix by apache.
the class TestClusterVerifier method testSleepTransition.
@Test
public void testSleepTransition() throws InterruptedException {
HelixClusterVerifier bestPossibleVerifier = new BestPossibleExternalViewVerifier.Builder(_clusterName).setZkClient(_gZkClient).build();
Assert.assertTrue(bestPossibleVerifier.verify(10000));
HelixClusterVerifier strictMatchVerifier = new StrictMatchExternalViewVerifier.Builder(_clusterName).setZkClient(_gZkClient).build();
Assert.assertTrue(strictMatchVerifier.verify(10000));
// Re-start a new participant with sleeping transition(all state model transition cannot finish)
_participants[0].syncStop();
Thread.sleep(1000);
_participants[0] = new MockParticipantManager(ZK_ADDR, _clusterName, _participants[0].getInstanceName());
_participants[0].setTransition(new SleepTransition(99999999));
_participants[0].syncStart();
// The new participant causes rebalance, but the state transitions are all stuck
Thread.sleep(1000);
Assert.assertFalse(strictMatchVerifier.verify(3000));
}
use of org.apache.helix.mock.participant.SleepTransition in project helix by apache.
the class TestStateTransitionThrottle method testTransitionThrottleOnRecoveryPartition.
@Test
public void testTransitionThrottleOnRecoveryPartition() throws Exception {
String clusterName = getShortClassName() + "testRecoveryPartition";
MockParticipantManager[] participants = new MockParticipantManager[participantCount];
System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis()));
final ZKHelixDataAccessor accessor = new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_gZkClient));
setupCluster(clusterName, accessor);
// start partial participants
for (int i = 0; i < participantCount - 1; i++) {
participants[i] = new MockParticipantManager(ZK_ADDR, clusterName, "localhost_" + (12918 + i));
if (i == 0) {
// One participant 0, delay processing partition 0 transition
final String delayedPartitionName = resourceName + "_0";
participants[i].setTransition(new SleepTransition(99999999) {
@Override
public void doTransition(Message message, NotificationContext context) throws InterruptedException {
String partition = message.getPartitionName();
if (partition.equals(delayedPartitionName)) {
super.doTransition(message, context);
}
}
});
}
participants[i].syncStart();
}
ClusterControllerManager controller = new ClusterControllerManager(ZK_ADDR, clusterName, "controller_0");
controller.syncStart();
BestPossibleExternalViewVerifier verifier = new BestPossibleExternalViewVerifier.Builder(clusterName).setZkClient(_gZkClient).build();
// Won't match, since there is pending transition
Assert.assertFalse(verifier.verify(3000));
participants[participantCount - 1] = new MockParticipantManager(ZK_ADDR, clusterName, "localhost_" + (12918 + participantCount - 1));
participants[participantCount - 1].syncStart();
// Load balance transition won't be scheduled since there is pending recovery balance transition
Assert.assertFalse(pollForPartitionAssignment(accessor, participants[participantCount - 1], resourceName, 5000));
// Stop participant, so blocking transition is removed.
participants[0].syncStop();
Assert.assertTrue(pollForPartitionAssignment(accessor, participants[participantCount - 1], resourceName, 5000));
// clean up
controller.syncStop();
for (int i = 0; i < participantCount; i++) {
participants[i].syncStop();
}
System.out.println("END " + clusterName + " at " + new Date(System.currentTimeMillis()));
}
Aggregations