Package org.apache.helix.Mocks

Examples of org.apache.helix.Mocks.MockHelixTaskExecutor


    StateModelDefinition stateModelDef =
        new StateModelDefinition(generator.generateConfigForMasterSlave());
    Builder keyBuilder = accessor.keyBuilder();
    accessor.setProperty(keyBuilder.stateModelDef("MasterSlave"), stateModelDef);

    MockHelixTaskExecutor executor = new MockHelixTaskExecutor();
    MockStateModel stateModel = new MockStateModel();
    NotificationContext context;
    executor.registerMessageHandlerFactory(MessageType.TASK_REPLY.toString(),
                                           new AsyncCallbackService());
    // String clusterName =" testcluster";
    context = new NotificationContext(manager);
    CurrentState currentStateDelta = new CurrentState("TestDB");
    currentStateDelta.setState("TestDB_0", "OFFLINE");
    HelixStateTransitionHandler handler =
        new HelixStateTransitionHandler(stateModel,
                                        message,
                                        context,
                                        currentStateDelta,
                                        executor);

    executor.scheduleTask(message, handler, context);
    while (!executor.isDone(msgId + "/" + message.getPartitionName()))
    {
      Thread.sleep(500);
    }
    AssertJUnit.assertTrue(stateModel.stateModelInvoked);
    System.out.println("END TestCMTaskExecutor");
View Full Code Here


    StateModelDefinition stateModelDef =
        new StateModelDefinition(StateModelConfigGenerator.generateConfigForMasterSlave());
    Builder keyBuilder = accessor.keyBuilder();
    accessor.setProperty(keyBuilder.stateModelDef("MasterSlave"), stateModelDef);

    MockHelixTaskExecutor executor = new MockHelixTaskExecutor();
    MockStateModel stateModel = new MockStateModel();
    executor.registerMessageHandlerFactory(MessageType.TASK_REPLY.toString(),
        new AsyncCallbackService());

    NotificationContext context = new NotificationContext(manager);
    CurrentState currentStateDelta = new CurrentState("TestDB");
    currentStateDelta.setState("TestDB_0", "OFFLINE");

    StateModelFactory<MockStateModel> stateModelFactory = new StateModelFactory<MockStateModel>() {

      @Override
      public MockStateModel createNewStateModel(String partitionName) {
        // TODO Auto-generated method stub
        return new MockStateModel();
      }

    };
    HelixStateTransitionHandler handler =
        new HelixStateTransitionHandler(stateModelFactory, stateModel, message, context,
            currentStateDelta);

    HelixTask task = new HelixTask(message, context, handler, executor);
    executor.scheduleTask(task);
    for (int i = 0; i < 10; i++) {
      if (!executor.isDone(task.getTaskId())) {
        Thread.sleep(500);
      }
    }
    AssertJUnit.assertTrue(stateModel.stateModelInvoked);
    System.out.println("END TestCMTaskExecutor");
View Full Code Here

    StateModelDefinition stateModelDef =
        new StateModelDefinition(StateModelConfigGenerator.generateConfigForMasterSlave());
    Builder keyBuilder = accessor.keyBuilder();
    accessor.setProperty(keyBuilder.stateModelDef("MasterSlave"), stateModelDef);

    MockHelixTaskExecutor executor = new MockHelixTaskExecutor();
    MockStateModel stateModel = new MockStateModel();
    executor.registerMessageHandlerFactory(MessageType.TASK_REPLY.toString(),
        new AsyncCallbackService());

    NotificationContext context = new NotificationContext(manager);
    CurrentState currentStateDelta = new CurrentState("TestDB");
    currentStateDelta.setState(PartitionId.from("TestDB_0"), State.from("OFFLINE"));

    StateTransitionHandlerFactory<MockStateModel> stateModelFactory = new StateTransitionHandlerFactory<MockStateModel>() {

      @Override
      public MockStateModel createStateTransitionHandler(PartitionId partition) {
        // TODO Auto-generated method stub
        return new MockStateModel();
      }

    };
    HelixStateTransitionHandler handler =
        new HelixStateTransitionHandler(stateModelFactory, stateModel, message, context,
            currentStateDelta);

    HelixTask task = new HelixTask(message, context, handler, executor);
    executor.scheduleTask(task);
    for (int i = 0; i < 10; i++) {
      if (!executor.isDone(task.getTaskId())) {
        Thread.sleep(500);
      }
    }
    AssertJUnit.assertTrue(stateModel.stateModelInvoked);
    System.out.println("END TestCMTaskExecutor");
View Full Code Here

    StateModelDefinition stateModelDef =
        new StateModelDefinition(StateModelConfigGenerator.generateConfigForMasterSlave());
    Builder keyBuilder = accessor.keyBuilder();
    accessor.setProperty(keyBuilder.stateModelDef("MasterSlave"), stateModelDef);

    MockHelixTaskExecutor executor = new MockHelixTaskExecutor();
    MockStateModel stateModel = new MockStateModel();
    executor.registerMessageHandlerFactory(MessageType.TASK_REPLY.toString(),
        new AsyncCallbackService());

    NotificationContext context = new NotificationContext(manager);
    CurrentState currentStateDelta = new CurrentState("TestDB");
    currentStateDelta.setState(PartitionId.from("TestDB_0"), State.from("OFFLINE"));

    StateModelFactory<MockStateModel> stateModelFactory = new StateModelFactory<MockStateModel>() {

      @Override
      public MockStateModel createNewStateModel(String partitionName) {
        // TODO Auto-generated method stub
        return new MockStateModel();
      }

    };
    HelixStateTransitionHandler handler =
        new HelixStateTransitionHandler(stateModelFactory, stateModel, message, context,
            currentStateDelta);

    HelixTask task = new HelixTask(message, context, handler, executor);
    executor.scheduleTask(task);
    for (int i = 0; i < 10; i++) {
      if (!executor.isDone(task.getTaskId())) {
        Thread.sleep(500);
      }
    }
    AssertJUnit.assertTrue(stateModel.stateModelInvoked);
    System.out.println("END TestCMTaskExecutor");
View Full Code Here

    StateModelDefinition stateModelDef =
        new StateModelDefinition(generator.generateConfigForMasterSlave());
    Builder keyBuilder = accessor.keyBuilder();
    accessor.setProperty(keyBuilder.stateModelDef("MasterSlave"), stateModelDef);

    MockHelixTaskExecutor executor = new MockHelixTaskExecutor();
    MockStateModel stateModel = new MockStateModel();
    NotificationContext context;
    executor.registerMessageHandlerFactory(MessageType.TASK_REPLY.toString(),
                                           new AsyncCallbackService());
    // String clusterName =" testcluster";
    context = new NotificationContext(manager);
    CurrentState currentStateDelta = new CurrentState("TestDB");
    currentStateDelta.setState("TestDB_0", "OFFLINE");
    HelixStateTransitionHandler handler =
        new HelixStateTransitionHandler(stateModel,
                                        message,
                                        context,
                                        currentStateDelta);

  HelixTask task = new HelixTask(message, context, handler, executor);
  executor.scheduleTask(task);
  for (int i = 0; i < 10; i++) {
    if (!executor.isDone(task.getTaskId())) {
      Thread.sleep(500);
    }
  }
    AssertJUnit.assertTrue(stateModel.stateModelInvoked);
    System.out.println("END TestCMTaskExecutor");
View Full Code Here

TOP

Related Classes of org.apache.helix.Mocks.MockHelixTaskExecutor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.