use of com.hazelcast.spi.impl.NodeEngine in project hazelcast by hazelcast.
the class ApplyOp method callFunction.
private Data callFunction(Data currentData) {
NodeEngine nodeEngine = getNodeEngine();
IFunction func = nodeEngine.toObject(function);
Object input = nodeEngine.toObject(currentData);
// noinspection unchecked
Object output = func.apply(input);
return nodeEngine.toData(output);
}
use of com.hazelcast.spi.impl.NodeEngine in project hazelcast by hazelcast.
the class ExecutorServiceProxy method submitToMember.
private <T> void submitToMember(@Nonnull Data taskData, @Nonnull Member member, @Nullable ExecutionCallback<T> callback) {
checkNotNull(member, "member must not be null");
checkNotShutdown();
NodeEngine nodeEngine = getNodeEngine();
UUID uuid = newUnsecureUUID();
MemberCallableTaskOperation op = new MemberCallableTaskOperation(name, uuid, taskData);
OperationService operationService = nodeEngine.getOperationService();
Address address = member.getAddress();
InvocationFuture<T> future = operationService.createInvocationBuilder(DistributedExecutorService.SERVICE_NAME, op, address).invoke();
if (callback != null) {
future.whenCompleteAsync(new ExecutionCallbackAdapter<>(callback)).whenCompleteAsync((v, t) -> {
if (t instanceof RejectedExecutionException) {
callback.onFailure(t);
}
});
}
}
use of com.hazelcast.spi.impl.NodeEngine in project hazelcast by hazelcast.
the class ExecutorServiceProxy method submitToKeyOwner.
@Override
public <T> void submitToKeyOwner(@Nonnull Callable<T> task, @Nonnull Object key, @Nullable ExecutionCallback<T> callback) {
checkNotNull(key, "key must not be null");
checkNotNull(task, "task must not be null");
NodeEngine nodeEngine = getNodeEngine();
submitToPartitionOwner(task, callback, nodeEngine.getPartitionService().getPartitionId(key));
}
use of com.hazelcast.spi.impl.NodeEngine in project hazelcast by hazelcast.
the class ExecutorServiceProxy method submitToKeyOwner.
@Override
public <T> Future<T> submitToKeyOwner(@Nonnull Callable<T> task, @Nonnull Object key) {
checkNotNull(key, "key must not be null");
NodeEngine nodeEngine = getNodeEngine();
return submitToPartitionOwner(task, nodeEngine.getPartitionService().getPartitionId(key));
}
use of com.hazelcast.spi.impl.NodeEngine in project hazelcast by hazelcast.
the class DurableExecutorServiceProxy method shutdown.
@Override
public void shutdown() {
NodeEngine nodeEngine = getNodeEngine();
Collection<Member> members = nodeEngine.getClusterService().getMembers();
OperationService operationService = nodeEngine.getOperationService();
Collection<Future> calls = new LinkedList<>();
for (Member member : members) {
ShutdownOperation op = new ShutdownOperation(name);
Future f = operationService.invokeOnTarget(SERVICE_NAME, op, member.getAddress());
calls.add(f);
}
waitWithDeadline(calls, 3, TimeUnit.SECONDS, shutdownExceptionHandler);
}
Aggregations