use of com.hazelcast.spi.impl.InternalCompletableFuture 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);
}
use of com.hazelcast.spi.impl.InternalCompletableFuture 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);
}
use of com.hazelcast.spi.impl.InternalCompletableFuture in project hazelcast by hazelcast.
the class InvalidationMetaDataFetcher method init.
// returns true if handler is initialized properly, otherwise false
public final boolean init(RepairingHandler handler) {
MetadataHolder resultHolder = new MetadataHolder();
List<String> dataStructureNames = Collections.singletonList(handler.getName());
Map<Member, InternalCompletableFuture> futureByMember = fetchMembersMetadataFor(dataStructureNames);
for (Map.Entry<Member, InternalCompletableFuture> entry : futureByMember.entrySet()) {
Member member = entry.getKey();
InternalCompletableFuture future = entry.getValue();
try {
extractMemberMetadata(member, future, resultHolder);
} catch (Exception e) {
handleExceptionWhileProcessingMetadata(member, e);
return false;
}
initUuid(resultHolder.partitionUuidList, handler);
initSequence(resultHolder.namePartitionSequenceList, handler);
}
return true;
}
use of com.hazelcast.spi.impl.InternalCompletableFuture in project hazelcast by hazelcast.
the class ChainingFutureTest method testNonTopologyRelatedExceptionArePropagated.
@Test(expected = OperationTimeoutException.class)
public void testNonTopologyRelatedExceptionArePropagated() {
InternalCompletableFuture<Object> future1 = newFuture();
InternalCompletableFuture<Object> future2 = newFuture();
InternalCompletableFuture<Object> future3 = newFuture();
CountingIterator<InternalCompletableFuture<Object>> iterator = toIterator(future1, future2, future3);
ChainingFuture.ExceptionHandler handler = repairingIterator;
ChainingFuture<Object> future = new ChainingFuture<>(iterator, handler);
assertEquals(1, iterator.getHasNextCounter());
assertEquals(1, iterator.getNextCounter());
assertFalse(future.isDone());
future1.completeExceptionally(new OperationTimeoutException());
assertTrue(future.isDone());
future.joinInternal();
}
use of com.hazelcast.spi.impl.InternalCompletableFuture in project hazelcast by hazelcast.
the class ChainingFutureTest method testIteratingExceptionArePropagated.
@Test(expected = HazelcastException.class)
public void testIteratingExceptionArePropagated() {
InternalCompletableFuture<Object> future1 = newFuture();
InternalCompletableFuture<Object> future2 = newFuture();
InternalCompletableFuture<Object> future3 = newFuture();
CountingIterator<InternalCompletableFuture<Object>> iterator = toIterator(future1, future2, future3);
ChainingFuture.ExceptionHandler handler = repairingIterator;
ChainingFuture<Object> future = new ChainingFuture<>(iterator, handler);
assertEquals(1, iterator.getHasNextCounter());
assertEquals(1, iterator.getNextCounter());
assertFalse(future.isDone());
iterator.exceptionToThrow = new HazelcastException("iterating exception");
future1.complete("foo");
assertTrue(future.isDone());
future.joinInternal();
}
Aggregations