Package org.apache.hc.core5.reactor
Class SingleCoreListeningIOReactor
- java.lang.Object
-
- org.apache.hc.core5.reactor.AbstractSingleCoreIOReactor
-
- org.apache.hc.core5.reactor.SingleCoreListeningIOReactor
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,ModalCloseable
,ConnectionAcceptor
,IOReactor
class SingleCoreListeningIOReactor extends AbstractSingleCoreIOReactor implements ConnectionAcceptor
-
-
Field Summary
Fields Modifier and Type Field Description private Callback<ChannelEntry>
callback
private java.util.concurrent.ConcurrentMap<ListenerEndpointImpl,java.lang.Boolean>
endpoints
private java.util.concurrent.atomic.AtomicBoolean
paused
private IOReactorConfig
reactorConfig
private java.util.Queue<ListenerEndpointRequest>
requestQueue
private long
selectTimeoutMillis
-
Fields inherited from class org.apache.hc.core5.reactor.AbstractSingleCoreIOReactor
selector
-
-
Constructor Summary
Constructors Constructor Description SingleCoreListeningIOReactor(Callback<java.lang.Exception> exceptionCallback, IOReactorConfig ioReactorConfig, Callback<ChannelEntry> callback)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
doExecute()
(package private) void
doTerminate()
java.util.Set<ListenerEndpoint>
getEndpoints()
Returns a set of endpoints for this I/O reactor.java.util.concurrent.Future<ListenerEndpoint>
listen(java.net.SocketAddress address, java.lang.Object attachment, FutureCallback<ListenerEndpoint> callback)
Opens a new listener endpoint with the given socket address.java.util.concurrent.Future<ListenerEndpoint>
listen(java.net.SocketAddress address, FutureCallback<ListenerEndpoint> callback)
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(java.nio.channels.SelectionKey key)
private void
processEvents(int readyCount)
private void
processSessionRequests()
void
resume()
Resumes the I/O reactor restoring its ability to accept incoming connections on all active endpoints.-
Methods inherited from class org.apache.hc.core5.reactor.AbstractSingleCoreIOReactor
awaitShutdown, close, close, close, execute, getStatus, initiateShutdown, logException, toString
-
-
-
-
Field Detail
-
reactorConfig
private final IOReactorConfig reactorConfig
-
callback
private final Callback<ChannelEntry> callback
-
requestQueue
private final java.util.Queue<ListenerEndpointRequest> requestQueue
-
endpoints
private final java.util.concurrent.ConcurrentMap<ListenerEndpointImpl,java.lang.Boolean> endpoints
-
paused
private final java.util.concurrent.atomic.AtomicBoolean paused
-
selectTimeoutMillis
private final long selectTimeoutMillis
-
-
Constructor Detail
-
SingleCoreListeningIOReactor
SingleCoreListeningIOReactor(Callback<java.lang.Exception> exceptionCallback, IOReactorConfig ioReactorConfig, Callback<ChannelEntry> callback)
-
-
Method Detail
-
doTerminate
void doTerminate()
- Specified by:
doTerminate
in classAbstractSingleCoreIOReactor
-
doExecute
protected final void doExecute() throws java.io.IOException
- Specified by:
doExecute
in classAbstractSingleCoreIOReactor
- Throws:
java.io.IOException
-
processEvents
private void processEvents(int readyCount) throws java.io.IOException
- Throws:
java.io.IOException
-
processEvent
private void processEvent(java.nio.channels.SelectionKey key) throws java.io.IOException
- Throws:
java.io.IOException
-
listen
public java.util.concurrent.Future<ListenerEndpoint> listen(java.net.SocketAddress address, java.lang.Object attachment, FutureCallback<ListenerEndpoint> callback)
Description copied from interface:ConnectionAcceptor
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.- Specified by:
listen
in interfaceConnectionAcceptor
- Parameters:
address
- the socket address to listen on.attachment
- the attachment object.callback
- the result callback.- Returns:
- listener endpoint.
-
listen
public java.util.concurrent.Future<ListenerEndpoint> listen(java.net.SocketAddress address, FutureCallback<ListenerEndpoint> callback)
Description copied from interface:ConnectionAcceptor
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.- Specified by:
listen
in interfaceConnectionAcceptor
- Parameters:
address
- the socket address to listen on.callback
- the result callback.- Returns:
- listener endpoint.
-
processSessionRequests
private void processSessionRequests() throws java.io.IOException
- Throws:
java.io.IOException
-
getEndpoints
public java.util.Set<ListenerEndpoint> getEndpoints()
Description copied from interface:ConnectionAcceptor
Returns a set of endpoints for this I/O reactor.- Specified by:
getEndpoints
in interfaceConnectionAcceptor
- Returns:
- set of endpoints.
-
pause
public void pause() throws java.io.IOException
Description copied from interface:ConnectionAcceptor
Suspends the I/O reactor preventing it from accepting new connections on all active endpoints.- Specified by:
pause
in interfaceConnectionAcceptor
- Throws:
java.io.IOException
- in case of an I/O error.
-
resume
public void resume() throws java.io.IOException
Description copied from interface:ConnectionAcceptor
Resumes the I/O reactor restoring its ability to accept incoming connections on all active endpoints.- Specified by:
resume
in interfaceConnectionAcceptor
- Throws:
java.io.IOException
- in case of an I/O error.
-
-