예제 #1
0
 public void connectionRemoved(Connection connection) {
   logger.log(Level.FINEST, "Connection is removed " + connection.getEndPoint());
   if (!node.joined()) {
     if (getMasterAddress() != null) {
       if (getMasterAddress().equals(connection.getEndPoint())) {
         node.setMasterAddress(null);
       }
     }
   }
 }
예제 #2
0
 @Override
 public void connectionRemoved(Connection connection) {
   if (logger.isFinestEnabled()) {
     logger.finest("Removed connection " + connection.getEndPoint());
   }
   if (!node.joined()) {
     Address masterAddress = node.getMasterAddress();
     if (masterAddress != null && masterAddress.equals(connection.getEndPoint())) {
       node.setMasterAddress(null);
     }
   }
 }
  @Override
  public void destroyConnection(final Connection connection) {
    if (connection == null) {
      return;
    }
    if (logger.isFinestEnabled()) {
      logger.finest("Destroying " + connection);
    }

    if (activeConnections.remove(connection)) {
      // this should not be needed; but some tests are using DroppingConnection which is not a
      // TcpIpConnection.
      if (connection instanceof TcpIpConnection) {
        ioThreadingModel.onConnectionRemoved((TcpIpConnection) connection);
      }
    }
    final Address endPoint = connection.getEndPoint();
    if (endPoint != null) {
      connectionsInProgress.remove(endPoint);
      connectionsMap.remove(endPoint, connection);
      fireConnectionRemovedEvent(connection, endPoint);
    }
    if (connection.isAlive()) {
      connection.close();
      closedCount.inc();
    }
  }
  public void destroyConnection(final Connection connection) {
    final Address endPoint = connection.getEndPoint();
    final boolean removed = mapConnections.remove(endPoint, connection);
    if (!removed) {
      return;
    }

    logger.info("Removed connection to endpoint: " + endPoint + ", connection: " + connection);
    ioService
        .getEventService()
        .executeEventCallback(
            new StripedRunnable() {
              @Override
              public void run() {
                for (ConnectionListener listener : connectionListeners) {
                  listener.connectionRemoved(connection);
                }
              }

              @Override
              public int getKey() {
                return endPoint.hashCode();
              }
            });
  }
 protected final boolean isValid() {
   final ClusterServiceImpl clusterService = getService();
   final Connection conn = getConnection();
   final Address masterAddress = conn != null ? conn.getEndPoint() : null;
   return conn == null
       || // which means this is a local call.
       (masterAddress != null && masterAddress.equals(clusterService.getMasterAddress()));
 }
  ClientEndpoint createEndpoint(Connection conn) {
    if (!conn.live()) {
      LOGGER.severe("Can't create and endpoint for a dead connection");
      return null;
    }

    String clientUuid = UuidUtil.createClientUuid(conn.getEndPoint());
    ClientEndpoint endpoint = new ClientEndpoint(clientEngine, conn, clientUuid);
    if (endpoints.putIfAbsent(conn, endpoint) != null) {
      LOGGER.severe("An endpoint already exists for connection:" + conn);
    }
    return endpoint;
  }
  @Override
  public void heartBeatStopped(Connection connection) {
    ClientMessage request = ClientRemoveAllListenersCodec.encodeRequest();
    ClientInvocation removeListenerInvocation = new ClientInvocation(client, request, connection);
    removeListenerInvocation.setBypassHeartbeatCheck(true);
    removeListenerInvocation.invoke();

    final Address remoteEndpoint = connection.getEndPoint();
    final Iterator<ClientListenerInvocation> iterator = eventHandlerMap.values().iterator();
    final TargetDisconnectedException response = new TargetDisconnectedException(remoteEndpoint);

    while (iterator.hasNext()) {
      final ClientInvocation clientInvocation = iterator.next();
      if (clientInvocation.getSendConnection().equals(connection)) {
        iterator.remove();
        clientInvocation.notifyException(response);
      }
    }
  }
예제 #8
0
 public ClientEndpoint createNew(Connection conn) {
   return new ClientEndpoint(
       ClientEngineImpl.this, conn, UuidUtil.createClientUuid(conn.getEndPoint()));
 }