use of com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl in project hazelcast by hazelcast.
the class ListenerTests method testSmartListenerRegister_whenNodeJoined.
@Test
public void testSmartListenerRegister_whenNodeJoined() {
int nodeCount = 5;
for (int i = 0; i < nodeCount - 1; i++) {
factory.newHazelcastInstance();
}
HazelcastInstance client = factory.newHazelcastClient();
IMap<Object, Object> map = client.getMap("test");
ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
executorService.schedule(new Runnable() {
@Override
public void run() {
factory.newHazelcastInstance();
}
}, 500, TimeUnit.MILLISECONDS);
EntryAdapter listener = new EntryAdapter();
LinkedList<UUID> registrationIds = new LinkedList<UUID>();
HazelcastClientInstanceImpl clientInstance = getHazelcastClientInstanceImpl(client);
while (clientInstance.getConnectionManager().getActiveConnections().size() < nodeCount) {
registrationIds.add(map.addEntryListener(listener, false));
}
for (UUID registrationId : registrationIds) {
assertTrue(map.removeEntryListener(registrationId));
}
executorService.shutdown();
}
use of com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl in project hazelcast by hazelcast.
the class BackupListenerLeakTest method testBackupListenerIsNotRemoved_afterClientRestart.
@Test
public void testBackupListenerIsNotRemoved_afterClientRestart() throws InterruptedException {
ClientConfig clientConfig = new ClientConfig();
clientConfig.getConnectionStrategyConfig().getConnectionRetryConfig().setClusterConnectTimeoutMillis(Long.MAX_VALUE);
HazelcastInstance hazelcast = hazelcastFactory.newHazelcastInstance();
HazelcastInstance client = hazelcastFactory.newHazelcastClient(clientConfig);
HazelcastClientInstanceImpl clientImpl = getHazelcastClientInstanceImpl(client);
TcpClientConnectionManager connectionManager = (TcpClientConnectionManager) clientImpl.getConnectionManager();
connectionManager.reset();
Map<UUID, Consumer<Long>> backupListeners = ((ClientEngineImpl) getNode(hazelcast).clientEngine).getBackupListeners();
assertTrueEventually(() -> assertEquals(1, backupListeners.size()));
}
use of com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl in project hazelcast by hazelcast.
the class ClientInvocationTest method invokeOnMember_redirectDisallowedToRandom_whenMemberIsNotInMemberList.
@Test(expected = OperationTimeoutException.class)
public void invokeOnMember_redirectDisallowedToRandom_whenMemberIsNotInMemberList() {
hazelcastFactory.newHazelcastInstance();
UUID unavailableTarget = UUID.randomUUID();
ClientConfig config = new ClientConfig();
config.setProperty(ClientProperty.INVOCATION_TIMEOUT_SECONDS.getName(), "1");
HazelcastClientInstanceImpl client = getHazelcastClientInstanceImpl(hazelcastFactory.newHazelcastClient(config));
ClientMessage request = MapSizeCodec.encodeRequest("test");
ClientInvocation invocation = new ClientInvocation(client, request, "map", unavailableTarget);
invocation.disallowRetryOnRandom();
invocation.invoke().joinInternal();
}
use of com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl in project hazelcast by hazelcast.
the class ClientInvocationTest method invokeOnPartitionOwner_redirectDisallowedToRandom_WhenPartitionOwnerIsnull.
@Test(expected = OperationTimeoutException.class)
public void invokeOnPartitionOwner_redirectDisallowedToRandom_WhenPartitionOwnerIsnull() {
hazelcastFactory.newHazelcastInstance();
ClientConfig config = new ClientConfig();
config.setProperty(ClientProperty.INVOCATION_TIMEOUT_SECONDS.getName(), "1");
HazelcastClientInstanceImpl client = getHazelcastClientInstanceImpl(hazelcastFactory.newHazelcastClient(config));
ClientMessage request = MapSizeCodec.encodeRequest("test");
int ownerlessPartition = 4000;
ClientInvocation invocation = new ClientInvocation(client, request, "map", ownerlessPartition);
invocation.disallowRetryOnRandom();
invocation.invoke().joinInternal();
}
use of com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl in project hazelcast by hazelcast.
the class ClientResponseHandlerSupplierTest method getResponseHandler.
private Consumer<ClientMessage> getResponseHandler(int threadCount, boolean dynamic) {
HazelcastInstance client = hazelcastFactory.newHazelcastClient(new ClientConfig().setProperty(RESPONSE_THREAD_COUNT.getName(), "" + threadCount).setProperty(RESPONSE_THREAD_DYNAMIC.getName(), "" + dynamic));
HazelcastClientInstanceImpl clientInstanceImpl = getHazelcastClientInstanceImpl(client);
ClientInvocationServiceImpl invocationService = (ClientInvocationServiceImpl) clientInstanceImpl.getInvocationService();
ClientResponseHandlerSupplier responseHandlerSupplier = new ClientResponseHandlerSupplier(invocationService, clientInstanceImpl.getConcurrencyDetection());
return responseHandlerSupplier.get();
}
Aggregations