private void closeConnection(Address address, String reason) { Connection conn = node.connectionManager.getConnection(address); if (conn != null) { conn.close(reason, null); } }
private void destroySilently(Connection conn, String reason) { if (conn == null) { return; } try { conn.close(reason, null); } catch (Throwable ignore) { logger.finest(ignore); } }
private void destroySilently(Connection conn, String reason) { if (conn == null) { return; } try { conn.close(reason, null); } catch (Throwable ignore) { logger.finest(ignore); } }
private void closeConnection(Address address, String reason) { Connection conn = node.connectionManager.getConnection(address); if (conn != null) { conn.close(reason, null); } }
@Override public void onError(Channel channel, Throwable cause) { if (channel == null) { logger.severe(cause); } else { if (cause instanceof OutOfMemoryError) { logger.severe(cause); } Connection connection = (Connection) channel.attributeMap().get(ClientConnection.class); if (cause instanceof EOFException) { connection.close("Connection closed by the other side", cause); } else { connection.close("Exception in " + connection + ", thread=" + Thread.currentThread().getName(), cause); } } } }
public synchronized void shutdown() { if (!alive) { return; } alive = false; for (Connection connection : activeConnections.values()) { connection.close("Hazelcast client is shutting down", null); } clusterConnector.shutdown(); stopNetworking(); connectionListeners.clear(); heartbeat.shutdown(); connectionStrategy.shutdown(); credentialsFactory.destroy(); }
public synchronized void shutdown() { if (!alive) { return; } alive = false; for (Connection connection : activeConnections.values()) { connection.close("Hazelcast client is shutting down", null); } clusterConnector.shutdown(); stopNetworking(); connectionListeners.clear(); heartbeat.shutdown(); connectionStrategy.shutdown(); credentialsFactory.destroy(); }
private void memberRemoved(Member member) { members.remove(member); logger.info(membersString()); final Connection connection = connectionManager.getActiveConnection(member.getAddress()); if (connection != null) { connection.close(null, newTargetDisconnectedExceptionCausedByMemberLeftEvent(connection)); } MembershipEvent event = new MembershipEvent(client.getCluster(), member, MembershipEvent.MEMBER_REMOVED, unmodifiableSet(members)); clusterService.handleMembershipEvent(event); }
private void memberRemoved(Member member) { members.remove(member); logger.info(membersString()); final Connection connection = connectionManager.getActiveConnection(member.getAddress()); if (connection != null) { connection.close(null, newTargetDisconnectedExceptionCausedByMemberLeftEvent(connection)); } MembershipEvent event = new MembershipEvent(client.getCluster(), member, MembershipEvent.MEMBER_REMOVED, unmodifiableSet(members)); clusterService.handleMembershipEvent(event); }
private void handleAuthenticationFailure() { Exception exception; if (nodeEngine.isRunning()) { String message = "Client " + endpoint + " must authenticate before any operation."; logger.severe(message); exception = new RetryableHazelcastException(new StubAuthenticationException(message)); } else { exception = new HazelcastInstanceNotActiveException(); } sendClientMessage(exception); connection.close("Authentication failed. " + exception.getMessage(), null); }
private void handleAuthenticationFailure() { Exception exception; if (nodeEngine.isRunning()) { String message = "Client " + endpoint + " must authenticate before any operation."; logger.severe(message); exception = new RetryableHazelcastException(new StubAuthenticationException(message)); } else { exception = new HazelcastInstanceNotActiveException(); } sendClientMessage(exception); connection.close("Authentication failed. " + exception.getMessage(), null); }
private Connection connectAsOwner(Address address) { Connection connection = null; try { logger.info("Trying to connect to " + address + " as owner member"); connection = connectionManager.getOrConnect(address, true); client.onClusterConnect(connection); fireConnectionEvent(LifecycleEvent.LifecycleState.CLIENT_CONNECTED); connectionStrategy.onClusterConnect(); } catch (Exception e) { logger.warning("Exception during initial connection to " + address + ", exception " + e); if (null != connection) { connection.close("Could not connect to " + address + " as owner", e); } return null; } return connection; }
private Connection connectAsOwner(Address address) { Connection connection = null; try { logger.info("Trying to connect to " + address + " as owner member"); connection = connectionManager.getOrConnect(address, true); client.onClusterConnect(connection); fireConnectionEvent(LifecycleEvent.LifecycleState.CLIENT_CONNECTED); connectionStrategy.onConnectToCluster(); } catch (Exception e) { logger.warning("Exception during initial connection to " + address + ", exception " + e); if (null != connection) { connection.close("Could not connect to " + address + " as owner", e); } return null; } return connection; }
private void clear(String reason) { for (ClientEndpoint ce : endpointManager.getEndpoints()) { ClientEndpointImpl endpoint = (ClientEndpointImpl) ce; try { endpoint.destroy(); } catch (LoginException e) { logger.finest(e.getMessage()); } try { final Connection conn = endpoint.getConnection(); if (conn.isAlive()) { conn.close(reason, null); } } catch (Exception e) { logger.finest(e); } } endpointManager.clear(); ownershipMappings.clear(); }
private void monitor(ClientEndpoint clientEndpoint) { // C++ client does not send heartbeat over its owner connection for versions before 3.10 // We are skipping checking heartbeat for cpp owner connection on those versions. if (clientEndpoint.isOwnerConnection() && ClientType.CPP.equals(clientEndpoint.getClientType()) && clientEndpoint.getClientVersion() < BuildInfo.calculateVersion("3.10")) { return; } Connection connection = clientEndpoint.getConnection(); long lastTimePacketReceived = connection.lastReadTimeMillis(); long timeoutInMillis = SECONDS.toMillis(heartbeatTimeoutSeconds); long currentTimeMillis = Clock.currentTimeMillis(); if (lastTimePacketReceived + timeoutInMillis < currentTimeMillis) { String message = "Client heartbeat is timed out, closing connection to " + connection + ". Now: " + timeToString(currentTimeMillis) + ". LastTimePacketReceived: " + timeToString(lastTimePacketReceived); connection.close(message, null); } } }
@Override public void run() { NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine(); Connection connection = getConnection(); String message = "Node could not join cluster at node: " + connection.getEndPoint() + " Cause: the target cluster has a different group-name"; connection.close(message, null); ILogger logger = nodeEngine.getLogger("com.hazelcast.cluster"); logger.warning(message); Node node = nodeEngine.getNode(); node.getJoiner().blacklist(getCallerAddress(), true); }
private void monitor(ClientEndpoint clientEndpoint) { // C++ client does not send heartbeat over its owner connection for versions before 3.10 // We are skipping checking heartbeat for cpp owner connection on those versions. if (clientEndpoint.isOwnerConnection() && ClientType.CPP.equals(clientEndpoint.getClientType()) && clientEndpoint.getClientVersion() < BuildInfo.calculateVersion("3.10")) { return; } Connection connection = clientEndpoint.getConnection(); long lastTimePacketReceived = connection.lastReadTimeMillis(); long timeoutInMillis = SECONDS.toMillis(heartbeatTimeoutSeconds); long currentTimeMillis = Clock.currentTimeMillis(); if (lastTimePacketReceived + timeoutInMillis < currentTimeMillis) { String message = "Client heartbeat is timed out, closing connection to " + connection + ". Now: " + timeToString(currentTimeMillis) + ". LastTimePacketReceived: " + timeToString(lastTimePacketReceived); connection.close(message, null); } } }
@Override public void run() { NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine(); Connection connection = getConnection(); String message = "Node could not join cluster at node: " + connection.getEndPoint() + " Cause: the target cluster has a different group-name"; connection.close(message, null); ILogger logger = nodeEngine.getLogger("com.hazelcast.cluster"); logger.warning(message); Node node = nodeEngine.getNode(); node.getJoiner().blacklist(getCallerAddress(), true); }
private boolean doRun() { ClientEngineImpl engine = getService(); final ClientEndpointManagerImpl endpointManager = (ClientEndpointManagerImpl) engine.getEndpointManager(); if (!engine.removeOwnershipMapping(clientUuid, memberUuid)) { return false; } Set<ClientEndpoint> endpoints = endpointManager.getEndpoints(clientUuid); // This part cleans up listener and transactions for (ClientEndpoint endpoint : endpoints) { endpoint.getConnection().close("ClientDisconnectionOperation: Client disconnected from cluster", null); } NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine(); // This part cleans up locks conditions semaphore etc.. Collection<ClientAwareService> services = nodeEngine.getServices(ClientAwareService.class); for (ClientAwareService service : services) { service.clientDisconnected(clientUuid); } return true; }
private boolean doRun() { ClientEngineImpl engine = getService(); final ClientEndpointManagerImpl endpointManager = (ClientEndpointManagerImpl) engine.getEndpointManager(); if (!engine.removeOwnershipMapping(clientUuid, memberUuid)) { return false; } Set<ClientEndpoint> endpoints = endpointManager.getEndpoints(clientUuid); // This part cleans up listener and transactions for (ClientEndpoint endpoint : endpoints) { endpoint.getConnection().close("ClientDisconnectionOperation: Client disconnected from cluster", null); } NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine(); // This part cleans up locks conditions semaphore etc.. Collection<ClientAwareService> services = nodeEngine.getServices(ClientAwareService.class); for (ClientAwareService service : services) { service.clientDisconnected(clientUuid); } return true; }