private void notifyConnect(SessionProtocol desiredProtocol,
                               PoolKey key, Future<Channel> future,
                               ChannelAcquisitionFuture promise,
                               ClientConnectionTimingsBuilder timingsBuilder) {
        assert future.isDone();
        removePendingAcquisition(desiredProtocol, key);

        timingsBuilder.socketConnectEnd();
        try {
            if (future.isSuccess()) {
                final Channel channel = future.getNow();
                final SessionProtocol protocol = getProtocolIfHealthy(channel);
                if (protocol == null || closeable.isClosing()) {
                    channel.close();
                    promise.completeExceptionally(
                            UnprocessedRequestException.of(
                                    new ClosedSessionException("acquired an unhealthy connection")));
                    return;
                }

                allChannels.put(channel, Boolean.TRUE);

                final InetSocketAddress remoteAddr = ChannelUtil.remoteAddress(channel);
                final InetSocketAddress localAddr = ChannelUtil.localAddress(channel);
                assert remoteAddr != null && localAddr != null
                        : "raddr: " + remoteAddr + ", laddr: " + localAddr;
                try {
                    listener.connectionOpen(protocol, remoteAddr, localAddr, channel);
                } catch (Throwable e) {
                    if (logger.isWarnEnabled()) {
                        logger.warn("{} Exception handling {}.connectionOpen()",
                                    channel, listener.getClass().getName(), e);
                    }
                }

                final HttpSession session = HttpSession.get(channel);
                if (session.incrementNumUnfinishedResponses()) {
                    if (protocol.isMultiplex()) {
                        final Http2PooledChannel pooledChannel = new Http2PooledChannel(channel, protocol);
                        addToPool(protocol, key, pooledChannel);
                        promise.complete(pooledChannel);
                    } else {
                        promise.complete(new Http1PooledChannel(channel, protocol, key));
                    }
                } else {
                    // Server set MAX_CONCURRENT_STREAMS to 0, which means we can't send anything.
                    channel.close();
                    promise.completeExceptionally(
                            UnprocessedRequestException.of(RefusedStreamException.get()));
                }

                channel.closeFuture().addListener(f -> {
                    allChannels.remove(channel);

                    // Clean up old unhealthy channels by iterating from the beginning of the queue.
                    final Deque<PooledChannel> queue = getPool(protocol, key);
                    if (queue != null) {
                        for (;;) {
                            final PooledChannel pooledChannel = queue.peekFirst();
                            if (pooledChannel == null || isHealthy(pooledChannel)) {
                                break;
                            }
                            queue.removeFirst();
                        }
                    }

                    try {
                        listener.connectionClosed(protocol, remoteAddr, localAddr, channel);
                    } catch (Throwable e) {
                        if (logger.isWarnEnabled()) {
                            logger.warn("{} Exception handling {}.connectionClosed()",
                                        channel, listener.getClass().getName(), e);
                        }
                    }
                });
            } else {
                final Throwable throwable = future.cause();
                if (throwable instanceof ProxyConnectException) {
                    maybeHandleProxyFailure(desiredProtocol, key, throwable);
                }
                promise.completeExceptionally(UnprocessedRequestException.of(throwable));
            }
        } catch (Exception e) {
            promise.completeExceptionally(UnprocessedRequestException.of(e));
        }
    }
Returns the number of open connections on this {@link HttpChannelPool}.
core/src/main/java/com/linecorp/armeria/client/HttpChannelPool.java