void destroyBlockingChannel(BlockingChannel blockingChannel) {
    rwlock.readLock().lock();
    try {
      boolean changed = blockingChannelActiveConnections.remove(blockingChannel);
      if (!changed) {
        logger.error("Invalid connection being destroyed. "
                + "Channel does not belong to this queue. queue host {} port {} channel host {} port {}", host,
            port.getPort(), blockingChannel.getRemoteHost(), blockingChannel.getRemotePort());
        throw new IllegalArgumentException("Invalid connection. Channel does not belong to this queue");
      }
      blockingChannel.disconnect();
      // we ensure we maintain the current count of connections to the host to avoid synchronization across threads
      // to create the connection
      BlockingChannel channel =
          getBlockingChannelBasedOnPortType(blockingChannel.getRemoteHost(), blockingChannel.getRemotePort());
      channel.connect();
      logger.trace("Destroying connection and adding new connection for host {} port {}", host, port.getPort());
      blockingChannelAvailableConnections.add(channel);
    } catch (Exception e) {
      logger.error(
          "Connection failure to remote host {} and port {} when destroying and recreating the connection. Exception: ",
          host, port.getPort(), e);
      synchronized (lock) {
        // decrement the number of connections to the host and port. we were not able to maintain the count
        numberOfConnections.decrementAndGet();
        // at this point we are good to clean up the available connections since re-creation failed
        do {
          BlockingChannel channel = blockingChannelAvailableConnections.poll();
          if (channel == null) {
            break;
          }
          if (config.connectionPoolSocketResetOnError) {
            channel.reset();
          } else {
            channel.disconnect();
          }
          numberOfConnections.decrementAndGet();
        } while (true);
      }
    } finally {
      rwlock.readLock().unlock();
    }
  }
Returns BlockingChannel or SSLBlockingChannel depending on whether the port type is PlainText or SSL
@param host upon which connection has to be established
@param port upon which connection has to be established
@return BlockingChannel
ambry-network/src/main/java/com/github/ambry/network/BlockingChannelInfo.java