use of com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl in project hazelcast by hazelcast.
the class ClientInvocationTest method invokeOnPartitionOwnerRedirectsToRandom_WhenPartitionOwnerIsnull.
@Test
public void invokeOnPartitionOwnerRedirectsToRandom_WhenPartitionOwnerIsnull() throws Exception {
hazelcastFactory.newHazelcastInstance();
HazelcastClientInstanceImpl client = getHazelcastClientInstanceImpl(hazelcastFactory.newHazelcastClient());
ClientMessage request = MapSizeCodec.encodeRequest("test");
int ownerlessPartition = 4000;
ClientInvocation invocation = new ClientInvocation(client, request, "map", ownerlessPartition);
assertEquals(0, MapSizeCodec.decodeResponse(invocation.invoke().get()));
}
use of com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl in project hazelcast by hazelcast.
the class ListenerLeakTest method getClientEventRegistrations.
private Collection<ClientConnectionRegistration> getClientEventRegistrations(HazelcastInstance client, UUID id) {
HazelcastClientInstanceImpl clientImpl = ClientTestUtil.getHazelcastClientInstanceImpl(client);
ClientListenerServiceImpl listenerService = (ClientListenerServiceImpl) clientImpl.getListenerService();
return listenerService.getActiveRegistrations(id).values();
}
use of com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl in project hazelcast by hazelcast.
the class ClientExecutorServiceTest method testExecutionCallback_whenExecutionRejected.
@Ignore("Behaviour needs a better test, due to switching from user executor to ForkJoinPool.commonPool")
@Test
public void testExecutionCallback_whenExecutionRejected() {
final AtomicReference<Throwable> exceptionThrown = new AtomicReference<>();
final CountDownLatch waitForShutdown = new CountDownLatch(1);
final CountDownLatch didShutdown = new CountDownLatch(1);
final HazelcastClientInstanceImpl hzClient = ClientTestUtil.getHazelcastClientInstanceImpl(client);
ExecutionRejectedRunnable.waitForShutdown = waitForShutdown;
ExecutionRejectedRunnable.didShutdown = didShutdown;
IExecutorService executorService = hzClient.getExecutorService("executor");
Thread t = new Thread(() -> {
try {
waitForShutdown.await(30, TimeUnit.SECONDS);
} catch (InterruptedException e) {
ignore(e);
}
ForkJoinPool.commonPool().shutdown();
didShutdown.countDown();
});
t.start();
executorService.submit(new ExecutionRejectedRunnable(), new ExecutionCallback<Object>() {
@Override
public void onResponse(Object response) {
}
@Override
public void onFailure(Throwable t) {
exceptionThrown.set(t);
}
});
// assert a RejectedExecutionException is thrown from already shutdown user executor
// it is not wrapped in a HazelcastClientNotActiveException because the client is still running
assertTrueEventually(() -> assertTrue(exceptionThrown.get() instanceof RejectedExecutionException));
}
use of com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl in project hazelcast by hazelcast.
the class AbstractListenersOnReconnectTest method testListenersTemporaryNetworkBlockage.
private void testListenersTemporaryNetworkBlockage(boolean isSmart, int clusterSize) {
factory.newInstances(null, clusterSize);
ClientConfig clientConfig = createClientConfig(isSmart);
client = factory.newHazelcastClient(clientConfig);
setupListener();
HazelcastClientInstanceImpl clientInstanceImpl = getHazelcastClientInstanceImpl(client);
long timeout = clientInstanceImpl.getProperties().getMillis(HEARTBEAT_TIMEOUT);
long waitTime = timeout / 2;
for (HazelcastInstance instance : factory.getAllHazelcastInstances()) {
blockMessagesFromInstance(instance, client);
}
sleepMillis((int) waitTime);
for (HazelcastInstance instance : factory.getAllHazelcastInstances()) {
unblockMessagesFromInstance(instance, client);
}
validateRegistrationsAndListenerFunctionality();
}
use of com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl in project hazelcast by hazelcast.
the class AbstractListenersOnReconnectTest method getClientEventRegistrations.
private Map<Connection, ClientConnectionRegistration> getClientEventRegistrations(HazelcastInstance client, UUID id) {
HazelcastClientInstanceImpl clientImpl = ClientTestUtil.getHazelcastClientInstanceImpl(client);
ClientListenerServiceImpl listenerService = (ClientListenerServiceImpl) clientImpl.getListenerService();
return listenerService.getActiveRegistrations(id);
}
Aggregations