Package net.sf.katta.operation.master

Examples of net.sf.katta.operation.master.MasterOperation


  public void testPublishMaster() throws Exception {
    Master master1 = mock(Master.class);
    Master master2 = mock(Master.class);
    when(master1.getMasterName()).thenReturn("master1");
    when(master2.getMasterName()).thenReturn("master2");
    MasterOperation operation = mock(MasterOperation.class);
    _protocol.addMasterOperation(operation);

    MasterQueue queue = _protocol.publishMaster(master1);
    assertNotNull(queue);
    assertNotNull(_protocol.getMasterMD());
View Full Code Here


  }

  @Test(timeout = 15000)
  public void testWatchDogMechanism() throws Exception {
    final MasterQueue queue = new MasterQueue(_zk.getZkClient(), getRootPath());
    MasterOperation masterOperation = mock(MasterOperation.class);
    queue.add(masterOperation);

    List<OperationId> operationIds = new ArrayList<OperationId>();
    operationIds.add(new OperationId("node1", "e1"));
View Full Code Here

  @Test(timeout = 15000)
  public void testKeepStateBetweenExecutionAndCompletion() throws Exception {
    final MasterQueue queue = new MasterQueue(_zk.getZkClient(), getRootPath());

    MasterOperation masterOperation = new StatefulMasterOperation();
    queue.add(masterOperation);

    masterOperation = queue.peek();
    masterOperation.execute(mock(MasterContext.class), Collections.EMPTY_LIST);

    queue.moveOperationToWatching(masterOperation, Collections.EMPTY_LIST);
    assertEquals(1, queue.getWatchdogs().size());
    masterOperation = queue.getWatchdogs().get(0).getOperation();
    masterOperation.nodeOperationsComplete(mock(MasterContext.class), Collections.EMPTY_LIST);
  }
View Full Code Here

  @Test(timeout = 15000)
  public void testWatchDogCleanup() throws Exception {
    ZkClient zkClientSpy = spy(_zk.getZkClient());
    MasterQueue queue = new MasterQueue(zkClientSpy, getRootPath());
    MasterOperation masterOperation = mock(MasterOperation.class);
    String elementName = queue.add(masterOperation);

    List<OperationId> operationIds = new ArrayList<OperationId>();
    operationIds.add(new OperationId("node1", "e1"));
View Full Code Here

    Master master = new Master(_zk.getInteractionProtocol(), false);
    Node node = Mocks.mockNode();// leave safe mode
    _protocol.publishNode(node, new NodeMetaData("node1"));
    master.start();

    MasterOperation operation1 = mock(MasterOperation.class, withSettings().serializable());
    MasterOperation operation2 = mock(MasterOperation.class, withSettings().serializable());

    SerializableCountDownLatchAnswer answer = new SerializableCountDownLatchAnswer(2);
    when(operation1.getExecutionInstruction((List<MasterOperation>) notNull()))
            .thenReturn(ExecutionInstruction.EXECUTE);
    when(operation2.getExecutionInstruction((List<MasterOperation>) notNull()))
            .thenReturn(ExecutionInstruction.EXECUTE);
    when(operation1.execute((MasterContext) notNull(), (List<MasterOperation>) notNull())).thenAnswer(answer);
    when(operation2.execute((MasterContext) notNull(), (List<MasterOperation>) notNull())).thenAnswer(answer);
    _protocol.addMasterOperation(operation1);
    _protocol.addMasterOperation(operation2);
    answer.getCountDownLatch().await();

    master.shutdown();
View Full Code Here

  protected final MasterContext _context = new MasterContext(_protocol, Mocks.mockMaster(),
          new DefaultDistributionPolicy(), _queue);

  @Test(timeout = 10000)
  public void testSafeMode() throws Exception {
    final MasterOperation operation = mockOperation(ExecutionInstruction.EXECUTE);
    when(_queue.peek()).thenReturn(operation).thenAnswer(new SleepingAnswer());
    when(_protocol.getLiveNodes()).thenReturn(EMPTY_LIST);

    long safeModeMaxTime = 200;
    OperatorThread operatorThread = new OperatorThread(_context, safeModeMaxTime);
View Full Code Here

    operatorThread.join();
  }

  @Test(timeout = 10000)
  public void testOperationExecution() throws Exception {
    final MasterOperation masterOperation1 = mockOperation(ExecutionInstruction.EXECUTE);
    final MasterOperation masterOperation2 = mockOperation(ExecutionInstruction.EXECUTE);
    final MasterOperation masterOperation3 = mockOperation(ExecutionInstruction.EXECUTE);
    when(_queue.peek()).thenReturn(masterOperation1).thenReturn(masterOperation2).thenReturn(masterOperation3)
            .thenAnswer(new SleepingAnswer());

    when(_protocol.getLiveNodes()).thenReturn(Arrays.asList("node1"));
    long safeModeMaxTime = 200;
View Full Code Here

    String nodeName = "node1";
    when(_protocol.getLiveNodes()).thenReturn(Arrays.asList(nodeName));
    List<OperationId> operationIds = new ArrayList<OperationId>();
    operationIds.add(new OperationId(nodeName, "e1"));

    final MasterOperation leaderOperation = mock(MasterOperation.class);
    when(leaderOperation.execute(_context, EMPTY_LIST)).thenReturn(operationIds);
    setupExecutionInstruction(leaderOperation, ExecutionInstruction.EXECUTE);
    when(_queue.peek()).thenReturn(leaderOperation).thenAnswer(new SleepingAnswer());

    when(_protocol.isNodeOperationQueued(operationIds.get(0))).thenReturn(false);
    OperationWatchdog watchdog = mock(OperationWatchdog.class);
View Full Code Here

    }, TimeUnit.SECONDS, 30);
  }

  @Test(timeout = 10000)
  public void testOperationLocks_CancelLockedOperation() throws Exception {
    final MasterOperation leaderOperation1 = mock(MasterOperation.class);
    final MasterOperation leaderOperation2 = mock(MasterOperation.class);
    ExecutionInstruction lockInstruction = MasterOperation.ExecutionInstruction.CANCEL;

    runLockSituation(leaderOperation1, leaderOperation2, lockInstruction);
    verify(leaderOperation2, times(0)).execute(_context, EMPTY_LIST);
  }
View Full Code Here

    verify(leaderOperation2, times(0)).execute(_context, EMPTY_LIST);
  }

  @Test(timeout = 10000)
  public void testOperationLocks_SuspendLockedTask() throws Exception {
    final MasterOperation leaderOperation1 = mock(MasterOperation.class);
    final MasterOperation leaderOperation2 = mock(MasterOperation.class);

    ExecutionInstruction lockInstruction = MasterOperation.ExecutionInstruction.ADD_TO_QUEUE_TAIL;
    runLockSituation(leaderOperation1, leaderOperation2, lockInstruction);
    verify(leaderOperation2, times(0)).execute(_context, EMPTY_LIST);
    verify(_queue, times(1)).add(leaderOperation2);
View Full Code Here

TOP

Related Classes of net.sf.katta.operation.master.MasterOperation

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.