use of com.hazelcast.spi.impl.InternalCompletableFuture in project hazelcast by hazelcast.
the class InvocationFuture_IsDoneTest method whenNullResponse.
@Test
public void whenNullResponse() throws ExecutionException, InterruptedException {
DummyOperation op = new DummyOperation(null);
InternalCompletableFuture future = operationService.invokeOnTarget(null, op, getAddress(local));
future.get();
assertTrue(future.isDone());
}
use of com.hazelcast.spi.impl.InternalCompletableFuture in project hazelcast by hazelcast.
the class InvocationFuture_CancelTest method whenCallCancel_thenCancelled.
@Test
public void whenCallCancel_thenCancelled() {
// Given
InternalCompletableFuture future = invoke();
// When
boolean result = future.cancel(true);
// Then
assertTrue(result);
assertTrue(future.isCancelled());
assertTrue(future.isDone());
}
use of com.hazelcast.spi.impl.InternalCompletableFuture in project hazelcast by hazelcast.
the class Invocation_OffloadedTest method whenStartThrowsException_thenExceptionPropagated.
@Test(expected = ExpectedRuntimeException.class)
public void whenStartThrowsException_thenExceptionPropagated() {
InternalCompletableFuture f = localOperationService.invokeOnPartition(new OffloadingOperation(op -> new Offload(op) {
@Override
public void start() {
throw new ExpectedRuntimeException();
}
}));
assertCompletesEventually(f);
f.joinInternal();
}
use of com.hazelcast.spi.impl.InternalCompletableFuture in project hazelcast by hazelcast.
the class Invocation_ExceptionTest method test.
@Test
public void test() throws Exception {
HazelcastInstance local = createHazelcastInstance();
OperationService operationService = getOperationService(local);
InternalCompletableFuture f = operationService.invokeOnPartition(null, new OperationsReturnsNoResponse(exception), 0);
assertCompletesEventually(f);
expected.expect(expectedExceptionClass);
expected.expectCause(exceptionCauseMatcher);
waitForFuture(f, futureSyncMethod);
}
use of com.hazelcast.spi.impl.InternalCompletableFuture in project hazelcast by hazelcast.
the class Invocation_NestedLocalTest method invokeOnPartition_outerLocal_innerSameInstance_callsDifferentPartition_mappedToSameThread.
@Test
public void invokeOnPartition_outerLocal_innerSameInstance_callsDifferentPartition_mappedToSameThread() {
Config config = new Config();
config.setProperty(ClusterProperty.PARTITION_COUNT.getName(), "2");
config.setProperty(ClusterProperty.PARTITION_OPERATION_THREAD_COUNT.getName(), "1");
HazelcastInstance local = createHazelcastInstance(config);
final OperationService operationService = getOperationService(local);
int outerPartitionId = 1;
int innerPartitionId = 0;
InnerOperation innerOperation = new InnerOperation(RESPONSE, innerPartitionId);
OuterOperation outerOperation = new OuterOperation(innerOperation, outerPartitionId);
InternalCompletableFuture future = operationService.invokeOnPartition(null, outerOperation, outerOperation.getPartitionId());
expected.expect(IllegalThreadStateException.class);
expected.expectMessage("cannot make remote call");
future.joinInternal();
}
Aggregations