use of com.hazelcast.internal.nio.Connection in project hazelcast by hazelcast.
the class TcpClientConnectionManager method shutdown.
public synchronized void shutdown() {
if (!isAlive.compareAndSet(true, false)) {
return;
}
executor.shutdownNow();
ClientExecutionServiceImpl.awaitExecutorTermination("cluster", executor, logger);
for (Connection connection : activeConnections.values()) {
connection.close("Hazelcast client is shutting down", null);
}
stopNetworking();
connectionListeners.clear();
clusterDiscoveryService.current().destroy();
}
use of com.hazelcast.internal.nio.Connection in project hazelcast by hazelcast.
the class ClusterViewListenerService method sendToListeningEndpoints.
private void sendToListeningEndpoints(ClientMessage clientMessage) {
for (Map.Entry<ClientEndpoint, Long> entry : clusterListeningEndpoints.entrySet()) {
Long correlationId = entry.getValue();
// share the partition and membership table, copy only initial frame
ClientMessage message = clientMessage.copyWithNewCorrelationId(correlationId);
ClientEndpoint clientEndpoint = entry.getKey();
Connection connection = clientEndpoint.getConnection();
write(message, connection);
}
}
use of com.hazelcast.internal.nio.Connection in project hazelcast by hazelcast.
the class SqlClientExecuteCloseRaceTest method testCloseExecute.
@Test
public void testCloseExecute() {
QueryId queryId = QueryId.create(UUID.randomUUID());
// Send "close"
Connection connection = clientService.getQueryConnection();
ClientMessage closeRequest = SqlCloseCodec.encodeRequest(queryId);
clientService.invokeOnConnection(connection, closeRequest);
assertEquals(1, memberService.getInternalService().getClientStateRegistry().getCursorCount());
// Send "execute"
ClientMessage executeResponse = sendExecuteRequest(connection, queryId);
assertEquals(0, memberService.getInternalService().getClientStateRegistry().getCursorCount());
checkExecuteResponse(executeResponse, false);
}
use of com.hazelcast.internal.nio.Connection in project hazelcast by hazelcast.
the class SqlClientExecuteCloseRaceTest method testClose.
@Test
public void testClose() {
QueryId queryId = QueryId.create(UUID.randomUUID());
// Send "close"
Connection connection = clientService.getQueryConnection();
ClientMessage closeRequest = SqlCloseCodec.encodeRequest(queryId);
clientService.invokeOnConnection(connection, closeRequest);
// Make sure that we observed the cancel request.
assertEquals(1, memberService.getInternalService().getClientStateRegistry().getCursorCount());
// Wait for it to disappear.
memberService.getInternalService().getClientStateRegistry().setClosedCursorCleanupTimeoutSeconds(1L);
assertTrueEventually(() -> assertEquals(0, memberService.getInternalService().getClientStateRegistry().getCursorCount()));
}
use of com.hazelcast.internal.nio.Connection 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);
}
Aggregations