HttpClientConnection getConnection() { final PoolEntry<HttpHost, HttpClientConnection> poolEntry = poolEntryRef.get(); return poolEntry != null ? poolEntry.getConnection() : null; }
HttpClientConnection getConnection() { final PoolEntry<HttpHost, HttpClientConnection> poolEntry = poolEntryRef.get(); return poolEntry != null ? poolEntry.getConnection() : null; }
@Override public boolean isConnected() { final PoolEntry<HttpHost, IOSession> poolEntry = poolEntryRef.get(); if (poolEntry != null) { final IOSession ioSession = poolEntry.getConnection(); if (ioSession != null && !ioSession.isClosed()) { return true; } } return false; }
@Override public boolean isConnected() { final PoolEntry<HttpHost, IOSession> poolEntry = poolEntryRef.get(); if (poolEntry != null) { final IOSession ioSession = poolEntry.getConnection(); if (ioSession != null && !ioSession.isClosed()) { return true; } } return false; }
@Override public void execute( final AsyncClientExchangeHandler exchangeHandler, final HandlerFactory<AsyncPushConsumer> pushHandlerFactory, final HttpContext context) { final PoolEntry<HttpHost, IOSession> poolEntry = poolEntryRef.get(); if (poolEntry == null) { throw new IllegalStateException("Endpoint has already been released"); } final IOSession ioSession = poolEntry.getConnection(); if (ioSession == null) { throw new IllegalStateException("I/O session is invalid"); } ioSession.enqueue(new RequestExecutionCommand(exchangeHandler, pushHandlerFactory, null, context), Command.Priority.NORMAL); }
void releaseConnection() { final PoolEntry<HttpHost, HttpClientConnection> poolEntry = poolEntryRef.getAndSet(null); if (poolEntry != null) { final HttpClientConnection connection = poolEntry.getConnection(); connPool.release(poolEntry, connection != null && connection.isOpen()); } }
@Override public void releaseAndReuse() { final PoolEntry<HttpHost, IOSession> poolEntry = poolEntryRef.getAndSet(null); if (poolEntry != null) { final IOSession ioSession = poolEntry.getConnection(); connPool.release(poolEntry, ioSession != null && !ioSession.isClosed()); } }
@Override public void releaseAndReuse() { final PoolEntry<HttpHost, IOSession> poolEntry = poolEntryRef.getAndSet(null); if (poolEntry != null) { final IOSession ioSession = poolEntry.getConnection(); connPool.release(poolEntry, ioSession != null && !ioSession.isClosed()); } }
void releaseConnection() { final PoolEntry<HttpHost, HttpClientConnection> poolEntry = poolEntryRef.getAndSet(null); if (poolEntry != null) { final HttpClientConnection connection = poolEntry.getConnection(); connPool.release(poolEntry, connection != null && connection.isOpen()); } }
@Override public void setSocketTimeout(final Timeout timeout) { getValidatedPoolEntry().getConnection().setSocketTimeout(timeout); }
@Override public boolean isConnected() { final PoolEntry<HttpRoute, ManagedAsyncClientConnection> poolEntry = poolEntryRef.get(); if (poolEntry == null) { return false; } final ManagedAsyncClientConnection connection = poolEntry.getConnection(); if (connection == null) { return false; } if (!connection.isOpen()) { poolEntry.discardConnection(CloseMode.IMMEDIATE); return false; } return true; }
@Override public boolean isConnected() { final PoolEntry<HttpRoute, ManagedHttpClientConnection> poolEntry = getPoolEntry(); final ManagedHttpClientConnection connection = poolEntry.getConnection(); return connection != null && connection.isOpen(); }
@Override public void setSocketTimeout(final Timeout timeout) { getValidatedPoolEntry().getConnection().setSocketTimeout(timeout); }
PoolEntry<HttpRoute, ManagedAsyncClientConnection> getValidatedPoolEntry() { final PoolEntry<HttpRoute, ManagedAsyncClientConnection> poolEntry = getPoolEntry(); final ManagedAsyncClientConnection connection = poolEntry.getConnection(); Asserts.check(connection != null && connection.isOpen(), "Endpoint is not connected"); return poolEntry; }
void leaseCompleted(final PoolEntry<HttpRoute, ManagedAsyncClientConnection> poolEntry) { final ManagedAsyncClientConnection connection = poolEntry.getConnection(); if (connection != null) { connection.activate(); } if (log.isDebugEnabled()) { log.debug("Connection leased: " + ConnPoolSupport.formatStats(connection, route, state, pool)); } final AsyncConnectionEndpoint endpoint = new InternalConnectionEndpoint(poolEntry); if (log.isDebugEnabled()) { log.debug(ConnPoolSupport.getId(endpoint) + ": acquired " + ConnPoolSupport.getId(connection)); } resultFuture.completed(endpoint); }
PoolEntry<HttpRoute, ManagedHttpClientConnection> getValidatedPoolEntry() { final PoolEntry<HttpRoute, ManagedHttpClientConnection> poolEntry = getPoolEntry(); final ManagedHttpClientConnection connection = poolEntry.getConnection(); Asserts.check(connection != null && connection.isOpen(), "Endpoint is not connected"); return poolEntry; }
@Override public void execute( final AsyncClientExchangeHandler exchangeHandler, final HandlerFactory<AsyncPushConsumer> pushHandlerFactory, final HttpContext context) { final ManagedAsyncClientConnection connection = getValidatedPoolEntry().getConnection(); if (log.isDebugEnabled()) { log.debug(id + ": executing exchange " + ConnPoolSupport.getId(exchangeHandler) + " over " + ConnPoolSupport.getId(connection)); } connection.submitCommand( new RequestExecutionCommand(exchangeHandler, pushHandlerFactory, context), Command.Priority.NORMAL); }
@Override public void upgrade( final AsyncConnectionEndpoint endpoint, final Object attachment, final HttpContext context) { Args.notNull(endpoint, "Managed endpoint"); final InternalConnectionEndpoint internalEndpoint = cast(endpoint); final PoolEntry<HttpRoute, ManagedAsyncClientConnection> poolEntry = internalEndpoint.getValidatedPoolEntry(); final HttpRoute route = poolEntry.getRoute(); final ManagedAsyncClientConnection connection = poolEntry.getConnection(); connectionOperator.upgrade(poolEntry.getConnection(), route.getTargetHost(), attachment); if (log.isDebugEnabled()) { log.debug(ConnPoolSupport.getId(internalEndpoint) + ": upgraded " + ConnPoolSupport.getId(connection)); } }
@Override public ClassicHttpResponse execute( final ClassicHttpRequest request, final HttpRequestExecutor requestExecutor, final HttpContext context) throws IOException, HttpException { Args.notNull(request, "HTTP request"); Args.notNull(requestExecutor, "Request executor"); final ManagedHttpClientConnection connection = getValidatedPoolEntry().getConnection(); return requestExecutor.execute(request, connection, context); }
@Override public void upgrade(final ConnectionEndpoint endpoint, final HttpContext context) throws IOException { Args.notNull(endpoint, "Managed endpoint"); final InternalConnectionEndpoint internalEndpoint = cast(endpoint); final PoolEntry<HttpRoute, ManagedHttpClientConnection> poolEntry = internalEndpoint.getValidatedPoolEntry(); final HttpRoute route = poolEntry.getRoute(); this.connectionOperator.upgrade(poolEntry.getConnection(), route.getTargetHost(), context); }