Search in sources :

Example 1 with MemberCallableTaskOperation

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);
            }
        });
    }
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) Address(com.hazelcast.cluster.Address) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) UuidUtil.newUnsecureUUID(com.hazelcast.internal.util.UuidUtil.newUnsecureUUID) UUID(java.util.UUID) MemberCallableTaskOperation(com.hazelcast.executor.impl.operations.MemberCallableTaskOperation) RejectedExecutionException(java.util.concurrent.RejectedExecutionException)

Example 2 with MemberCallableTaskOperation

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;
}
Also used : SecurityContext(com.hazelcast.security.SecurityContext) Data(com.hazelcast.internal.serialization.Data) MemberCallableTaskOperation(com.hazelcast.executor.impl.operations.MemberCallableTaskOperation) Subject(javax.security.auth.Subject) Callable(java.util.concurrent.Callable)

Example 3 with MemberCallableTaskOperation

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);
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) Address(com.hazelcast.cluster.Address) InternalCompletableFuture(com.hazelcast.spi.impl.InternalCompletableFuture) UuidUtil.newUnsecureUUID(com.hazelcast.internal.util.UuidUtil.newUnsecureUUID) UUID(java.util.UUID) MemberCallableTaskOperation(com.hazelcast.executor.impl.operations.MemberCallableTaskOperation)

Aggregations

MemberCallableTaskOperation (com.hazelcast.executor.impl.operations.MemberCallableTaskOperation)3 Address (com.hazelcast.cluster.Address)2 UuidUtil.newUnsecureUUID (com.hazelcast.internal.util.UuidUtil.newUnsecureUUID)2 NodeEngine (com.hazelcast.spi.impl.NodeEngine)2 UUID (java.util.UUID)2 Data (com.hazelcast.internal.serialization.Data)1 SecurityContext (com.hazelcast.security.SecurityContext)1 InternalCompletableFuture (com.hazelcast.spi.impl.InternalCompletableFuture)1 OperationService (com.hazelcast.spi.impl.operationservice.OperationService)1 Callable (java.util.concurrent.Callable)1 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1 Subject (javax.security.auth.Subject)1