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();
}
}
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();
}
}
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();
}
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();
}
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;
}
Aggregations