use of com.hazelcast.durableexecutor.impl.operations.TaskOperation in project hazelcast by hazelcast.
the class DurableExecutorSubmitToPartitionMessageTask 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);
}
return new TaskOperation(parameters.name, callableData);
}
use of com.hazelcast.durableexecutor.impl.operations.TaskOperation in project hazelcast by hazelcast.
the class DurableExecutorServiceProxy method submitToPartition.
private <T> DurableExecutorServiceFuture<T> submitToPartition(@Nonnull Callable<T> task, int partitionId, T defaultValue) {
checkNotNull(task, "task can't be null");
SerializationService serializationService = getNodeEngine().getSerializationService();
Data taskData = serializationService.toData(task);
TaskOperation operation = new TaskOperation(name, taskData);
operation.setPartitionId(partitionId);
InternalCompletableFuture<Integer> future = invokeOnPartition(operation);
int sequence;
try {
sequence = future.join();
} catch (CompletionException t) {
InternalCompletableFuture<T> completedFuture = completedExceptionally(t.getCause());
return new DurableExecutorServiceDelegateFuture<T>(completedFuture, serializationService, null, -1);
} catch (CancellationException e) {
return new DurableExecutorServiceDelegateFuture<>(future, serializationService, null, -1);
}
Operation op = new RetrieveResultOperation(name, sequence).setPartitionId(partitionId);
InternalCompletableFuture<T> internalCompletableFuture = invokeOnPartition(op);
long taskId = Bits.combineToLong(partitionId, sequence);
return new DurableExecutorServiceDelegateFuture<>(internalCompletableFuture, serializationService, defaultValue, taskId);
}
Aggregations