Class HttpAsyncRequester
- java.lang.Object
-
- org.apache.hc.core5.http.impl.bootstrap.AsyncRequester
-
- org.apache.hc.core5.http.impl.bootstrap.HttpAsyncRequester
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,ModalCloseable,ConnPoolControl<HttpHost>,ConnPoolStats<HttpHost>,ConnectionInitiator,IOReactor,IOReactorService
public class HttpAsyncRequester extends AsyncRequester implements ConnPoolControl<HttpHost>
HTTP/1.1 client side message exchange initiator.- Since:
- 5.0
-
-
Constructor Summary
Constructors Constructor Description HttpAsyncRequester(IOReactorConfig ioReactorConfig, IOEventHandlerFactory eventHandlerFactory, Decorator<IOSession> ioSessionDecorator, Callback<java.lang.Exception> exceptionCallback, IOSessionListener sessionListener, ManagedConnPool<HttpHost,IOSession> connPool, TlsStrategy tlsStrategy, Timeout handshakeTimeout, IOReactorMetricsListener threadPoolListener, IOWorkerSelector workerSelector, int maxPendingCommandsPerConnection)UseAsyncRequesterBootstrapto create instances of this class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcloseExpired()voidcloseIdle(TimeValue idleTime)java.util.concurrent.Future<AsyncClientEndpoint>connect(HttpHost host, Timeout timeout)java.util.concurrent.Future<AsyncClientEndpoint>connect(HttpHost host, Timeout timeout, java.lang.Object attachment, FutureCallback<AsyncClientEndpoint> callback)java.util.concurrent.Future<IOSession>connect(NamedEndpoint remoteEndpoint, java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress, Timeout timeout, java.lang.Object attachment, FutureCallback<IOSession> callback)Requests a connection to a remote host.protected java.util.concurrent.Future<AsyncClientEndpoint>doConnect(HttpHost host, Timeout timeout, java.lang.Object attachment, FutureCallback<AsyncClientEndpoint> callback)protected voiddoTlsUpgrade(ProtocolIOSession ioSession, NamedEndpoint endpoint, FutureCallback<ProtocolIOSession> callback)voidexecute(HttpHost target, AsyncClientExchangeHandler exchangeHandler, HandlerFactory<AsyncPushConsumer> pushHandlerFactory, Timeout timeout, HttpContext executeContext)<T> java.util.concurrent.Future<T>execute(HttpHost target, AsyncRequestProducer requestProducer, AsyncResponseConsumer<T> responseConsumer, HandlerFactory<AsyncPushConsumer> pushHandlerFactory, Timeout timeout, HttpContext context, FutureCallback<T> callback)<T> java.util.concurrent.Future<T>execute(HttpHost target, AsyncRequestProducer requestProducer, AsyncResponseConsumer<T> responseConsumer, Timeout timeout, FutureCallback<T> callback)voidexecute(AsyncClientExchangeHandler exchangeHandler, HandlerFactory<AsyncPushConsumer> pushHandlerFactory, Timeout timeout, HttpContext executeContext)voidexecute(AsyncClientExchangeHandler exchangeHandler, Timeout timeout, HttpContext executeContext)<T> java.util.concurrent.Future<T>execute(AsyncRequestProducer requestProducer, AsyncResponseConsumer<T> responseConsumer, HandlerFactory<AsyncPushConsumer> pushHandlerFactory, Timeout timeout, HttpContext context, FutureCallback<T> callback)<T> java.util.concurrent.Future<T>execute(AsyncRequestProducer requestProducer, AsyncResponseConsumer<T> responseConsumer, Timeout timeout, FutureCallback<T> callback)<T> java.util.concurrent.Future<T>execute(AsyncRequestProducer requestProducer, AsyncResponseConsumer<T> responseConsumer, Timeout timeout, HttpContext context, FutureCallback<T> callback)intgetDefaultMaxPerRoute()intgetMaxPerRoute(HttpHost route)intgetMaxTotal()java.util.Set<HttpHost>getRoutes()PoolStatsgetStats(HttpHost route)PoolStatsgetTotalStats()voidsetDefaultMaxPerRoute(int max)voidsetMaxPerRoute(HttpHost route, int max)voidsetMaxTotal(int max)-
Methods inherited from class org.apache.hc.core5.http.impl.bootstrap.AsyncRequester
awaitShutdown, close, close, defaultTarget, getStatus, initiateShutdown, requestSession, start
-
-
-
-
Constructor Detail
-
HttpAsyncRequester
@Internal public HttpAsyncRequester(IOReactorConfig ioReactorConfig, IOEventHandlerFactory eventHandlerFactory, Decorator<IOSession> ioSessionDecorator, Callback<java.lang.Exception> exceptionCallback, IOSessionListener sessionListener, ManagedConnPool<HttpHost,IOSession> connPool, TlsStrategy tlsStrategy, Timeout handshakeTimeout, IOReactorMetricsListener threadPoolListener, IOWorkerSelector workerSelector, int maxPendingCommandsPerConnection)
UseAsyncRequesterBootstrapto create instances of this class.- Since:
- 5.2
-
-
Method Detail
-
getTotalStats
public PoolStats getTotalStats()
- Specified by:
getTotalStatsin interfaceConnPoolStats<HttpHost>
-
getStats
public PoolStats getStats(HttpHost route)
- Specified by:
getStatsin interfaceConnPoolStats<HttpHost>
-
setMaxTotal
public void setMaxTotal(int max)
- Specified by:
setMaxTotalin interfaceConnPoolControl<HttpHost>
-
getMaxTotal
public int getMaxTotal()
- Specified by:
getMaxTotalin interfaceConnPoolControl<HttpHost>
-
setDefaultMaxPerRoute
public void setDefaultMaxPerRoute(int max)
- Specified by:
setDefaultMaxPerRoutein interfaceConnPoolControl<HttpHost>
-
getDefaultMaxPerRoute
public int getDefaultMaxPerRoute()
- Specified by:
getDefaultMaxPerRoutein interfaceConnPoolControl<HttpHost>
-
setMaxPerRoute
public void setMaxPerRoute(HttpHost route, int max)
- Specified by:
setMaxPerRoutein interfaceConnPoolControl<HttpHost>
-
getMaxPerRoute
public int getMaxPerRoute(HttpHost route)
- Specified by:
getMaxPerRoutein interfaceConnPoolControl<HttpHost>
-
closeIdle
public void closeIdle(TimeValue idleTime)
- Specified by:
closeIdlein interfaceConnPoolControl<HttpHost>
-
closeExpired
public void closeExpired()
- Specified by:
closeExpiredin interfaceConnPoolControl<HttpHost>
-
getRoutes
public java.util.Set<HttpHost> getRoutes()
- Specified by:
getRoutesin interfaceConnPoolControl<HttpHost>
-
connect
public java.util.concurrent.Future<AsyncClientEndpoint> connect(HttpHost host, Timeout timeout, java.lang.Object attachment, FutureCallback<AsyncClientEndpoint> callback)
-
doConnect
protected java.util.concurrent.Future<AsyncClientEndpoint> doConnect(HttpHost host, Timeout timeout, java.lang.Object attachment, FutureCallback<AsyncClientEndpoint> callback)
-
connect
public java.util.concurrent.Future<AsyncClientEndpoint> connect(HttpHost host, Timeout timeout)
-
execute
public void execute(HttpHost target, AsyncClientExchangeHandler exchangeHandler, HandlerFactory<AsyncPushConsumer> pushHandlerFactory, Timeout timeout, HttpContext executeContext)
- Since:
- 5.3
-
execute
public void execute(AsyncClientExchangeHandler exchangeHandler, HandlerFactory<AsyncPushConsumer> pushHandlerFactory, Timeout timeout, HttpContext executeContext)
-
execute
public void execute(AsyncClientExchangeHandler exchangeHandler, Timeout timeout, HttpContext executeContext)
-
execute
public final <T> java.util.concurrent.Future<T> execute(HttpHost target, AsyncRequestProducer requestProducer, AsyncResponseConsumer<T> responseConsumer, HandlerFactory<AsyncPushConsumer> pushHandlerFactory, Timeout timeout, HttpContext context, FutureCallback<T> callback)
- Type Parameters:
T- The result type returned by the Future'sgetmethod.- Since:
- 5.3
-
execute
public final <T> java.util.concurrent.Future<T> execute(AsyncRequestProducer requestProducer, AsyncResponseConsumer<T> responseConsumer, HandlerFactory<AsyncPushConsumer> pushHandlerFactory, Timeout timeout, HttpContext context, FutureCallback<T> callback)
-
execute
public final <T> java.util.concurrent.Future<T> execute(AsyncRequestProducer requestProducer, AsyncResponseConsumer<T> responseConsumer, Timeout timeout, HttpContext context, FutureCallback<T> callback)
-
execute
public final <T> java.util.concurrent.Future<T> execute(HttpHost target, AsyncRequestProducer requestProducer, AsyncResponseConsumer<T> responseConsumer, Timeout timeout, FutureCallback<T> callback)
- Type Parameters:
T- The result type returned by the Future'sgetmethod.- Since:
- 5.3
-
execute
public final <T> java.util.concurrent.Future<T> execute(AsyncRequestProducer requestProducer, AsyncResponseConsumer<T> responseConsumer, Timeout timeout, FutureCallback<T> callback)
-
doTlsUpgrade
protected void doTlsUpgrade(ProtocolIOSession ioSession, NamedEndpoint endpoint, FutureCallback<ProtocolIOSession> callback)
-
connect
public final java.util.concurrent.Future<IOSession> connect(NamedEndpoint remoteEndpoint, java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress, Timeout timeout, java.lang.Object attachment, FutureCallback<IOSession> callback)
Description copied from interface:ConnectionInitiatorRequests a connection to a remote host.Opening a connection to a remote host usually tends to be a time consuming process and may take a while to complete. One can monitor and control the process of session initialization by means of the
Futureinterface.There are several parameters one can use to exert a greater control over the process of session initialization:
A non-null local socket address parameter can be used to bind the socket to a specific local address.
An attachment object can added to the new session's context upon initialization. This object can be used to pass an initial processing state to the protocol handler.
It is often desirable to be able to react to the completion of a session request asynchronously without having to wait for it, blocking the current thread of execution. One can optionally provide an implementation
FutureCallbackinstance to get notified of events related to session requests, such as request completion, cancellation, failure or timeout.- Specified by:
connectin interfaceConnectionInitiator- Parameters:
remoteEndpoint- name of the remote host.remoteAddress- remote socket address.localAddress- local socket address. Can benull, in which can the default local address and a random port will be used.timeout- connect timeout.attachment- the attachment object. Can benull.callback- interface. Can benull.- Returns:
- session request object.
-
-