コード例 #1
0
ファイル: AtomicLongProxy.java プロジェクト: qhfu/hazelcast
 public void set(long newValue) {
   try {
     SetOperation operation = new SetOperation(name, newValue);
     Invocation inv =
         getNodeEngine()
             .getOperationService()
             .createInvocationBuilder(AtomicLongService.SERVICE_NAME, operation, partitionId)
             .build();
     inv.invoke().get();
   } catch (Throwable throwable) {
     throw ExceptionUtil.rethrow(throwable);
   }
 }
コード例 #2
0
 private Object invokeData(QueueOperation operation) {
   final NodeEngine nodeEngine = getNodeEngine();
   try {
     Invocation inv =
         nodeEngine
             .getOperationService()
             .createInvocationBuilder(QueueService.SERVICE_NAME, operation, getPartitionId())
             .build();
     Future f = inv.invoke();
     return f.get();
   } catch (Throwable throwable) {
     throw ExceptionUtil.rethrow(throwable);
   }
 }
コード例 #3
0
 protected <T> T invoke(CollectionOperation operation) {
   final NodeEngine nodeEngine = getNodeEngine();
   try {
     Invocation inv =
         nodeEngine
             .getOperationService()
             .createInvocationBuilder(getServiceName(), operation, partitionId)
             .build();
     Future f = inv.invoke();
     return nodeEngine.toObject(f.get());
   } catch (Throwable throwable) {
     throw ExceptionUtil.rethrow(throwable);
   }
 }
コード例 #4
0
ファイル: AtomicLongProxy.java プロジェクト: qhfu/hazelcast
 public boolean compareAndSet(long expect, long update) {
   try {
     CompareAndSetOperation operation = new CompareAndSetOperation(name, expect, update);
     Invocation inv =
         getNodeEngine()
             .getOperationService()
             .createInvocationBuilder(AtomicLongService.SERVICE_NAME, operation, partitionId)
             .build();
     Future f = inv.invoke();
     return (Boolean) f.get();
   } catch (Throwable throwable) {
     throw ExceptionUtil.rethrow(throwable);
   }
 }
コード例 #5
0
ファイル: AtomicLongProxy.java プロジェクト: qhfu/hazelcast
 public long addAndGet(long delta) {
   try {
     AddAndGetOperation operation = new AddAndGetOperation(name, delta);
     Invocation inv =
         getNodeEngine()
             .getOperationService()
             .createInvocationBuilder(AtomicLongService.SERVICE_NAME, operation, partitionId)
             .build();
     Future f = inv.invoke();
     return (Long) f.get();
   } catch (Throwable throwable) {
     throw ExceptionUtil.rethrow(throwable);
   }
 }
コード例 #6
0
 private Object invokeData(CollectionOperation operation, Data dataKey) {
   final NodeEngine nodeEngine = getNodeEngine();
   try {
     int partitionId = nodeEngine.getPartitionService().getPartitionId(dataKey);
     Invocation inv =
         nodeEngine
             .getOperationService()
             .createInvocationBuilder(CollectionService.SERVICE_NAME, operation, partitionId)
             .build();
     Future f = inv.invoke();
     return nodeEngine.toObject(f.get());
   } catch (Throwable throwable) {
     throw ExceptionUtil.rethrow(throwable);
   }
 }
コード例 #7
0
 Object pollInternal(long timeout) throws InterruptedException {
   PollOperation operation = new PollOperation(name, timeout);
   final NodeEngine nodeEngine = getNodeEngine();
   try {
     Invocation inv =
         nodeEngine
             .getOperationService()
             .createInvocationBuilder(QueueService.SERVICE_NAME, operation, getPartitionId())
             .build();
     Future f = inv.invoke();
     return f.get();
   } catch (Throwable throwable) {
     throw ExceptionUtil.rethrowAllowInterrupted(throwable);
   }
 }
コード例 #8
0
ファイル: MapProxyImpl.java プロジェクト: nscavell/hazelcast
 protected Object invoke(Operation operation, int partitionId) throws Throwable {
   NodeEngine nodeEngine = getNodeEngine();
   Invocation invocation =
       nodeEngine
           .getOperationService()
           .createInvocationBuilder(SERVICE_NAME, operation, partitionId)
           .build();
   Future f = invocation.invoke();
   Object response = f.get();
   Object returnObj = getService().toObject(response);
   if (returnObj instanceof Throwable) {
     throw (Throwable) returnObj;
   }
   return returnObj;
 }
コード例 #9
0
 boolean offerInternal(Data data, long timeout) throws InterruptedException {
   throwExceptionIfNull(data);
   OfferOperation operation = new OfferOperation(name, timeout, data);
   final NodeEngine nodeEngine = getNodeEngine();
   try {
     Invocation inv =
         nodeEngine
             .getOperationService()
             .createInvocationBuilder(QueueService.SERVICE_NAME, operation, getPartitionId())
             .build();
     Future f = inv.invoke();
     return (Boolean) nodeEngine.toObject(f.get());
   } catch (Throwable throwable) {
     throw ExceptionUtil.rethrowAllowInterrupted(throwable);
   }
 }
コード例 #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
 private <T> T invoke(Operation operation, Data dataKey) {
   final NodeEngine nodeEngine = getNodeEngine();
   try {
     int partitionId = nodeEngine.getPartitionService().getPartitionId(dataKey);
     Invocation invocation =
         nodeEngine
             .getOperationService()
             .createInvocationBuilder(CollectionService.SERVICE_NAME, operation, partitionId)
             .build();
     Future f;
     Object o;
     if (config.isStatisticsEnabled()) {
       long time = System.currentTimeMillis();
       f = invocation.invoke();
       o = f.get();
       if (operation instanceof PutOperation) {
         getService()
             .getLocalMultiMapStatsImpl(proxyId)
             .incrementPuts(System.currentTimeMillis() - time);
       } else if (operation instanceof RemoveOperation
           || operation instanceof RemoveAllOperation) {
         getService()
             .getLocalMultiMapStatsImpl(proxyId)
             .incrementRemoves(System.currentTimeMillis() - time);
       } else if (operation instanceof GetAllOperation) {
         getService()
             .getLocalMultiMapStatsImpl(proxyId)
             .incrementGets(System.currentTimeMillis() - time);
       }
     } else {
       f = invocation.invoke();
       o = f.get();
     }
     return (T) nodeEngine.toObject(o);
   } catch (Throwable throwable) {
     throw ExceptionUtil.rethrow(throwable);
   }
 }