use of com.hazelcast.client.impl.connection.ClientConnectionManager in project hazelcast by hazelcast.
the class ClientHeartbeatTest method testConnectionClosed_whenHeartbeatStopped.
@Test
public void testConnectionClosed_whenHeartbeatStopped() {
hazelcastFactory.newHazelcastInstance();
final HazelcastInstance client = hazelcastFactory.newHazelcastClient(getClientConfig());
HazelcastInstance instance = hazelcastFactory.newHazelcastInstance();
HazelcastClientInstanceImpl clientImpl = getHazelcastClientInstanceImpl(client);
final ClientConnectionManager connectionManager = clientImpl.getConnectionManager();
makeSureConnectedToServers(client, 2);
final CountDownLatch countDownLatch = new CountDownLatch(1);
connectionManager.addConnectionListener(new ConnectionListener() {
@Override
public void connectionAdded(Connection connection) {
}
@Override
public void connectionRemoved(Connection connection) {
countDownLatch.countDown();
}
});
blockMessagesFromInstance(instance, client);
assertOpenEventually(countDownLatch);
}
use of com.hazelcast.client.impl.connection.ClientConnectionManager in project hazelcast by hazelcast.
the class ClientClusterServiceImpl method getLocalClient.
@Override
public Client getLocalClient() {
final ClientConnectionManager cm = client.getConnectionManager();
final TcpClientConnection connection = (TcpClientConnection) cm.getRandomConnection();
InetSocketAddress inetSocketAddress = connection != null ? connection.getLocalSocketAddress() : null;
UUID clientUuid = cm.getClientUuid();
return new ClientImpl(clientUuid, inetSocketAddress, client.getName(), labels);
}
use of com.hazelcast.client.impl.connection.ClientConnectionManager in project hazelcast by hazelcast.
the class ClientTestSupport method blockMessagesToInstance.
/**
* Blocks outgoing messages from client to given instance
*/
protected void blockMessagesToInstance(HazelcastInstance instance, HazelcastInstance client) {
HazelcastClientInstanceImpl clientImpl = getHazelcastClientInstanceImpl(client);
ClientConnectionManager connectionManager = clientImpl.getConnectionManager();
Address address = instance.getCluster().getLocalMember().getAddress();
((TestClientRegistry.MockTcpClientConnectionManager) connectionManager).blockTo(address);
}
use of com.hazelcast.client.impl.connection.ClientConnectionManager in project hazelcast by hazelcast.
the class ClientTestSupport method makeSureConnectedToServers.
protected void makeSureConnectedToServers(final HazelcastInstance client, final int numberOfServers) {
assertTrueEventually(() -> {
ClientConnectionManager connectionManager = getHazelcastClientInstanceImpl(client).getConnectionManager();
assertEquals(numberOfServers, connectionManager.getActiveConnections().size());
});
}
Aggregations