Class HttpAsyncRequester
- All Implemented Interfaces:
Closeable,AutoCloseable,ModalCloseable,ConnPoolControl<HttpHost>,ConnPoolStats<HttpHost>,ConnectionInitiator,IOReactor,IOReactorService
- Direct Known Subclasses:
H2AsyncRequester
- Since:
- 5.0
-
Constructor Summary
ConstructorsConstructorDescriptionHttpAsyncRequester(IOReactorConfig ioReactorConfig, IOEventHandlerFactory eventHandlerFactory, Decorator<IOSession> ioSessionDecorator, Callback<Exception> exceptionCallback, IOSessionListener sessionListener, ManagedConnPool<HttpHost, IOSession> connPool) UseAsyncRequesterBootstrapto create instances of this class.HttpAsyncRequester(IOReactorConfig ioReactorConfig, IOEventHandlerFactory eventHandlerFactory, Decorator<IOSession> ioSessionDecorator, Callback<Exception> exceptionCallback, IOSessionListener sessionListener, ManagedConnPool<HttpHost, IOSession> connPool, TlsStrategy tlsStrategy, Timeout handshakeTimeout) UseAsyncRequesterBootstrapto create instances of this class. -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidconnect(HttpHost host, Timeout timeout, Object attachment, FutureCallback<AsyncClientEndpoint> callback) connect(NamedEndpoint remoteEndpoint, SocketAddress remoteAddress, SocketAddress localAddress, Timeout timeout, Object attachment, FutureCallback<IOSession> callback) Requests a connection to a remote host.protected Future<AsyncClientEndpoint> doConnect(HttpHost host, Timeout timeout, Object attachment, FutureCallback<AsyncClientEndpoint> callback) protected voiddoTlsUpgrade(ProtocolIOSession ioSession, NamedEndpoint endpoint, FutureCallback<ProtocolIOSession> callback) voidexecute(AsyncClientExchangeHandler exchangeHandler, HandlerFactory<AsyncPushConsumer> pushHandlerFactory, Timeout timeout, HttpContext executeContext) voidexecute(AsyncClientExchangeHandler exchangeHandler, Timeout timeout, HttpContext executeContext) final <T> Future<T> execute(AsyncRequestProducer requestProducer, AsyncResponseConsumer<T> responseConsumer, HandlerFactory<AsyncPushConsumer> pushHandlerFactory, Timeout timeout, HttpContext context, FutureCallback<T> callback) final <T> Future<T> execute(AsyncRequestProducer requestProducer, AsyncResponseConsumer<T> responseConsumer, Timeout timeout, FutureCallback<T> callback) final <T> Future<T> execute(AsyncRequestProducer requestProducer, AsyncResponseConsumer<T> responseConsumer, Timeout timeout, HttpContext context, FutureCallback<T> callback) intintgetMaxPerRoute(HttpHost route) intvoidsetDefaultMaxPerRoute(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, getStatus, initiateShutdown, requestSession, start
-
Constructor Details
-
HttpAsyncRequester
@Internal public HttpAsyncRequester(IOReactorConfig ioReactorConfig, IOEventHandlerFactory eventHandlerFactory, Decorator<IOSession> ioSessionDecorator, Callback<Exception> exceptionCallback, IOSessionListener sessionListener, ManagedConnPool<HttpHost, IOSession> connPool, TlsStrategy tlsStrategy, Timeout handshakeTimeout) UseAsyncRequesterBootstrapto create instances of this class.- Since:
- 5.2
-
HttpAsyncRequester
@Internal public HttpAsyncRequester(IOReactorConfig ioReactorConfig, IOEventHandlerFactory eventHandlerFactory, Decorator<IOSession> ioSessionDecorator, Callback<Exception> exceptionCallback, IOSessionListener sessionListener, ManagedConnPool<HttpHost, IOSession> connPool) UseAsyncRequesterBootstrapto create instances of this class.
-
-
Method Details
-
getTotalStats
- Specified by:
getTotalStatsin interfaceConnPoolStats<HttpHost>
-
getStats
- 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
- Specified by:
setMaxPerRoutein interfaceConnPoolControl<HttpHost>
-
getMaxPerRoute
- Specified by:
getMaxPerRoutein interfaceConnPoolControl<HttpHost>
-
closeIdle
- Specified by:
closeIdlein interfaceConnPoolControl<HttpHost>
-
closeExpired
public void closeExpired()- Specified by:
closeExpiredin interfaceConnPoolControl<HttpHost>
-
getRoutes
- Specified by:
getRoutesin interfaceConnPoolControl<HttpHost>
-
connect
public Future<AsyncClientEndpoint> connect(HttpHost host, Timeout timeout, Object attachment, FutureCallback<AsyncClientEndpoint> callback) -
doConnect
protected Future<AsyncClientEndpoint> doConnect(HttpHost host, Timeout timeout, Object attachment, FutureCallback<AsyncClientEndpoint> callback) -
connect
-
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> Future<T> execute(AsyncRequestProducer requestProducer, AsyncResponseConsumer<T> responseConsumer, HandlerFactory<AsyncPushConsumer> pushHandlerFactory, Timeout timeout, HttpContext context, FutureCallback<T> callback) -
execute
public final <T> Future<T> execute(AsyncRequestProducer requestProducer, AsyncResponseConsumer<T> responseConsumer, Timeout timeout, HttpContext context, FutureCallback<T> callback) -
execute
public final <T> 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 Future<IOSession> connect(NamedEndpoint remoteEndpoint, SocketAddress remoteAddress, SocketAddress localAddress, Timeout timeout, 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.
-