Search in sources :

Example 26 with InternalCompletableFuture

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());
}
Also used : InternalCompletableFuture(com.hazelcast.spi.impl.InternalCompletableFuture) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 27 with InternalCompletableFuture

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());
}
Also used : InternalCompletableFuture(com.hazelcast.spi.impl.InternalCompletableFuture) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 28 with InternalCompletableFuture

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();
}
Also used : Config(com.hazelcast.config.Config) HazelcastInstance(com.hazelcast.core.HazelcastInstance) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) Accessors.getOperationService(com.hazelcast.test.Accessors.getOperationService) Offload(com.hazelcast.spi.impl.operationservice.Offload) CallStatus(com.hazelcast.spi.impl.operationservice.CallStatus) QuickTest(com.hazelcast.test.annotation.QuickTest) HazelcastTestSupport(com.hazelcast.test.HazelcastTestSupport) RunWith(org.junit.runner.RunWith) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Category(org.junit.experimental.categories.Category) ClusterProperty(com.hazelcast.spi.properties.ClusterProperty) InternalCompletableFuture(com.hazelcast.spi.impl.InternalCompletableFuture) ExpectedRuntimeException(com.hazelcast.test.ExpectedRuntimeException) Operation(com.hazelcast.spi.impl.operationservice.Operation) Assert.assertFalse(org.junit.Assert.assertFalse) HazelcastParallelClassRunner(com.hazelcast.test.HazelcastParallelClassRunner) Assert.assertEquals(org.junit.Assert.assertEquals) Before(org.junit.Before) ExpectedRuntimeException(com.hazelcast.test.ExpectedRuntimeException) InternalCompletableFuture(com.hazelcast.spi.impl.InternalCompletableFuture) Offload(com.hazelcast.spi.impl.operationservice.Offload) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 29 with InternalCompletableFuture

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);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) InternalCompletableFuture(com.hazelcast.spi.impl.InternalCompletableFuture) Accessors.getOperationService(com.hazelcast.test.Accessors.getOperationService) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 30 with InternalCompletableFuture

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();
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) InternalCompletableFuture(com.hazelcast.spi.impl.InternalCompletableFuture) Accessors.getOperationService(com.hazelcast.test.Accessors.getOperationService) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

InternalCompletableFuture (com.hazelcast.spi.impl.InternalCompletableFuture)90 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)47 QuickTest (com.hazelcast.test.annotation.QuickTest)47 Test (org.junit.Test)47 OperationService (com.hazelcast.spi.impl.operationservice.OperationService)19 HazelcastInstance (com.hazelcast.core.HazelcastInstance)17 Accessors.getOperationService (com.hazelcast.test.Accessors.getOperationService)15 Data (com.hazelcast.internal.serialization.Data)10 ArrayList (java.util.ArrayList)10 Map (java.util.Map)10 Operation (com.hazelcast.spi.impl.operationservice.Operation)9 UUID (java.util.UUID)9 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)8 Member (com.hazelcast.cluster.Member)7 ApplyRaftRunnable (com.hazelcast.cp.internal.raft.impl.dataservice.ApplyRaftRunnable)7 Future (java.util.concurrent.Future)7 Address (com.hazelcast.cluster.Address)6 List (java.util.List)6 BiConsumer (java.util.function.BiConsumer)6 Nonnull (javax.annotation.Nonnull)6