@Override
    public Promise<PooledConnection> acquire(
            EventLoop eventLoop, CurrentPassport passport, AtomicReference<? super InetAddress> selectedHostAddr) {

        if (draining) {
            throw new IllegalStateException("Attempt to acquire connection while draining");
        }

        requestConnCounter.increment();
        updateServerStatsOnAcquire();

        Promise<PooledConnection> promise = eventLoop.newPromise();

        // Try getting a connection from the pool.
        final PooledConnection conn = tryGettingFromConnectionPool(eventLoop);
        if (conn != null) {
            // There was a pooled connection available, so use this one.
            reusePooledConnection(passport, selectedHostAddr, conn, promise);
        } else {
            // connection pool empty, create new connection using client connection factory.
            tryMakingNewConnection(eventLoop, promise, passport, selectedHostAddr);
        }

        return promise;
    }
@Test
    void acquireNewConnectionHitsMaxConnections() {
        CurrentPassport currentPassport = CurrentPassport.create();

        clientConfig.set(Keys.MaxConnectionsPerHost, 1);
        discoveryResult.incrementOpenConnectionsCount();

        Promise<PooledConnection> promise = pool.acquire(CLIENT_EVENT_LOOP, currentPassport, new AtomicReference<>());

        assertFalse(promise.isSuccess());
        assertTrue(promise.cause() instanceof OriginConnectException);
        assertEquals(1, maxConnsPerHostExceededCounter.count());
    }