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 boolean
private 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 void
Triggered to cancel pending session requests.private ListenerEndpointImpl
createEndpoint
(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.void
pause()
Suspends the I/O reactor preventing it from accepting new connections on all active endpoints.private void
processEvent
(SelectionKey key) protected void
processEvents
(int readyCount) Triggered to process I/O events registered by the mainSelector
.private void
void
resume()
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:AbstractMultiworkerIOReactor
Triggered to cancel pending session requests.Super-classes can implement this method to react to the event.
- Specified by:
cancelRequests
in classAbstractMultiworkerIOReactor
- Throws:
IOReactorException
- in case if a non-recoverable I/O error.
-
processEvents
Description copied from class:AbstractMultiworkerIOReactor
Triggered to process I/O events registered by the mainSelector
.Super-classes can implement this method to react to the event.
- Specified by:
processEvents
in 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:ListeningIOReactor
Opens 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:
listen
in interfaceListeningIOReactor
- Parameters:
address
- the socket address to listen on.- Returns:
- listener endpoint.
-
processSessionRequests
- Throws:
IOReactorException
-
getEndpoints
Description copied from interface:ListeningIOReactor
Returns a set of endpoints for this I/O reactor.- Specified by:
getEndpoints
in interfaceListeningIOReactor
- Returns:
- set of endpoints.
-
pause
Description copied from interface:ListeningIOReactor
Suspends the I/O reactor preventing it from accepting new connections on all active endpoints.- Specified by:
pause
in interfaceListeningIOReactor
- Throws:
IOException
- in case of an I/O error.
-
resume
Description copied from interface:ListeningIOReactor
Resumes the I/O reactor restoring its ability to accept incoming connections on all active endpoints.- Specified by:
resume
in interfaceListeningIOReactor
- Throws:
IOException
- in case of an I/O error.
-
DefaultListeningIOReactor(IOReactorConfig, ThreadFactory)