Package org.apache.http.impl.nio.reactor
Class DefaultListeningIOReactor
java.lang.Object
org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor
org.apache.http.impl.nio.reactor.DefaultListeningIOReactor
- All Implemented Interfaces:
IOReactor,ListeningIOReactor
public class DefaultListeningIOReactor
extends AbstractMultiworkerIOReactor
implements ListeningIOReactor
Default implementation of
ListeningIOReactor. This class extends
AbstractMultiworkerIOReactor with capability to listen for incoming
connections.- Since:
- 4.0
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor
AbstractMultiworkerIOReactor.DefaultThreadFactory, AbstractMultiworkerIOReactor.Worker -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Set<ListenerEndpointImpl>private booleanprivate final Set<SocketAddress>private final Queue<ListenerEndpointImpl>Fields inherited from class org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor
auditLog, config, exceptionHandler, interestOpsQueueing, params, selector, selectTimeout, status -
Constructor Summary
ConstructorsConstructorDescriptionCreates an instance of DefaultListeningIOReactor with default configuration.DefaultListeningIOReactor(int workerCount, ThreadFactory threadFactory, HttpParams params) Deprecated.DefaultListeningIOReactor(int workerCount, HttpParams params) Deprecated.Creates an instance of DefaultListeningIOReactor with the given configuration.DefaultListeningIOReactor(IOReactorConfig config, ThreadFactory threadFactory) Creates an instance of DefaultListeningIOReactor with the given configuration. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidTriggered to cancel pending session requests.private ListenerEndpointImplcreateEndpoint(SocketAddress address) Returns a set of endpoints for this I/O reactor.listen(SocketAddress address) Opens a new listener endpoint with the given socket address.voidpause()Suspends the I/O reactor preventing it from accepting new connections on all active endpoints.private voidprocessEvent(SelectionKey key) protected voidprocessEvents(int readyCount) Triggered to process I/O events registered by the mainSelector.private voidvoidresume()Resumes the I/O reactor restoring its ability to accept incoming connections on all active endpoints.Methods inherited from class org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor
addChannel, addExceptionEvent, addExceptionEvent, awaitShutdown, closeChannel, convert, doShutdown, execute, getAuditLog, getStatus, prepareSocket, registerChannel, setExceptionHandler, shutdown, shutdown
-
Field Details
-
requestQueue
-
endpoints
-
pausedEndpoints
-
paused
private volatile boolean paused
-
-
Constructor Details
-
DefaultListeningIOReactor
public DefaultListeningIOReactor(IOReactorConfig config, ThreadFactory threadFactory) throws IOReactorException Creates an instance of DefaultListeningIOReactor with the given configuration.- Parameters:
config- I/O reactor configuration.threadFactory- the factory to create threads. Can benull.- Throws:
IOReactorException- in case if a non-recoverable I/O error.- Since:
- 4.2
-
DefaultListeningIOReactor
Creates an instance of DefaultListeningIOReactor with the given configuration.- Parameters:
config- I/O reactor configuration. Can benull.- Throws:
IOReactorException- in case if a non-recoverable I/O error.- Since:
- 4.2
-
DefaultListeningIOReactor
Creates an instance of DefaultListeningIOReactor with default configuration.- Throws:
IOReactorException- in case if a non-recoverable I/O error.- Since:
- 4.2
-
DefaultListeningIOReactor
@Deprecated public DefaultListeningIOReactor(int workerCount, ThreadFactory threadFactory, HttpParams params) throws IOReactorException Deprecated.- Throws:
IOReactorException
-
DefaultListeningIOReactor
@Deprecated public DefaultListeningIOReactor(int workerCount, HttpParams params) throws IOReactorException Deprecated.- Throws:
IOReactorException
-
-
Method Details
-
cancelRequests
Description copied from class:AbstractMultiworkerIOReactorTriggered to cancel pending session requests.Super-classes can implement this method to react to the event.
- Specified by:
cancelRequestsin classAbstractMultiworkerIOReactor- Throws:
IOReactorException- in case if a non-recoverable I/O error.
-
processEvents
Description copied from class:AbstractMultiworkerIOReactorTriggered to process I/O events registered by the mainSelector.Super-classes can implement this method to react to the event.
- Specified by:
processEventsin classAbstractMultiworkerIOReactor- Parameters:
readyCount- event count.- Throws:
IOReactorException- in case if a non-recoverable I/O error.
-
processEvent
- Throws:
IOReactorException
-
createEndpoint
-
listen
Description copied from interface:ListeningIOReactorOpens a new listener endpoint with the given socket address. Once the endpoint is fully initialized it starts accepting incoming connections and propagates I/O activity notifications to the I/O event dispatcher.ListenerEndpoint.waitFor()can be used to wait for the listener to be come ready to accept incoming connections.ListenerEndpoint.close()can be used to shut down the listener even before it is fully initialized.- Specified by:
listenin interfaceListeningIOReactor- Parameters:
address- the socket address to listen on.- Returns:
- listener endpoint.
-
processSessionRequests
- Throws:
IOReactorException
-
getEndpoints
Description copied from interface:ListeningIOReactorReturns a set of endpoints for this I/O reactor.- Specified by:
getEndpointsin interfaceListeningIOReactor- Returns:
- set of endpoints.
-
pause
Description copied from interface:ListeningIOReactorSuspends the I/O reactor preventing it from accepting new connections on all active endpoints.- Specified by:
pausein interfaceListeningIOReactor- Throws:
IOException- in case of an I/O error.
-
resume
Description copied from interface:ListeningIOReactorResumes the I/O reactor restoring its ability to accept incoming connections on all active endpoints.- Specified by:
resumein interfaceListeningIOReactor- Throws:
IOException- in case of an I/O error.
-
DefaultListeningIOReactor(IOReactorConfig, ThreadFactory)