@Override
 public InternalCompletableFuture<Boolean> asyncCompareAndSet(E expect, E update) {
   NodeEngine nodeEngine = getNodeEngine();
   Operation operation =
       new CompareAndSetOperation(name, nodeEngine.toData(expect), nodeEngine.toData(update));
   return asyncInvoke(operation, nodeEngine);
 }
  @Override
  public InternalCompletableFuture<E> asyncGetAndAlter(IFunction<E, E> function) {
    isNotNull(function, "function");

    NodeEngine nodeEngine = getNodeEngine();
    Operation operation = new GetAndAlterOperation(name, nodeEngine.toData(function));
    return asyncInvoke(operation, nodeEngine);
  }
  @Override
  public <R> InternalCompletableFuture<R> asyncApply(IFunction<E, R> function) {
    isNotNull(function, "function");

    NodeEngine nodeEngine = getNodeEngine();
    Operation operation = new ApplyOperation(name, nodeEngine.toData(function));
    return asyncInvoke(operation, nodeEngine);
  }
 public EntrySetResponse(Map<Data, Collection<MultiMapRecord>> map, NodeEngine nodeEngine) {
   this.map = new HashMap<Data, Collection<Data>>(map.size());
   for (Map.Entry<Data, Collection<MultiMapRecord>> entry : map.entrySet()) {
     Collection<MultiMapRecord> records = entry.getValue();
     Collection<Data> coll = new ArrayList<Data>(records.size());
     for (MultiMapRecord record : records) {
       coll.add(nodeEngine.toData(record.getObject()));
     }
     this.map.put(entry.getKey(), coll);
   }
 }
 public boolean addAll(Collection<? extends E> c) {
   throwExceptionIfNull(c);
   List<Data> valueList = new ArrayList<Data>(c.size());
   final NodeEngine nodeEngine = getNodeEngine();
   for (E e : c) {
     throwExceptionIfNull(e);
     valueList.add(nodeEngine.toData(e));
   }
   final CollectionAddAllOperation operation = new CollectionAddAllOperation(name, valueList);
   final Boolean result = invoke(operation);
   return result;
 }
 public boolean containsAll(Collection<?> c) {
   throwExceptionIfNull(c);
   Set<Data> valueSet = new HashSet<Data>(c.size());
   final NodeEngine nodeEngine = getNodeEngine();
   for (Object o : c) {
     throwExceptionIfNull(o);
     valueSet.add(nodeEngine.toData(o));
   }
   final CollectionContainsOperation operation = new CollectionContainsOperation(name, valueSet);
   final Boolean result = invoke(operation);
   return result;
 }
 private void clearRemoteTransactions(Xid xid) {
   NodeEngine nodeEngine = getNodeEngine();
   InternalPartitionService partitionService = nodeEngine.getPartitionService();
   OperationService operationService = nodeEngine.getOperationService();
   SerializableXID serializableXID =
       new SerializableXID(
           xid.getFormatId(), xid.getGlobalTransactionId(), xid.getBranchQualifier());
   Data xidData = nodeEngine.toData(serializableXID);
   int partitionId = partitionService.getPartitionId(xidData);
   ClearRemoteTransactionOperation operation = new ClearRemoteTransactionOperation(xidData);
   operationService.invokeOnPartition(SERVICE_NAME, operation, partitionId);
 }
 private boolean compareAndRemove(boolean retain, Collection<?> c) {
   throwExceptionIfNull(c);
   Set<Data> valueSet = new HashSet<Data>(c.size());
   final NodeEngine nodeEngine = getNodeEngine();
   for (Object o : c) {
     throwExceptionIfNull(o);
     valueSet.add(nodeEngine.toData(o));
   }
   final CollectionCompareAndRemoveOperation operation =
       new CollectionCompareAndRemoveOperation(name, retain, valueSet);
   final Boolean result = invoke(operation);
   return result;
 }
  @Override
  public void process(
      EntryTaskScheduler<String, Void> scheduler,
      Collection<ScheduledEntry<String, Void>> entries) {
    if (entries.isEmpty()) {
      return;
    }

    InternalPartitionService partitionService = nodeEngine.getPartitionService();
    OperationService operationService = nodeEngine.getOperationService();

    for (ScheduledEntry<String, Void> entry : entries) {
      String name = entry.getKey();
      int partitionId = partitionService.getPartitionId(nodeEngine.toData(name));
      CheckAndEvictOperation op = new CheckAndEvictOperation(entry.getKey());
      operationService.invokeOnPartition(QueueService.SERVICE_NAME, op, partitionId).getSafely();
    }
  }
 public void process(
     EntryTaskScheduler<String, Void> scheduler,
     Collection<ScheduledEntry<String, Void>> entries) {
   if (entries.isEmpty()) {
     return;
   }
   for (ScheduledEntry<String, Void> entry : entries) {
     String name = entry.getKey();
     int partitionId = nodeEngine.getPartitionService().getPartitionId(nodeEngine.toData(name));
     final Invocation inv =
         nodeEngine
             .getOperationService()
             .createInvocationBuilder(
                 QueueService.SERVICE_NAME,
                 new CheckAndEvictOperation(entry.getKey()),
                 partitionId)
             .build();
     inv.invoke();
   }
 }
Exemple #11
0
 private void finalizeTransactionRemotely(Xid xid, boolean isCommit) throws XAException {
   NodeEngine nodeEngine = getNodeEngine();
   InternalPartitionService partitionService = nodeEngine.getPartitionService();
   OperationService operationService = nodeEngine.getOperationService();
   SerializableXID serializableXID =
       new SerializableXID(
           xid.getFormatId(), xid.getGlobalTransactionId(), xid.getBranchQualifier());
   Data xidData = nodeEngine.toData(serializableXID);
   int partitionId = partitionService.getPartitionId(xidData);
   FinalizeRemoteTransactionOperation operation =
       new FinalizeRemoteTransactionOperation(xidData, isCommit);
   InternalCompletableFuture<Integer> future =
       operationService.invokeOnPartition(SERVICE_NAME, operation, partitionId);
   Integer errorCode;
   try {
     errorCode = future.get();
   } catch (Exception e) {
     throw ExceptionUtil.rethrow(e);
   }
   if (errorCode != null) {
     throw new XAException(errorCode);
   }
 }
 @Override
 public InternalCompletableFuture<E> asyncSetAndGet(E update) {
   NodeEngine nodeEngine = getNodeEngine();
   Operation operation = new SetAndGetOperation(name, nodeEngine.toData(update));
   return asyncInvoke(operation, nodeEngine);
 }
 @Override
 public InternalCompletableFuture<Void> asyncSet(E newValue) {
   NodeEngine nodeEngine = getNodeEngine();
   Operation operation = new SetOperation(name, nodeEngine.toData(newValue));
   return asyncInvoke(operation, nodeEngine);
 }
 @Override
 public InternalCompletableFuture<Boolean> asyncContains(E value) {
   NodeEngine nodeEngine = getNodeEngine();
   Operation operation = new ContainsOperation(name, nodeEngine.toData(value));
   return asyncInvoke(operation, nodeEngine);
 }