Search in sources :

Example 41 with ClientDelegatingFuture

use of com.hazelcast.client.impl.ClientDelegatingFuture in project hazelcast by hazelcast.

the class MCMessageTasksTest method testGetClusterMetadataMessageTask.

@Test
public void testGetClusterMetadataMessageTask() throws Exception {
    ClientInvocation invocation = new ClientInvocation(getClientImpl(), MCGetClusterMetadataCodec.encodeRequest(), null);
    ClientDelegatingFuture<MCGetClusterMetadataCodec.ResponseParameters> future = new ClientDelegatingFuture<>(invocation.invoke(), getClientImpl().getSerializationService(), MCGetClusterMetadataCodec::decodeResponse);
    MCGetClusterMetadataCodec.ResponseParameters response = future.get(ASSERT_TRUE_EVENTUALLY_TIMEOUT, SECONDS);
    assertTrue(response.clusterTime > 0);
    assertEquals(0, response.currentState);
    assertEquals(BuildInfoProvider.getBuildInfo().getVersion(), response.memberVersion);
    assertNull(response.jetVersion);
}
Also used : ClientDelegatingFuture(com.hazelcast.client.impl.ClientDelegatingFuture) ClientInvocation(com.hazelcast.client.impl.spi.impl.ClientInvocation) MCGetClusterMetadataCodec(com.hazelcast.client.impl.protocol.codec.MCGetClusterMetadataCodec) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 42 with ClientDelegatingFuture

use of com.hazelcast.client.impl.ClientDelegatingFuture in project hazelcast by hazelcast.

the class ClientDelegatingFutureTest_CompletionStageTest method newCompletableFuture.

@Override
protected CompletableFuture<Object> newCompletableFuture(boolean exceptional, long completeAfterMillis) {
    invocation.getCallIdSequence().next();
    ClientInvocationFuture cf = invocation.getClientInvocationFuture();
    ClientDelegatingFuture<Object> future = new ClientDelegatingFuture<>(cf, serializationService, MapGetCodec::decodeResponse);
    Executor completionExecutor;
    if (completeAfterMillis <= 0) {
        completionExecutor = CALLER_RUNS;
    } else {
        completionExecutor = command -> new Thread(() -> {
            sleepAtLeastMillis(completeAfterMillis);
            command.run();
        }, "test-completion-thread").start();
    }
    if (exceptional) {
        completionExecutor.execute(() -> invocation.completeExceptionally(new ExpectedRuntimeException()));
    } else {
        completionExecutor.execute(completeNormally(invocation));
    }
    return future;
}
Also used : MapGetCodec(com.hazelcast.client.impl.protocol.codec.MapGetCodec) ClientDelegatingFuture(com.hazelcast.client.impl.ClientDelegatingFuture) ExpectedRuntimeException(com.hazelcast.test.ExpectedRuntimeException) Executor(java.util.concurrent.Executor)

Example 43 with ClientDelegatingFuture

use of com.hazelcast.client.impl.ClientDelegatingFuture in project hazelcast by hazelcast.

the class MCMessageTasksTest method testHotRestartTriggerPartialStartMessageTask.

@Test
public void testHotRestartTriggerPartialStartMessageTask() throws Exception {
    ClientInvocation invocation = new ClientInvocation(getClientImpl(), MCTriggerPartialStartCodec.encodeRequest(), null);
    ClientDelegatingFuture<Boolean> future = new ClientDelegatingFuture<>(invocation.invoke(), getClientImpl().getSerializationService(), MCTriggerPartialStartCodec::decodeResponse);
    assertFalse(future.get(ASSERT_TRUE_EVENTUALLY_TIMEOUT, SECONDS));
}
Also used : ClientDelegatingFuture(com.hazelcast.client.impl.ClientDelegatingFuture) MCTriggerPartialStartCodec(com.hazelcast.client.impl.protocol.codec.MCTriggerPartialStartCodec) ClientInvocation(com.hazelcast.client.impl.spi.impl.ClientInvocation) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 44 with ClientDelegatingFuture

use of com.hazelcast.client.impl.ClientDelegatingFuture in project hazelcast by hazelcast.

the class MCMessageTasksTest method testGetSystemPropertiesMessageTask.

@Test
public void testGetSystemPropertiesMessageTask() throws Exception {
    ClientInvocation invocation = new ClientInvocation(getClientImpl(), MCGetSystemPropertiesCodec.encodeRequest(), null);
    ClientDelegatingFuture<List<Entry<String, String>>> future = new ClientDelegatingFuture<>(invocation.invoke(), getClientImpl().getSerializationService(), MCGetSystemPropertiesCodec::decodeResponse);
    assertFalse(future.get(ASSERT_TRUE_EVENTUALLY_TIMEOUT, SECONDS).isEmpty());
}
Also used : MCGetSystemPropertiesCodec(com.hazelcast.client.impl.protocol.codec.MCGetSystemPropertiesCodec) ClientDelegatingFuture(com.hazelcast.client.impl.ClientDelegatingFuture) ClientInvocation(com.hazelcast.client.impl.spi.impl.ClientInvocation) List(java.util.List) ArrayList(java.util.ArrayList) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 45 with ClientDelegatingFuture

use of com.hazelcast.client.impl.ClientDelegatingFuture in project hazelcast by hazelcast.

the class MCMessageTasksTest method testGetThreadDumpMessageTask.

@Test
public void testGetThreadDumpMessageTask() throws Exception {
    ClientInvocation invocation = new ClientInvocation(getClientImpl(), MCGetThreadDumpCodec.encodeRequest(false), null);
    ClientDelegatingFuture<String> future = new ClientDelegatingFuture<>(invocation.invoke(), getClientImpl().getSerializationService(), MCGetThreadDumpCodec::decodeResponse);
    assertFalse(isNullOrEmptyAfterTrim(future.get(ASSERT_TRUE_EVENTUALLY_TIMEOUT, SECONDS)));
}
Also used : MCGetThreadDumpCodec(com.hazelcast.client.impl.protocol.codec.MCGetThreadDumpCodec) ClientDelegatingFuture(com.hazelcast.client.impl.ClientDelegatingFuture) ClientInvocation(com.hazelcast.client.impl.spi.impl.ClientInvocation) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

ClientDelegatingFuture (com.hazelcast.client.impl.ClientDelegatingFuture)54 ClientInvocation (com.hazelcast.client.impl.spi.impl.ClientInvocation)46 ClientInvocationFuture (com.hazelcast.client.impl.spi.impl.ClientInvocationFuture)32 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)31 Test (org.junit.Test)17 Data (com.hazelcast.internal.serialization.Data)16 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)15 QuickTest (com.hazelcast.test.annotation.QuickTest)15 SerializationService (com.hazelcast.internal.serialization.SerializationService)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 ClientConfig (com.hazelcast.client.config.ClientConfig)3 StaleSequenceException (com.hazelcast.ringbuffer.StaleSequenceException)3 Nonnull (javax.annotation.Nonnull)3 AtomicLongAlterCodec (com.hazelcast.client.impl.protocol.codec.AtomicLongAlterCodec)2 AtomicRefSetCodec (com.hazelcast.client.impl.protocol.codec.AtomicRefSetCodec)2 MapGetCodec (com.hazelcast.client.impl.protocol.codec.MapGetCodec)2 SqlMappingDdlCodec (com.hazelcast.client.impl.protocol.codec.SqlMappingDdlCodec)2 HazelcastInstance (com.hazelcast.core.HazelcastInstance)2 IExecutorService (com.hazelcast.core.IExecutorService)2