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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
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; }
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); } }
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(); } }