コード例 #1
0
 @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);
 }
コード例 #2
0
  @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);
  }
コード例 #3
0
  @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);
  }
コード例 #4
0
 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);
   }
 }
コード例 #5
0
 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;
 }
コード例 #6
0
 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;
 }
コード例 #7
0
ファイル: XAResourceImpl.java プロジェクト: Gramler/hazelcast
 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);
 }
コード例 #8
0
 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;
 }
コード例 #9
0
  @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();
    }
  }
コード例 #10
0
 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();
   }
 }
コード例 #11
0
ファイル: XAResourceImpl.java プロジェクト: Gramler/hazelcast
 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);
   }
 }
コード例 #12
0
 @Override
 public InternalCompletableFuture<E> asyncSetAndGet(E update) {
   NodeEngine nodeEngine = getNodeEngine();
   Operation operation = new SetAndGetOperation(name, nodeEngine.toData(update));
   return asyncInvoke(operation, nodeEngine);
 }
コード例 #13
0
 @Override
 public InternalCompletableFuture<Void> asyncSet(E newValue) {
   NodeEngine nodeEngine = getNodeEngine();
   Operation operation = new SetOperation(name, nodeEngine.toData(newValue));
   return asyncInvoke(operation, nodeEngine);
 }
コード例 #14
0
 @Override
 public InternalCompletableFuture<Boolean> asyncContains(E value) {
   NodeEngine nodeEngine = getNodeEngine();
   Operation operation = new ContainsOperation(name, nodeEngine.toData(value));
   return asyncInvoke(operation, nodeEngine);
 }