Beispiel #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());
          }
        }
      }
    }
  }
Beispiel #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();
 }
Beispiel #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;
 }
Beispiel #4
0
 public Collection<Client> getEndpoints() {
   return new HashSet<Client>(endpoints.values());
 }
Beispiel #5
0
 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();
 }