Пример #1
0
 protected ICompletableFuture<Data> setAsyncInternal(
     Data key, Data value, long ttl, TimeUnit timeunit) {
   int partitionId = getNodeEngine().getPartitionService().getPartitionId(key);
   MapOperation operation =
       operationProvider.createSetOperation(name, key, value, getTimeInMillis(ttl, timeunit));
   operation.setThreadId(ThreadUtil.getThreadId());
   try {
     return operationService.invokeOnPartition(SERVICE_NAME, operation, partitionId);
   } catch (Throwable t) {
     throw rethrow(t);
   }
 }
Пример #2
0
 protected Object getInternal(Data key) {
   // todo action for read-backup true is not well tested.
   if (getMapConfig().isReadBackupData()) {
     Object fromBackup = readBackupDataOrNull(key);
     if (fromBackup != null) {
       return fromBackup;
     }
   }
   MapOperation operation = operationProvider.createGetOperation(name, key);
   operation.setThreadId(ThreadUtil.getThreadId());
   return invokeOperation(key, operation);
 }
Пример #3
0
 protected EntryView getEntryViewInternal(Data key) {
   int partitionId = partitionService.getPartitionId(key);
   MapOperation operation = operationProvider.createGetEntryViewOperation(name, key);
   operation.setThreadId(ThreadUtil.getThreadId());
   operation.setServiceName(SERVICE_NAME);
   try {
     Future future = operationService.invokeOnPartition(SERVICE_NAME, operation, partitionId);
     return (EntryView) toObject(future.get());
   } catch (Throwable t) {
     throw rethrow(t);
   }
 }
Пример #4
0
 protected boolean containsKeyInternal(Data key) {
   int partitionId = partitionService.getPartitionId(key);
   MapOperation containsKeyOperation = operationProvider.createContainsKeyOperation(name, key);
   containsKeyOperation.setThreadId(ThreadUtil.getThreadId());
   containsKeyOperation.setServiceName(SERVICE_NAME);
   try {
     Future future =
         operationService.invokeOnPartition(SERVICE_NAME, containsKeyOperation, partitionId);
     return (Boolean) toObject(future.get());
   } catch (Throwable t) {
     throw rethrow(t);
   }
 }
Пример #5
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);
   }
 }
Пример #6
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);
   }
 }
Пример #7
0
  protected ICompletableFuture<Data> removeAsyncInternal(Data key) {
    int partitionId = getNodeEngine().getPartitionService().getPartitionId(key);
    MapOperation operation = operationProvider.createRemoveOperation(name, key, false);
    operation.setThreadId(ThreadUtil.getThreadId());
    try {
      long startTime = System.currentTimeMillis();
      InternalCompletableFuture<Data> future =
          operationService.invokeOnPartition(SERVICE_NAME, operation, partitionId);

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

      return future;
    } catch (Throwable t) {
      throw rethrow(t);
    }
  }
Пример #8
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);
   }
 }
 @Override
 protected void readInternal(ObjectDataInput in) throws IOException {
   super.readInternal(in);
   predicate = in.readObject();
   iterationType = IterationType.getById(in.readByte());
 }
 @Override
 protected void writeInternal(ObjectDataOutput out) throws IOException {
   super.writeInternal(out);
   out.writeObject(predicate);
   out.writeByte(iterationType.getId());
 }