public void execute(Operation op) {
   String executorName = op.getExecutorName();
   if (executorName == null) {
     int partitionId = getPartitionIdForExecution(op);
     boolean hasPriority = op.isUrgent();
     execute(op, partitionId, hasPriority);
   } else {
     executeOnExternalExecutor(op, executorName);
   }
 }
Beispiel #2
0
  @Override
  public void afterRun() throws Exception {
    if (sync && getCallId() != 0 && originalCaller != null) {
      final NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
      final long callId = getCallId();
      final InternalOperationService operationService = nodeEngine.operationService;

      if (!nodeEngine.getThisAddress().equals(originalCaller)) {
        BackupResponse backupResponse = new BackupResponse(callId, backupOp.isUrgent());
        operationService.send(backupResponse, originalCaller);
      } else {
        operationService.notifyBackupCall(callId);
      }
    }
  }
Beispiel #3
0
  @Override
  public void afterRun() throws Exception {
    if (!valid || !sync || getCallId() == 0 || originalCaller == null) {
      return;
    }

    NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
    long callId = getCallId();
    OperationServiceImpl operationService = (OperationServiceImpl) nodeEngine.getOperationService();

    if (nodeEngine.getThisAddress().equals(originalCaller)) {
      operationService.getInvocationsRegistry().notifyBackupComplete(callId);
    } else {
      BackupResponse backupResponse = new BackupResponse(callId, backupOp.isUrgent());
      operationService.send(backupResponse, originalCaller);
    }
  }
  @Override
  public boolean send(Operation op, Address target) {
    checkNotNull(target, "Target is required!");

    if (thisAddress.equals(target)) {
      throw new IllegalArgumentException("Target is this node! -> " + target + ", op: " + op);
    }

    byte[] bytes = serializationService.toBytes(op);
    int partitionId = op.getPartitionId();
    Packet packet = new Packet(bytes, partitionId).setFlag(FLAG_OP);

    if (op.isUrgent()) {
      packet.setFlag(FLAG_URGENT);
    }

    ConnectionManager connectionManager = node.getConnectionManager();
    Connection connection = connectionManager.getOrConnect(target);
    return connectionManager.transmit(packet, connection);
  }