private <T> DurableExecutorServiceFuture<T> submitToPartition(Callable<T> task, int partitionId, T result) { checkNotNull(task, "task should not be null"); ClientMessage request = DurableExecutorSubmitToPartitionCodec.encodeRequest(name, toData(task)); int sequence; try { ClientMessage response = invokeOnPartition(request, partitionId); sequence = DurableExecutorSubmitToPartitionCodec.decodeResponse(response).response; } catch (Throwable t) { return new ClientDurableExecutorServiceCompletedFuture<T>(t, getUserExecutor()); } ClientMessage clientMessage = DurableExecutorRetrieveResultCodec.encodeRequest(name, sequence); ClientInvocationFuture future = new ClientInvocation(getClient(), clientMessage, getName(), partitionId).invoke(); long taskId = Bits.combineToLong(partitionId, sequence); return new ClientDurableExecutorServiceDelegatingFuture<T>(future, getSerializationService(), RETRIEVE_RESPONSE_DECODER, result, taskId); }
@Override public void andThen(ExecutionCallback<T> callback) { andThen(callback, executor); }
@Override public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { return get(); } }
private <T> DurableExecutorServiceFuture<T> submitToPartition(Callable<T> task, int partitionId, T result) { checkNotNull(task, "task should not be null"); ClientMessage request = DurableExecutorSubmitToPartitionCodec.encodeRequest(name, toData(task)); int sequence; try { ClientMessage response = invokeOnPartition(request, partitionId); sequence = DurableExecutorSubmitToPartitionCodec.decodeResponse(response).response; } catch (Throwable t) { return new ClientDurableExecutorServiceCompletedFuture<T>(t, getUserExecutor()); } ClientMessage clientMessage = DurableExecutorRetrieveResultCodec.encodeRequest(name, sequence); ClientInvocationFuture future = new ClientInvocation(getClient(), clientMessage, getName(), partitionId).invoke(); long taskId = Bits.combineToLong(partitionId, sequence); return new ClientDurableExecutorServiceDelegatingFuture<T>(future, getSerializationService(), RETRIEVE_RESPONSE_DECODER, result, taskId); }
@Override public void andThen(ExecutionCallback<T> callback) { andThen(callback, executor); }
@Override public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { return get(); } }