Search in sources :

Example 1 with TcpClientConnectionManager

use of com.hazelcast.client.impl.connection.tcp.TcpClientConnectionManager 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()));
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) ClientEngineImpl(com.hazelcast.client.impl.ClientEngineImpl) Consumer(java.util.function.Consumer) TcpClientConnectionManager(com.hazelcast.client.impl.connection.tcp.TcpClientConnectionManager) HazelcastClientInstanceImpl(com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl) ClientTestUtil.getHazelcastClientInstanceImpl(com.hazelcast.client.impl.clientside.ClientTestUtil.getHazelcastClientInstanceImpl) ClientConfig(com.hazelcast.client.config.ClientConfig) UUID(java.util.UUID) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 2 with TcpClientConnectionManager

use of com.hazelcast.client.impl.connection.tcp.TcpClientConnectionManager in project hazelcast by hazelcast.

the class ClientRegressionWithRealNetworkTest method testNioChannelLeakTest.

@Test
public void testNioChannelLeakTest() {
    ClientConfig config = new ClientConfig();
    config.getConnectionStrategyConfig().setAsyncStart(true).setReconnectMode(ClientConnectionStrategyConfig.ReconnectMode.ASYNC).getConnectionRetryConfig().setInitialBackoffMillis(1).setClusterConnectTimeoutMillis(1000);
    HazelcastInstance client = HazelcastClient.newHazelcastClient(config);
    HazelcastClientInstanceImpl clientInstanceImpl = getHazelcastClientInstanceImpl(client);
    TcpClientConnectionManager connectionManager = (TcpClientConnectionManager) clientInstanceImpl.getConnectionManager();
    sleepSeconds(2);
    assertTrueEventually(() -> assertEquals(0, connectionManager.getNetworking().getChannels().size()));
    client.shutdown();
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) TcpClientConnectionManager(com.hazelcast.client.impl.connection.tcp.TcpClientConnectionManager) HazelcastClientInstanceImpl(com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl) ClientConfig(com.hazelcast.client.config.ClientConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Aggregations

ClientConfig (com.hazelcast.client.config.ClientConfig)2 HazelcastClientInstanceImpl (com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl)2 TcpClientConnectionManager (com.hazelcast.client.impl.connection.tcp.TcpClientConnectionManager)2 HazelcastInstance (com.hazelcast.core.HazelcastInstance)2 QuickTest (com.hazelcast.test.annotation.QuickTest)2 Test (org.junit.Test)2 ClientEngineImpl (com.hazelcast.client.impl.ClientEngineImpl)1 ClientTestUtil.getHazelcastClientInstanceImpl (com.hazelcast.client.impl.clientside.ClientTestUtil.getHazelcastClientInstanceImpl)1 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)1 SlowTest (com.hazelcast.test.annotation.SlowTest)1 UUID (java.util.UUID)1 Consumer (java.util.function.Consumer)1