Search in sources :

Example 1 with MockBootstrapModelFactory

use of org.apache.helix.mock.participant.MockBootstrapModelFactory in project helix by apache.

the class TestNonOfflineInitState method testNonOfflineInitState.

@Test
public void testNonOfflineInitState() throws Exception {
    System.out.println("START testNonOfflineInitState at " + new Date(System.currentTimeMillis()));
    String clusterName = getShortClassName();
    setupCluster(// participant port
    clusterName, // participant port
    ZK_ADDR, // participant port
    12918, // participant name prefix
    "localhost", // resource name prefix
    "TestDB", // resources
    1, // partitions per resource
    10, // number of nodes
    5, // replicas
    1, "Bootstrap", // do rebalance
    true);
    ClusterControllerManager controller = new ClusterControllerManager(ZK_ADDR, clusterName, "controller_0");
    controller.syncStart();
    // start participants
    MockParticipantManager[] participants = new MockParticipantManager[5];
    for (int i = 0; i < 5; i++) {
        String instanceName = "localhost_" + (12918 + i);
        participants[i] = new MockParticipantManager(ZK_ADDR, clusterName, instanceName);
        // add a state model with non-OFFLINE initial state
        StateMachineEngine stateMach = participants[i].getStateMachineEngine();
        MockBootstrapModelFactory bootstrapFactory = new MockBootstrapModelFactory();
        stateMach.registerStateModelFactory("Bootstrap", bootstrapFactory);
        participants[i].syncStart();
    }
    boolean result = ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(ZK_ADDR, clusterName));
    Assert.assertTrue(result);
    // clean up
    controller.syncStop();
    for (int i = 0; i < 5; i++) {
        participants[i].syncStop();
    }
    System.out.println("END testNonOfflineInitState at " + new Date(System.currentTimeMillis()));
}
Also used : ClusterControllerManager(org.apache.helix.integration.manager.ClusterControllerManager) StateMachineEngine(org.apache.helix.participant.StateMachineEngine) MockParticipantManager(org.apache.helix.integration.manager.MockParticipantManager) MockBootstrapModelFactory(org.apache.helix.mock.participant.MockBootstrapModelFactory) BestPossAndExtViewZkVerifier(org.apache.helix.tools.ClusterStateVerifier.BestPossAndExtViewZkVerifier) Date(java.util.Date) Test(org.testng.annotations.Test)

Aggregations

Date (java.util.Date)1 ClusterControllerManager (org.apache.helix.integration.manager.ClusterControllerManager)1 MockParticipantManager (org.apache.helix.integration.manager.MockParticipantManager)1 MockBootstrapModelFactory (org.apache.helix.mock.participant.MockBootstrapModelFactory)1 StateMachineEngine (org.apache.helix.participant.StateMachineEngine)1 BestPossAndExtViewZkVerifier (org.apache.helix.tools.ClusterStateVerifier.BestPossAndExtViewZkVerifier)1 Test (org.testng.annotations.Test)1