Exemplo n.º 1
0
 private Object invokeOperation(Data key, MapOperation operation) {
   int partitionId = getNodeEngine().getPartitionService().getPartitionId(key);
   operation.setThreadId(ThreadUtil.getThreadId());
   try {
     Object result;
     if (statisticsEnabled) {
       long time = System.currentTimeMillis();
       Future future =
           operationService
               .createInvocationBuilder(SERVICE_NAME, operation, partitionId)
               .setResultDeserialized(false)
               .invoke();
       result = future.get();
       mapServiceContext.incrementOperationStats(time, localMapStats, name, operation);
     } else {
       Future future =
           operationService
               .createInvocationBuilder(SERVICE_NAME, operation, partitionId)
               .setResultDeserialized(false)
               .invoke();
       result = future.get();
     }
     return result;
   } catch (Throwable t) {
     throw rethrow(t);
   }
 }
Exemplo n.º 2
0
 protected void replicateClearOperation() {
   final OperationService operationService = getNodeEngine().getOperationService();
   Collection<Address> members = getMemberAddresses();
   for (Address address : members) {
     ClearOperation clearOperation = new ClearOperation(mapName, false);
     clearOperation.setPartitionId(getPartitionId());
     clearOperation.setValidateTarget(false);
     operationService
         .createInvocationBuilder(getServiceName(), clearOperation, address)
         .setTryCount(INVOCATION_TRY_COUNT)
         .invoke();
   }
 }
Exemplo n.º 3
0
 public Data executeOnKeyInternal(Data key, EntryProcessor entryProcessor) {
   int partitionId = partitionService.getPartitionId(key);
   MapOperation operation = operationProvider.createEntryOperation(name, key, entryProcessor);
   operation.setThreadId(ThreadUtil.getThreadId());
   try {
     Future future =
         operationService
             .createInvocationBuilder(SERVICE_NAME, operation, partitionId)
             .setResultDeserialized(false)
             .invoke();
     return (Data) future.get();
   } catch (Throwable t) {
     throw rethrow(t);
   }
 }
Exemplo n.º 4
0
 public ICompletableFuture executeOnKeyInternal(
     Data key, EntryProcessor entryProcessor, ExecutionCallback<Object> callback) {
   int partitionId = partitionService.getPartitionId(key);
   MapOperation operation = operationProvider.createEntryOperation(name, key, entryProcessor);
   operation.setThreadId(ThreadUtil.getThreadId());
   try {
     if (callback == null) {
       return operationService.invokeOnPartition(SERVICE_NAME, operation, partitionId);
     } else {
       return operationService
           .createInvocationBuilder(SERVICE_NAME, operation, partitionId)
           .setExecutionCallback(new MapExecutionCallbackAdapter(callback))
           .invoke();
     }
   } catch (Throwable t) {
     throw rethrow(t);
   }
 }
Exemplo n.º 5
0
  protected ICompletableFuture<Data> getAsyncInternal(Data key) {
    int partitionId = partitionService.getPartitionId(key);

    MapOperation operation = operationProvider.createGetOperation(name, key);
    try {
      long startTime = System.currentTimeMillis();
      InternalCompletableFuture<Data> future =
          operationService
              .createInvocationBuilder(SERVICE_NAME, operation, partitionId)
              .setResultDeserialized(false)
              .invoke();

      if (statisticsEnabled) {
        future.andThen(new IncrementStatsExecutionCallback<Data>(operation, startTime));
      }

      return future;
    } catch (Throwable t) {
      throw rethrow(t);
    }
  }
  private void invokeCheckReplicaVersion(int partitionId, int replicaIndex, Address target) {
    InternalPartitionServiceImpl partitionService = getService();
    long[] currentVersions = partitionService.getPartitionReplicaVersions(partitionId);
    long currentReplicaVersion = currentVersions[replicaIndex - 1];

    if (currentReplicaVersion > 0) {
      CheckReplicaVersion op =
          createCheckReplicaVersion(partitionId, replicaIndex, currentReplicaVersion);
      NodeEngine nodeEngine = getNodeEngine();
      OperationService operationService = nodeEngine.getOperationService();
      if (sync) {
        operationService
            .createInvocationBuilder(InternalPartitionService.SERVICE_NAME, op, target)
            .setExecutionCallback(callback)
            .setTryCount(OPERATION_TRY_COUNT)
            .setTryPauseMillis(OPERATION_TRY_PAUSE_MILLIS)
            .invoke();
      } else {
        operationService.send(op, target);
      }
    } else {
      notifyCallback(true);
    }
  }