Package org.apache.http.impl.nio.reactor
Class AbstractIOReactor
- java.lang.Object
-
- org.apache.http.impl.nio.reactor.AbstractIOReactor
-
- All Implemented Interfaces:
IOReactor
- Direct Known Subclasses:
BaseIOReactor
public abstract class AbstractIOReactor extends java.lang.Object implements IOReactor
Generic implementation ofIOReactor
that can used as a subclass for more specialized I/O reactors. It is based on a singleSelector
instance.- Since:
- 4.0
-
-
Constructor Summary
Constructors Constructor Description AbstractIOReactor(long selectTimeout)
Creates new AbstractIOReactor instance.AbstractIOReactor(long selectTimeout, boolean interestOpsQueueing)
Creates new AbstractIOReactor instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addChannel(ChannelEntry channelEntry)
Adds new channel entry.void
awaitShutdown(long timeout)
Blocks for the given period of time in milliseconds awaiting the completion of the reactor shutdown.boolean
getInterestOpsQueueing()
Returnstrue
if interest Ops queueing is enabled,false
otherwise.IOReactorStatus
getStatus()
Returns the current status of the reactor.void
gracefulShutdown()
Attempts graceful shutdown of this I/O reactor.void
hardShutdown()
Attempts force-shutdown of this I/O reactor.void
shutdown()
Initiates shutdown of the reactor and blocks for a default period of time waiting for the reactor to terminate all active connections, to shut down itself and to release system resources it currently holds.void
shutdown(long gracePeriod)
Initiates shutdown of the reactor and blocks approximately for the given period of time in milliseconds waiting for the reactor to terminate all active connections, to shut down itself and to release system resources it currently holds.
-
-
-
Constructor Detail
-
AbstractIOReactor
public AbstractIOReactor(long selectTimeout) throws IOReactorException
Creates new AbstractIOReactor instance.- Parameters:
selectTimeout
- the select timeout.- Throws:
IOReactorException
- in case if a non-recoverable I/O error.
-
AbstractIOReactor
public AbstractIOReactor(long selectTimeout, boolean interestOpsQueueing) throws IOReactorException
Creates new AbstractIOReactor instance.- Parameters:
selectTimeout
- the select timeout.interestOpsQueueing
- Ops queueing flag.- Throws:
IOReactorException
- in case if a non-recoverable I/O error.- Since:
- 4.1
-
-
Method Detail
-
getStatus
public IOReactorStatus getStatus()
Description copied from interface:IOReactor
Returns the current status of the reactor.
-
getInterestOpsQueueing
public boolean getInterestOpsQueueing()
Returnstrue
if interest Ops queueing is enabled,false
otherwise.- Since:
- 4.1
-
addChannel
public void addChannel(ChannelEntry channelEntry)
Adds new channel entry. The channel will be asynchronously registered with the selector.- Parameters:
channelEntry
- the channel entry.
-
gracefulShutdown
public void gracefulShutdown()
Attempts graceful shutdown of this I/O reactor.
-
hardShutdown
public void hardShutdown() throws IOReactorException
Attempts force-shutdown of this I/O reactor.- Throws:
IOReactorException
-
awaitShutdown
public void awaitShutdown(long timeout) throws java.lang.InterruptedException
Blocks for the given period of time in milliseconds awaiting the completion of the reactor shutdown.- Parameters:
timeout
- the maximum wait time.- Throws:
java.lang.InterruptedException
- if interrupted.
-
shutdown
public void shutdown(long gracePeriod) throws IOReactorException
Description copied from interface:IOReactor
Initiates shutdown of the reactor and blocks approximately for the given period of time in milliseconds waiting for the reactor to terminate all active connections, to shut down itself and to release system resources it currently holds.- Specified by:
shutdown
in interfaceIOReactor
- Parameters:
gracePeriod
- wait time in milliseconds.- Throws:
IOReactorException
-
shutdown
public void shutdown() throws IOReactorException
Description copied from interface:IOReactor
Initiates shutdown of the reactor and blocks for a default period of time waiting for the reactor to terminate all active connections, to shut down itself and to release system resources it currently holds. It is up to individual implementations to decide for how long this method can remain blocked.- Specified by:
shutdown
in interfaceIOReactor
- Throws:
IOReactorException
-
-