/** Closes the connection. Note: this method will block until the connection is actually closed */
  @Override
  public void close() {
    _log.info("closing connection to: " + _server.getAddress());
    final State newState = switchToClosing();
    if (State.CLOSING != newState && State.CLOSED != newState) {
      return;
    }

    if (null == _channel || !_channel.isConnected()) {
      switchToClosed();
    } else {
      _channel.close();
      awaitForCloseUninterruptibly();
    }
  }