Search in sources :

Example 1 with MockTaskStateModelFactory

use of org.apache.helix.mock.statemodel.MockTaskStateModelFactory in project helix by apache.

the class TestJobFailureTaskNotStarted method startParticipantsWithStuckTaskStateModelFactory.

protected void startParticipantsWithStuckTaskStateModelFactory() {
    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);
        }
    });
    List<String> instances = _setupTool.getClusterManagementTool().getInstancesInCluster(CLUSTER_NAME);
    _participants[0] = new MockParticipantManager(ZK_ADDR, CLUSTER_NAME, instances.get(0));
    StateMachineEngine stateMachine = _participants[0].getStateMachineEngine();
    stateMachine.registerStateModelFactory("Task", new MockTaskStateModelFactory(_participants[0], taskFactoryReg));
    _participants[0].syncStart();
    _blockedParticipant = _participants[0];
    _participants[1] = new MockParticipantManager(ZK_ADDR, CLUSTER_NAME, instances.get(1));
    stateMachine = _participants[1].getStateMachineEngine();
    stateMachine.registerStateModelFactory("Task", new TaskStateModelFactory(_participants[1], taskFactoryReg));
    _participants[1].syncStart();
    _normalParticipant = _participants[1];
}
Also used : Task(org.apache.helix.task.Task) StateMachineEngine(org.apache.helix.participant.StateMachineEngine) MockParticipantManager(org.apache.helix.integration.manager.MockParticipantManager) HashMap(java.util.HashMap) TaskCallbackContext(org.apache.helix.task.TaskCallbackContext) TaskFactory(org.apache.helix.task.TaskFactory) MockTaskStateModelFactory(org.apache.helix.mock.statemodel.MockTaskStateModelFactory) MockTaskStateModelFactory(org.apache.helix.mock.statemodel.MockTaskStateModelFactory) TaskStateModelFactory(org.apache.helix.task.TaskStateModelFactory)

Example 2 with MockTaskStateModelFactory

use of org.apache.helix.mock.statemodel.MockTaskStateModelFactory in project helix by apache.

the class TestJobTimeoutTaskNotStarted method startParticipantsWithStuckTaskStateModelFactory.

protected void startParticipantsWithStuckTaskStateModelFactory() {
    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);
        }
    });
    // start dummy participants
    for (int i = 0; i < _numNodes; i++) {
        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 MockTaskStateModelFactory(_participants[i], taskFactoryReg));
        _participants[i].syncStart();
    }
}
Also used : Task(org.apache.helix.task.Task) StateMachineEngine(org.apache.helix.participant.StateMachineEngine) MockParticipantManager(org.apache.helix.integration.manager.MockParticipantManager) HashMap(java.util.HashMap) TaskFactory(org.apache.helix.task.TaskFactory) MockTaskStateModelFactory(org.apache.helix.mock.statemodel.MockTaskStateModelFactory) TaskCallbackContext(org.apache.helix.task.TaskCallbackContext)

Aggregations

HashMap (java.util.HashMap)2 MockParticipantManager (org.apache.helix.integration.manager.MockParticipantManager)2 MockTaskStateModelFactory (org.apache.helix.mock.statemodel.MockTaskStateModelFactory)2 StateMachineEngine (org.apache.helix.participant.StateMachineEngine)2 Task (org.apache.helix.task.Task)2 TaskCallbackContext (org.apache.helix.task.TaskCallbackContext)2 TaskFactory (org.apache.helix.task.TaskFactory)2 TaskStateModelFactory (org.apache.helix.task.TaskStateModelFactory)1