use of com.hazelcast.executor.impl.operations.MemberCallableTaskOperation 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.executor.impl.operations.MemberCallableTaskOperation in project hazelcast by hazelcast.
the class ExecutorServiceSubmitToAddressMessageTask method prepareOperation.
@Override
protected Operation prepareOperation() {
SecurityContext securityContext = clientEngine.getSecurityContext();
Data callableData = parameters.callable;
if (securityContext != null) {
Subject subject = endpoint.getSubject();
Object taskObject = serializationService.toObject(parameters.callable);
Callable callable;
if (taskObject instanceof Runnable) {
callable = securityContext.createSecureCallable(subject, (Runnable) taskObject);
} else {
callable = securityContext.createSecureCallable(subject, (Callable<? extends Object>) taskObject);
}
callableData = serializationService.toData(callable);
}
MemberCallableTaskOperation op = new MemberCallableTaskOperation(parameters.name, parameters.uuid, callableData);
op.setCallerUuid(endpoint.getUuid());
return op;
}
use of com.hazelcast.executor.impl.operations.MemberCallableTaskOperation in project hazelcast by hazelcast.
the class ExecutorServiceProxy method submitToMember.
private <T> Future<T> submitToMember(@Nonnull Data taskData, @Nonnull Member member) {
NodeEngine nodeEngine = getNodeEngine();
UUID uuid = newUnsecureUUID();
Address target = member.getAddress();
MemberCallableTaskOperation op = new MemberCallableTaskOperation(name, uuid, taskData);
InternalCompletableFuture future = nodeEngine.getOperationService().invokeOnTarget(DistributedExecutorService.SERVICE_NAME, op, target);
return new CancellableDelegatingFuture<>(future, nodeEngine, uuid, target);
}
Aggregations