Ejemplo n.º 1
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.º 2
0
  private void destroyEndpoint(ClientEndpoint endpoint, boolean closeImmediately) {
    if (endpoint != null) {
      logger.info("Destroying " + endpoint);
      try {
        endpoint.destroy();
      } catch (LoginException e) {
        logger.warning(e);
      }

      final Connection connection = endpoint.getConnection();
      if (closeImmediately) {
        try {
          connection.close();
        } catch (Throwable e) {
          logger.warning("While closing client connection: " + connection, e);
        }
      } else {
        nodeEngine
            .getExecutionService()
            .schedule(
                new Runnable() {
                  public void run() {
                    if (connection.live()) {
                      try {
                        connection.close();
                      } catch (Throwable e) {
                        logger.warning("While closing client connection: " + e.toString());
                      }
                    }
                  }
                },
                1111,
                TimeUnit.MILLISECONDS);
      }
      sendClientEvent(endpoint);
    }
  }
Ejemplo n.º 3
0
  void removeEndpoint(final ClientEndpoint endpoint, boolean closeImmediately) {
    endpoints.remove(endpoint.getConnection());
    LOGGER.info("Destroying " + endpoint);
    try {
      endpoint.destroy();
    } catch (LoginException e) {
      LOGGER.warning(e);
    }

    final Connection connection = endpoint.getConnection();
    if (closeImmediately) {
      try {
        connection.close();
      } catch (Throwable e) {
        LOGGER.warning("While closing client connection: " + connection, e);
      }
    } else {
      nodeEngine
          .getExecutionService()
          .schedule(
              new Runnable() {
                public void run() {
                  if (connection.live()) {
                    try {
                      connection.close();
                    } catch (Throwable e) {
                      LOGGER.warning("While closing client connection: " + e.toString());
                    }
                  }
                }
              },
              DESTROY_ENDPOINT_DELAY_MS,
              TimeUnit.MILLISECONDS);
    }
    clientEngine.sendClientEvent(endpoint);
  }