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);
}
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);
}
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();
}
}
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();
}
}
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);
}
Aggregations