Search in sources :

Example 1 with DistClusterControllerStateModelFactory

use of org.apache.helix.participant.DistClusterControllerStateModelFactory in project helix by apache.

the class HelixControllerMain method startHelixController.

public static HelixManager startHelixController(final String zkConnectString, final String clusterName, final String controllerName, final String controllerMode) {
    HelixManager manager = null;
    try {
        if (controllerMode.equalsIgnoreCase(STANDALONE)) {
            manager = HelixManagerFactory.getZKHelixManager(clusterName, controllerName, InstanceType.CONTROLLER, zkConnectString);
            manager.connect();
        } else if (controllerMode.equalsIgnoreCase(DISTRIBUTED)) {
            manager = HelixManagerFactory.getZKHelixManager(clusterName, controllerName, InstanceType.CONTROLLER_PARTICIPANT, zkConnectString);
            DistClusterControllerStateModelFactory stateModelFactory = new DistClusterControllerStateModelFactory(zkConnectString);
            StateMachineEngine stateMach = manager.getStateMachineEngine();
            stateMach.registerStateModelFactory("LeaderStandby", stateModelFactory);
            manager.connect();
        } else {
            logger.error("cluster controller mode:" + controllerMode + " NOT supported");
        }
    } catch (Exception e) {
        logger.error("Exception while starting controller", e);
    }
    return manager;
}
Also used : HelixManager(org.apache.helix.HelixManager) DistClusterControllerStateModelFactory(org.apache.helix.participant.DistClusterControllerStateModelFactory) StateMachineEngine(org.apache.helix.participant.StateMachineEngine) ZkInterruptedException(org.I0Itec.zkclient.exception.ZkInterruptedException) ParseException(org.apache.commons.cli.ParseException)

Example 2 with DistClusterControllerStateModelFactory

use of org.apache.helix.participant.DistClusterControllerStateModelFactory in project helix by apache.

the class TestDistControllerStateModelFactory method testDistControllerStateModelFactory.

@Test()
public void testDistControllerStateModelFactory() {
    DistClusterControllerStateModelFactory factory = new DistClusterControllerStateModelFactory(zkAddr);
    DistClusterControllerStateModel stateModel = factory.createNewStateModel("name", "key");
    stateModel.onBecomeStandbyFromOffline(null, null);
}
Also used : DistClusterControllerStateModel(org.apache.helix.participant.DistClusterControllerStateModel) DistClusterControllerStateModelFactory(org.apache.helix.participant.DistClusterControllerStateModelFactory) Test(org.testng.annotations.Test)

Example 3 with DistClusterControllerStateModelFactory

use of org.apache.helix.participant.DistClusterControllerStateModelFactory in project helix by apache.

the class ClusterDistributedController method run.

@Override
public void run() {
    try {
        StateMachineEngine stateMach = getStateMachineEngine();
        DistClusterControllerStateModelFactory lsModelFactory = new DistClusterControllerStateModelFactory(_zkAddress);
        stateMach.registerStateModelFactory("LeaderStandby", lsModelFactory);
        connect();
        _startCountDown.countDown();
        _stopCountDown.await();
    } catch (Exception e) {
        LOG.error("exception running controller-manager", e);
    } finally {
        _startCountDown.countDown();
        disconnect();
        _waitStopFinishCountDown.countDown();
    }
}
Also used : StateMachineEngine(org.apache.helix.participant.StateMachineEngine) DistClusterControllerStateModelFactory(org.apache.helix.participant.DistClusterControllerStateModelFactory)

Aggregations

DistClusterControllerStateModelFactory (org.apache.helix.participant.DistClusterControllerStateModelFactory)3 StateMachineEngine (org.apache.helix.participant.StateMachineEngine)2 ZkInterruptedException (org.I0Itec.zkclient.exception.ZkInterruptedException)1 ParseException (org.apache.commons.cli.ParseException)1 HelixManager (org.apache.helix.HelixManager)1 DistClusterControllerStateModel (org.apache.helix.participant.DistClusterControllerStateModel)1 Test (org.testng.annotations.Test)1