Package net.sf.katta.operation.node

Examples of net.sf.katta.operation.node.OperationResult


    public void run() {
      try {
        while (_nodeContext.getNode().isRunning()) {
          try {
            NodeOperation operation = _queue.peek();
            OperationResult operationResult;
            try {
              LOG.info("executing " + operation);
              operationResult = operation.execute(_nodeContext);
            } catch (Exception e) {
              ExceptionUtil.rethrowInterruptedException(e);
              LOG.error(_nodeContext.getNode().getName() + ": failed to execute " + operation, e);
              operationResult = new OperationResult(_nodeContext.getNode().getName(), e);
            }
            _queue.complete(operationResult);// only remove after finish
          } catch (Throwable e) {
            ExceptionUtil.rethrowInterruptedException(e);
            LOG.fatal(_nodeContext.getNode().getName() + ": operation failure ", e);
View Full Code Here


    InteractionProtocol protocol = _context.getProtocol();
    protocol.unregisterComponent(this);
    try {
      List<OperationResult> operationResults = new ArrayList<OperationResult>(_openOperationIds.size());
      for (OperationId operationId : _operationIds) {
        OperationResult operationResult = protocol.getNodeOperationResult(operationId, true);
        if (operationResult != null && operationResult.getUnhandledException() != null) {
          // TODO jz: do we need to inform the master operation ?
          LOG.error("received unhandlde exception from node " + operationId.getNodeName(), operationResult
                  .getUnhandledException());
        }
        operationResults.add(operationResult);// we add null ones
      }
      _masterOperation.nodeOperationsComplete(_context, operationResults);
View Full Code Here

    final NodeQueue queue = new NodeQueue(_zk.getZkClient(), getRootPath());
    NodeOperation nodeOperation = mock(NodeOperation.class);
    String elementId = queue.add(nodeOperation);

    assertNotNull(queue.peek());
    OperationResult result = new OperationResult("ndoe1");
    queue.complete(result);
    assertNotNull(queue.getResult(elementId, false));

    assertNotNull(queue.getResult(elementId, true));
    assertNull(queue.getResult(elementId, true));
View Full Code Here

    ZkClient zkClientSpy = spy(_zk.getZkClient());
    NodeQueue queue = new NodeQueue(zkClientSpy, getRootPath());
    NodeOperation nodeOperation = mock(NodeOperation.class);
    String elementName = queue.add(nodeOperation);

    OperationResult result = new OperationResult("node1");
    // cause a unclean state
    doThrow(new IllegalStateException("test exception")).when(zkClientSpy).delete(endsWith(elementName));
    try {
      queue.complete(result);
      verify(zkClientSpy).createEphemeral(endsWith(elementName));
View Full Code Here

    List<OperationResult> operationResults = new ArrayList<OperationResult>();
    int i = 0;
    for (NodeQueue nodeQueue : nodeQueues) {
      NodeOperation nodeOperation = nodeQueue.peek();
      assertNotNull(nodeOperation);
      OperationResult result = new OperationResult(_nodes.get(i).getName());
      operationResults.add(result);
      nodeQueue.complete(result);
      i++;
    }
    operationWatchdog.join();
    assertTrue(operationWatchdog.isDone());
    assertEquals(0, operationWatchdog.getOpenOperationCount());
    ArgumentCaptor<List> argument = ArgumentCaptor.forClass(List.class);

    verify(_masterOperation, times(1)).nodeOperationsComplete(eq(_context), argument.capture());
    List<OperationResult> capturedResults = argument.getValue();
    assertEquals(operationResults.size(), capturedResults.size());
    for (OperationResult result : capturedResults) {
      assertNotNull(result);
      assertNotNull(result.getNodeName());
    }
  }
View Full Code Here

TOP

Related Classes of net.sf.katta.operation.node.OperationResult

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.