public void connectionRemoved(Connection connection) { if (connection.isClient() && connection instanceof TcpIpConnection && nodeEngine.isActive()) { final ClientEndpoint endpoint = endpoints.get(connection); if (endpoint != null && node.getLocalMember().getUuid().equals(endpoint.getPrincipal().getOwnerUuid())) { removeEndpoint(connection, true); if (!endpoint.isFirstConnection()) { return; } NodeEngine nodeEngine = node.nodeEngine; final Collection<MemberImpl> memberList = nodeEngine.getClusterService().getMemberList(); for (MemberImpl member : memberList) { final ClientDisconnectionOperation op = new ClientDisconnectionOperation(endpoint.getUuid()); op.setNodeEngine(nodeEngine) .setServiceName(SERVICE_NAME) .setService(this) .setResponseHandler(ResponseHandlerFactory.createEmptyResponseHandler()); if (member.localMember()) { nodeEngine.getOperationService().runOperation(op); } else { nodeEngine.getOperationService().send(op, member.getAddress()); } } } } }
public void shutdown() { for (ClientEndpoint endpoint : endpoints.values()) { try { endpoint.destroy(); } catch (LoginException e) { logger.finest(e.getMessage()); } try { final Connection conn = endpoint.getConnection(); if (conn.live()) { conn.close(); } } catch (Exception e) { logger.finest(e); } } endpoints.clear(); }
Set<ClientEndpoint> getEndpoints(String uuid) { Set<ClientEndpoint> endpointSet = new HashSet<ClientEndpoint>(); for (ClientEndpoint endpoint : endpoints.values()) { if (uuid.equals(endpoint.getUuid())) { endpointSet.add(endpoint); } } return endpointSet; }
public Collection<Client> getEndpoints() { return new HashSet<Client>(endpoints.values()); }
ClientEndpoint removeEndpoint(final Connection connection, boolean closeImmediately) { final ClientEndpoint endpoint = endpoints.remove(connection); destroyEndpoint(endpoint, closeImmediately); return endpoint; }
@Override public int getClientEndpointCount() { return endpoints.size(); }