Ejemplo n.º 1
0
  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());
          }
        }
      }
    }
  }
Ejemplo n.º 2
0
 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();
 }
Ejemplo n.º 3
0
 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;
 }
Ejemplo n.º 4
0
 public Collection<Client> getEndpoints() {
   return new HashSet<Client>(endpoints.values());
 }
Ejemplo n.º 5
0
 ClientEndpoint removeEndpoint(final Connection connection, boolean closeImmediately) {
   final ClientEndpoint endpoint = endpoints.remove(connection);
   destroyEndpoint(endpoint, closeImmediately);
   return endpoint;
 }
Ejemplo n.º 6
0
 @Override
 public int getClientEndpointCount() {
   return endpoints.size();
 }