Search in sources :

Example 36 with ClientDelegatingFuture

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

the class MCMessageTasksTest method test_sqlMappingDdl_existingMap.

@Test
public void test_sqlMappingDdl_existingMap() throws Exception {
    String name = randomMapName();
    instance().getMap(name).put(1, "value-1");
    ClientInvocation invocation = new ClientInvocation(getClientImpl(), SqlMappingDdlCodec.encodeRequest(name), null);
    ClientDelegatingFuture<String> future = new ClientDelegatingFuture<>(invocation.invoke(), getClientImpl().getSerializationService(), SqlMappingDdlCodec::decodeResponse);
    String response = future.get(ASSERT_TRUE_EVENTUALLY_TIMEOUT, SECONDS);
    assertStartsWith("CREATE MAPPING \"" + name + "\"", response);
}
Also used : ClientDelegatingFuture(com.hazelcast.client.impl.ClientDelegatingFuture) ClientInvocation(com.hazelcast.client.impl.spi.impl.ClientInvocation) SqlMappingDdlCodec(com.hazelcast.client.impl.protocol.codec.SqlMappingDdlCodec) Test(org.junit.Test)

Example 37 with ClientDelegatingFuture

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

the class MCMessageTasksTest method test_sqlMappingDdl_nonExistingMap.

@Test
public void test_sqlMappingDdl_nonExistingMap() throws Exception {
    ClientInvocation invocation = new ClientInvocation(getClientImpl(), SqlMappingDdlCodec.encodeRequest(randomMapName()), null);
    ClientDelegatingFuture<String> future = new ClientDelegatingFuture<>(invocation.invoke(), getClientImpl().getSerializationService(), SqlMappingDdlCodec::decodeResponse);
    String response = future.get(ASSERT_TRUE_EVENTUALLY_TIMEOUT, SECONDS);
    assertNull(response);
}
Also used : ClientDelegatingFuture(com.hazelcast.client.impl.ClientDelegatingFuture) ClientInvocation(com.hazelcast.client.impl.spi.impl.ClientInvocation) SqlMappingDdlCodec(com.hazelcast.client.impl.protocol.codec.SqlMappingDdlCodec) Test(org.junit.Test)

Example 38 with ClientDelegatingFuture

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

the class ClientMaxAllowedInvocationTest method testMaxAllowed_withWaitingCallbacks.

private void testMaxAllowed_withWaitingCallbacks(RegisterCallback registerCallbackCall) throws ExecutionException, InterruptedException {
    int MAX_ALLOWED = 10;
    hazelcastFactory.newHazelcastInstance();
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.setProperty(ClientProperty.MAX_CONCURRENT_INVOCATIONS.getName(), String.valueOf(MAX_ALLOWED));
    HazelcastInstance client = hazelcastFactory.newHazelcastClient(clientConfig);
    String name = randomString();
    IMap map = client.getMap(name);
    IExecutorService executorService = client.getExecutorService(randomString());
    CountDownLatch countDownLatch = new CountDownLatch(1);
    SleepyCallback sleepyCallback = new SleepyCallback(countDownLatch);
    try {
        for (int i = 0; i < MAX_ALLOWED; i++) {
            ClientDelegatingFuture future = (ClientDelegatingFuture) executorService.submit(new SleepyProcessor(0));
            registerCallbackCall.call(future, sleepyCallback);
            future.get();
        }
        map.get(1);
    } finally {
        countDownLatch.countDown();
    }
}
Also used : IMap(com.hazelcast.map.IMap) ClientDelegatingFuture(com.hazelcast.client.impl.ClientDelegatingFuture) HazelcastInstance(com.hazelcast.core.HazelcastInstance) IExecutorService(com.hazelcast.core.IExecutorService) ClientConfig(com.hazelcast.client.config.ClientConfig) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 39 with ClientDelegatingFuture

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

the class ClientMaxAllowedInvocationTest method testMaxAllowed.

private void testMaxAllowed(RegisterCallback registerCallbackCall) throws ExecutionException, InterruptedException {
    int MAX_ALLOWED = 10;
    hazelcastFactory.newHazelcastInstance();
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.setProperty(ClientProperty.MAX_CONCURRENT_INVOCATIONS.getName(), String.valueOf(MAX_ALLOWED));
    HazelcastInstance client = hazelcastFactory.newHazelcastClient(clientConfig);
    String name = randomString();
    IMap map = client.getMap(name);
    CountDownLatch countDownLatch = new CountDownLatch(1);
    SleepyCallback sleepyCallback = new SleepyCallback(countDownLatch);
    try {
        IExecutorService executorService = client.getExecutorService(randomString());
        for (int i = 0; i < MAX_ALLOWED - 1; i++) {
            executorService.submit(new SleepyProcessor(Integer.MAX_VALUE));
        }
        ClientDelegatingFuture future = (ClientDelegatingFuture) executorService.submit(new SleepyProcessor(0));
        registerCallbackCall.call(future, sleepyCallback);
        future.get();
        map.get(1);
    } finally {
        countDownLatch.countDown();
    }
}
Also used : IMap(com.hazelcast.map.IMap) ClientDelegatingFuture(com.hazelcast.client.impl.ClientDelegatingFuture) HazelcastInstance(com.hazelcast.core.HazelcastInstance) IExecutorService(com.hazelcast.core.IExecutorService) ClientConfig(com.hazelcast.client.config.ClientConfig) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 40 with ClientDelegatingFuture

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

the class MCMessageTasksTest method testGetMapConfigMessageTask.

@Test
public void testGetMapConfigMessageTask() throws Exception {
    ClientInvocation invocation = new ClientInvocation(getClientImpl(), MCGetMapConfigCodec.encodeRequest(randomString()), null);
    ClientDelegatingFuture<MCGetMapConfigCodec.ResponseParameters> future = new ClientDelegatingFuture<>(invocation.invoke(), getClientImpl().getSerializationService(), MCGetMapConfigCodec::decodeResponse);
    MCGetMapConfigCodec.ResponseParameters response = future.get(ASSERT_TRUE_EVENTUALLY_TIMEOUT, SECONDS);
    assertFalse(response.readBackupData);
}
Also used : ClientDelegatingFuture(com.hazelcast.client.impl.ClientDelegatingFuture) MCGetMapConfigCodec(com.hazelcast.client.impl.protocol.codec.MCGetMapConfigCodec) 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