@Override public void cancelled() { try { this.connPool.release(this.poolEntry, false); } finally { this.future.cancel(true); } }
/** * Initiates asynchronous HTTP request execution. * * @param <T> the result type of request execution. * @param <E> the connection pool entry type. * @param requestProducer request producer. * @param responseConsumer response consumer. * @param connPool pool of persistent reusable connections. * @param context HTTP context * @param callback future callback. * @return future representing pending completion of the operation. */ public <T, E extends PoolEntry<HttpHost, NHttpClientConnection>> Future<T> execute( final HttpAsyncRequestProducer requestProducer, final HttpAsyncResponseConsumer<T> responseConsumer, final ConnPool<HttpHost, E> connPool, final HttpContext context, final FutureCallback<T> callback) { Args.notNull(requestProducer, "HTTP request producer"); Args.notNull(responseConsumer, "HTTP response consumer"); Args.notNull(connPool, "HTTP connection pool"); Args.notNull(context, "HTTP context"); final BasicFuture<T> future = new BasicFuture<T>(callback); final HttpHost target = requestProducer.getTarget(); connPool.lease(target, null, new ConnRequestCallback<T, E>( future, requestProducer, responseConsumer, connPool, context)); return future; }
/** * Initiates asynchronous HTTP request execution. * * @param <T> the result type of request execution. * @param <E> the connection pool entry type. * @param requestProducer request producer. * @param responseConsumer response consumer. * @param connPool pool of persistent reusable connections. * @param context HTTP context * @param callback future callback. * @return future representing pending completion of the operation. */ public <T, E extends PoolEntry<HttpHost, NHttpClientConnection>> Future<T> execute( final HttpAsyncRequestProducer requestProducer, final HttpAsyncResponseConsumer<T> responseConsumer, final ConnPool<HttpHost, E> connPool, final HttpContext context, final FutureCallback<T> callback) { Args.notNull(requestProducer, "HTTP request producer"); Args.notNull(responseConsumer, "HTTP response consumer"); Args.notNull(connPool, "HTTP connection pool"); Args.notNull(context, "HTTP context"); final BasicFuture<T> future = new BasicFuture<T>(callback); final HttpHost target = requestProducer.getTarget(); connPool.lease(target, null, new ConnRequestCallback<T, E>( future, requestProducer, responseConsumer, connPool, context)); return future; }
@Override public void cancelled() { try { this.connPool.release(this.poolEntry, false); } finally { this.future.cancel(true); } }
Args.notNull(context, "HTTP context"); final BasicFuture<List<T>> future = new BasicFuture<List<T>>(callback); connPool.lease(target, null, new ConnPipelinedRequestCallback<T, E>( future, requestProducers, responseConsumers, connPool, context)); return future;
@Override public void completed(final T result) { try { this.connPool.release(this.poolEntry, true); } finally { this.future.completed(result); } }
Args.notNull(context, "HTTP context"); final BasicFuture<List<T>> future = new BasicFuture<List<T>>(callback); connPool.lease(target, null, new ConnPipelinedRequestCallback<T, E>( future, requestProducers, responseConsumers, connPool, context)); return future;
@Override public void failed(final Exception ex) { try { this.connPool.release(this.poolEntry, false); } finally { this.future.failed(ex); } }
@Override public void failed(final Exception ex) { try { this.connPool.release(this.poolEntry, false); } finally { this.future.failed(ex); } }
@Override public void completed(final T result) { try { this.connPool.release(this.poolEntry, true); } finally { this.future.completed(result); } }
@Override public void completed(final E result) { if (this.requestFuture.isDone()) { this.connPool.release(result, true); return; } final NHttpClientConnection conn = result.getConnection(); final BasicAsyncClientExchangeHandler<T> handler = new BasicAsyncClientExchangeHandler<T>( this.requestProducer, this.responseConsumer, new RequestExecutionCallback<T, E>(this.requestFuture, result, this.connPool), this.context, conn, httpprocessor, connReuseStrategy); initExecution(handler, conn); }
@Override public void completed(final E result) { if (this.requestFuture.isDone()) { this.connPool.release(result, true); return; } final NHttpClientConnection conn = result.getConnection(); final PipeliningClientExchangeHandler<T> handler = new PipeliningClientExchangeHandler<T>( this.requestProducers, this.responseConsumers, new RequestExecutionCallback<List<T>, E>(this.requestFuture, result, this.connPool), this.context, conn, httpprocessor, connReuseStrategy); initExecution(handler, conn); }
@Override public void completed(final E result) { if (this.requestFuture.isDone()) { this.connPool.release(result, true); return; } final NHttpClientConnection conn = result.getConnection(); final PipeliningClientExchangeHandler<T> handler = new PipeliningClientExchangeHandler<T>( this.requestProducers, this.responseConsumers, new RequestExecutionCallback<List<T>, E>(this.requestFuture, result, this.connPool), this.context, conn, httpprocessor, connReuseStrategy); initExecution(handler, conn); }
@Override public void completed(final E result) { if (this.requestFuture.isDone()) { this.connPool.release(result, true); return; } final NHttpClientConnection conn = result.getConnection(); final BasicAsyncClientExchangeHandler<T> handler = new BasicAsyncClientExchangeHandler<T>( this.requestProducer, this.responseConsumer, new RequestExecutionCallback<T, E>(this.requestFuture, result, this.connPool), this.context, conn, httpprocessor, connReuseStrategy); initExecution(handler, conn); }