Search in sources :

Example 26 with StateMachineEngine

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

the class Consumer method connect.

public void connect() {
    try {
        _manager = HelixManagerFactory.getZKHelixManager(_clusterName, _consumerId, InstanceType.PARTICIPANT, _zkAddr);
        StateMachineEngine stateMach = _manager.getStateMachineEngine();
        ConsumerStateModelFactory modelFactory = new ConsumerStateModelFactory(_consumerId, _mqServer);
        stateMach.registerStateModelFactory(SetupConsumerCluster.DEFAULT_STATE_MODEL, modelFactory);
        _manager.connect();
        Thread.currentThread().join();
    } catch (InterruptedException e) {
        System.err.println(" [-] " + _consumerId + " is interrupted ...");
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } finally {
        disconnect();
    }
}
Also used : StateMachineEngine(org.apache.helix.participant.StateMachineEngine)

Example 27 with StateMachineEngine

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

the class FileStore method connect.

public void connect() {
    try {
        _manager = HelixManagerFactory.getZKHelixManager(_clusterName, _serverId, InstanceType.PARTICIPANT, _zkAddr);
        StateMachineEngine stateMach = _manager.getStateMachineEngine();
        FileStoreStateModelFactory modelFactory = new FileStoreStateModelFactory(_manager);
        stateMach.registerStateModelFactory(SetupCluster.DEFAULT_STATE_MODEL, modelFactory);
        _manager.connect();
        // _manager.addExternalViewChangeListener(replicator);
        Thread.currentThread().join();
    } catch (InterruptedException e) {
        System.err.println(" [-] " + _serverId + " is interrupted ...");
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        disconnect();
    }
}
Also used : StateMachineEngine(org.apache.helix.participant.StateMachineEngine)

Example 28 with StateMachineEngine

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

the class BootstrapReplyHandler method start.

public void start() throws Exception {
    manager = HelixManagerFactory.getZKHelixManager(clusterName, instanceName, InstanceType.PARTICIPANT, zkConnectString);
    stateModelFactory = new BootstrapHandler();
    // genericStateMachineHandler = new StateMachineEngine();
    // genericStateMachineHandler.registerStateModelFactory("MasterSlave", stateModelFactory);
    StateMachineEngine stateMach = manager.getStateMachineEngine();
    stateMach.registerStateModelFactory("MasterSlave", stateModelFactory);
    manager.getMessagingService().registerMessageHandlerFactory(MessageType.STATE_TRANSITION.name(), stateMach);
    manager.getMessagingService().registerMessageHandlerFactory(MessageType.USER_DEFINE_MSG.name(), new CustomMessageHandlerFactory());
    manager.connect();
}
Also used : StateMachineEngine(org.apache.helix.participant.StateMachineEngine)

Example 29 with StateMachineEngine

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

the class TaskSynchronizedTestBase method startParticipant.

protected void startParticipant(int i) {
    Map<String, TaskFactory> taskFactoryReg = new HashMap<String, TaskFactory>();
    taskFactoryReg.put(MockTask.TASK_COMMAND, new TaskFactory() {

        @Override
        public Task createNewTask(TaskCallbackContext context) {
            return new MockTask(context);
        }
    });
    String instanceName = PARTICIPANT_PREFIX + "_" + (_startPort + i);
    _participants[i] = new MockParticipantManager(ZK_ADDR, CLUSTER_NAME, instanceName);
    // Register a Task state model factory.
    StateMachineEngine stateMachine = _participants[i].getStateMachineEngine();
    stateMachine.registerStateModelFactory("Task", new TaskStateModelFactory(_participants[i], taskFactoryReg));
    _participants[i].syncStart();
}
Also used : MockTask(org.apache.helix.integration.task.MockTask) StateMachineEngine(org.apache.helix.participant.StateMachineEngine) MockParticipantManager(org.apache.helix.integration.manager.MockParticipantManager) HashMap(java.util.HashMap) MockTask(org.apache.helix.integration.task.MockTask)

Example 30 with StateMachineEngine

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

the class DummyProcess method start.

public HelixManager start() throws Exception {
    HelixManager manager = null;
    // zk cluster manager
    if (_clusterMangerType.equalsIgnoreCase("zk")) {
        manager = HelixManagerFactory.getZKHelixManager(_clusterName, _instanceName, InstanceType.PARTICIPANT, _zkConnectString);
    } else {
        throw new IllegalArgumentException("Unsupported cluster manager type:" + _clusterMangerType);
    }
    stateModelFactory = new DummyStateModelFactory(_transDelayInMs);
    DummyLeaderStandbyStateModelFactory stateModelFactory1 = new DummyLeaderStandbyStateModelFactory(_transDelayInMs);
    DummyOnlineOfflineStateModelFactory stateModelFactory2 = new DummyOnlineOfflineStateModelFactory(_transDelayInMs);
    // genericStateMachineHandler = new StateMachineEngine();
    StateMachineEngine stateMach = manager.getStateMachineEngine();
    stateMach.registerStateModelFactory("MasterSlave", stateModelFactory);
    stateMach.registerStateModelFactory("LeaderStandby", stateModelFactory1);
    stateMach.registerStateModelFactory("OnlineOffline", stateModelFactory2);
    manager.connect();
    // genericStateMachineHandler);
    return manager;
}
Also used : HelixManager(org.apache.helix.HelixManager) StateMachineEngine(org.apache.helix.participant.StateMachineEngine)

Aggregations

StateMachineEngine (org.apache.helix.participant.StateMachineEngine)30 MockParticipantManager (org.apache.helix.integration.manager.MockParticipantManager)11 HashMap (java.util.HashMap)9 HelixManager (org.apache.helix.HelixManager)7 Task (org.apache.helix.task.Task)7 TaskCallbackContext (org.apache.helix.task.TaskCallbackContext)7 TaskFactory (org.apache.helix.task.TaskFactory)7 ClusterControllerManager (org.apache.helix.integration.manager.ClusterControllerManager)6 TaskStateModelFactory (org.apache.helix.task.TaskStateModelFactory)6 ClusterSetup (org.apache.helix.tools.ClusterSetup)4 BeforeClass (org.testng.annotations.BeforeClass)4 IOException (java.io.IOException)3 MockTask (org.apache.helix.integration.task.MockTask)3 TaskDriver (org.apache.helix.task.TaskDriver)3 Test (org.testng.annotations.Test)3 Date (java.util.Date)2 ParseException (org.apache.commons.cli.ParseException)2 ZNRecord (org.apache.helix.ZNRecord)2 MockDelayMSStateModelFactory (org.apache.helix.mock.participant.MockDelayMSStateModelFactory)2 MockTaskStateModelFactory (org.apache.helix.mock.statemodel.MockTaskStateModelFactory)2