Search in sources :

Example 1 with RetrieveResultOperation

use of com.hazelcast.durableexecutor.impl.operations.RetrieveResultOperation in project hazelcast by hazelcast.

the class DurableExecutorServiceProxy method retrieveResult.

@Override
public <T> Future<T> retrieveResult(long uniqueId) {
    int partitionId = Bits.extractInt(uniqueId, false);
    int sequence = Bits.extractInt(uniqueId, true);
    Operation op = new RetrieveResultOperation(name, sequence).setPartitionId(partitionId);
    return invokeOnPartition(op);
}
Also used : RetrieveResultOperation(com.hazelcast.durableexecutor.impl.operations.RetrieveResultOperation) ShutdownOperation(com.hazelcast.durableexecutor.impl.operations.ShutdownOperation) TaskOperation(com.hazelcast.durableexecutor.impl.operations.TaskOperation) Operation(com.hazelcast.spi.Operation) DisposeResultOperation(com.hazelcast.durableexecutor.impl.operations.DisposeResultOperation) RetrieveAndDisposeResultOperation(com.hazelcast.durableexecutor.impl.operations.RetrieveAndDisposeResultOperation) RetrieveResultOperation(com.hazelcast.durableexecutor.impl.operations.RetrieveResultOperation)

Example 2 with RetrieveResultOperation

use of com.hazelcast.durableexecutor.impl.operations.RetrieveResultOperation in project hazelcast by hazelcast.

the class DurableExecutorServiceProxy method submitToPartition.

private <T> DurableExecutorServiceFuture<T> submitToPartition(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.get();
    } catch (Throwable t) {
        CompletedFuture<T> completedFuture = new CompletedFuture<T>(serializationService, t, getAsyncExecutor());
        return new DurableExecutorServiceDelegateFuture<T>(completedFuture, 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<T>(internalCompletableFuture, serializationService, defaultValue, taskId);
}
Also used : SerializationService(com.hazelcast.spi.serialization.SerializationService) Data(com.hazelcast.nio.serialization.Data) TaskOperation(com.hazelcast.durableexecutor.impl.operations.TaskOperation) ShutdownOperation(com.hazelcast.durableexecutor.impl.operations.ShutdownOperation) TaskOperation(com.hazelcast.durableexecutor.impl.operations.TaskOperation) Operation(com.hazelcast.spi.Operation) DisposeResultOperation(com.hazelcast.durableexecutor.impl.operations.DisposeResultOperation) RetrieveAndDisposeResultOperation(com.hazelcast.durableexecutor.impl.operations.RetrieveAndDisposeResultOperation) RetrieveResultOperation(com.hazelcast.durableexecutor.impl.operations.RetrieveResultOperation) RetrieveResultOperation(com.hazelcast.durableexecutor.impl.operations.RetrieveResultOperation) CompletedFuture(com.hazelcast.util.executor.CompletedFuture)

Aggregations

DisposeResultOperation (com.hazelcast.durableexecutor.impl.operations.DisposeResultOperation)2 RetrieveAndDisposeResultOperation (com.hazelcast.durableexecutor.impl.operations.RetrieveAndDisposeResultOperation)2 RetrieveResultOperation (com.hazelcast.durableexecutor.impl.operations.RetrieveResultOperation)2 ShutdownOperation (com.hazelcast.durableexecutor.impl.operations.ShutdownOperation)2 TaskOperation (com.hazelcast.durableexecutor.impl.operations.TaskOperation)2 Operation (com.hazelcast.spi.Operation)2 Data (com.hazelcast.nio.serialization.Data)1 SerializationService (com.hazelcast.spi.serialization.SerializationService)1 CompletedFuture (com.hazelcast.util.executor.CompletedFuture)1