public abstract class NIOTransport extends AbstractTransport implements SocketBinder, SocketConnectorHandler, TemporarySelectorsEnabledTransport, AsyncQueueEnabledTransport
Transport.State| Modifier and Type | Field and Description |
|---|---|
protected ChannelConfigurator |
channelConfigurator |
static int |
DEFAULT_CLIENT_SOCKET_SO_TIMEOUT |
static int |
DEFAULT_CONNECTION_TIMEOUT |
static boolean |
DEFAULT_OPTIMIZED_FOR_MULTIPLEXING |
static boolean |
DEFAULT_REUSE_ADDRESS |
static int |
DEFAULT_SELECTOR_RUNNER_COUNT |
static int |
DEFAULT_SERVER_SOCKET_SO_TIMEOUT |
protected NIOChannelDistributor |
nioChannelDistributor |
protected SelectionKeyHandler |
selectionKeyHandler |
protected SelectorHandler |
selectorHandler |
protected SelectorProvider |
selectorProvider |
protected SelectorRunner[] |
selectorRunners |
protected FutureImpl<Transport> |
shutdownFuture
Future to control graceful shutdown status
|
protected Set<GracefulShutdownListener> |
shutdownListeners |
protected ExecutorService |
shutdownService
ExecutorService hosting shutdown listener threads.
|
protected TemporarySelectorIO |
temporarySelectorIO |
attributeBuilder, connectionMonitoringConfig, isBlocking, isStandalone, kernelPool, kernelPoolConfig, managedWorkerPool, memoryManager, name, processor, processorSelector, readBufferSize, readTimeout, state, strategy, threadPoolMonitoringConfig, transportMonitoringConfig, workerPoolConfig, workerThreadPool, writeBufferSize, writeTimeoutDEFAULT_READ_BUFFER_SIZE, DEFAULT_READ_TIMEOUT, DEFAULT_WRITE_BUFFER_SIZE, DEFAULT_WRITE_TIMEOUT| Constructor and Description |
|---|
NIOTransport(String name) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
addShutdownListener(GracefulShutdownListener shutdownListener)
Adds a
GracefulShutdownListener which will be called when Transport.shutdown()
is called to enable graceful shutdown of transports. |
protected abstract void |
closeConnection(Connection connection)
Close the connection, managed by Transport
|
protected void |
configureNIOConnection(NIOConnection connection) |
protected ExecutorService |
createShutdownExecutorService() |
protected abstract TemporarySelectorIO |
createTemporarySelectorIO() |
protected void |
finalizeShutdown() |
ChannelConfigurator |
getChannelConfigurator() |
int |
getClientSocketSoTimeout() |
int |
getConnectionTimeout() |
protected int |
getDefaultSelectorRunnersCount() |
NIOChannelDistributor |
getNIOChannelDistributor() |
SelectionKeyHandler |
getSelectionKeyHandler() |
SelectorHandler |
getSelectorHandler() |
SelectorProvider |
getSelectorProvider()
Get the
SelectorProvider to be used by this transport. |
protected SelectorRunner[] |
getSelectorRunners() |
int |
getSelectorRunnersCount() |
int |
getServerSocketSoTimeout() |
TemporarySelectorIO |
getTemporarySelectorIO() |
boolean |
isOptimizedForMultiplexing()
Returns true, if NIOTransport is configured to use
AsyncQueueWriter, optimized to be used in connection multiplexing
mode, or false otherwise. |
boolean |
isReuseAddress() |
protected abstract void |
listen() |
protected static void |
notifyProbesError(NIOTransport transport,
Throwable error)
Notify registered
TransportProbes about the error. |
protected static void |
notifyProbesPause(NIOTransport transport)
Notify registered
TransportProbes about the pause event. |
protected static void |
notifyProbesResume(NIOTransport transport)
Notify registered
TransportProbes about the resume event. |
protected static void |
notifyProbesStart(NIOTransport transport)
Notify registered
TransportProbes about the start event. |
protected static void |
notifyProbesStop(NIOTransport transport)
Notify registered
TransportProbes about the stop event. |
void |
notifyTransportError(Throwable error)
Method gets invoked, when error occur during the Transport lifecycle.
|
void |
pause()
Pause UDPNIOTransport, so I/O events coming on its
UDPNIOConnections
will not be processed. |
void |
resume()
Resume UDPNIOTransport, which has been paused before using
pause(). |
void |
setChannelConfigurator(ChannelConfigurator channelConfigurator)
Sets the configurator responsible for initial
SelectableChannel
configuration. |
void |
setClientSocketSoTimeout(int socketTimeout) |
void |
setConnectionTimeout(int connectionTimeout) |
void |
setNIOChannelDistributor(NIOChannelDistributor nioChannelDistributor) |
void |
setOptimizedForMultiplexing(boolean optimizedForMultiplexing)
Configures NIOTransport to be optimized for specific for the
connection multiplexing usecase, when different threads will try to
write data simultaneously.
|
void |
setReuseAddress(boolean reuseAddress) |
void |
setSelectionKeyHandler(SelectionKeyHandler selectionKeyHandler) |
void |
setSelectorHandler(SelectorHandler selectorHandler) |
void |
setSelectorProvider(SelectorProvider selectorProvider)
Set the
SelectorProvider to be used by this transport. |
void |
setSelectorRunnersCount(int selectorRunnersCount)
Sets the number of
SelectorRunners used for handling
NIO events. |
void |
setServerSocketSoTimeout(int serverSocketSoTimeout) |
GrizzlyFuture<Transport> |
shutdown()
Gracefully stops the transport accepting new connections and allows
existing work to complete before finalizing the shutdown.
|
GrizzlyFuture<Transport> |
shutdown(long gracePeriod,
TimeUnit timeUnit)
Gracefully stops the transport accepting new connections and allows
existing work to complete before finalizing the shutdown.
|
void |
shutdownNow()
Forcibly stops the transport and closes all connections.
|
void |
start()
Start TCPNIOTransport.
|
protected void |
startSelectorRunners() |
protected void |
stopSelectorRunners() |
abstract void |
unbindAll()
Unbinds all bound
Transport connections. |
configureBlocking, createJmxManagementObject, getAttributeBuilder, getConnectionMonitoringConfig, getIOStrategy, getKernelThreadPool, getKernelThreadPoolConfig, getMemoryManager, getMonitoringConfig, getName, getProcessor, getProcessorSelector, getReadBufferSize, getReadTimeout, getState, getThreadPoolMonitoringConfig, getWorkerThreadPool, getWorkerThreadPoolConfig, getWriteBufferSize, getWriteTimeout, isBlocking, isPaused, isStandalone, isStopped, notifyProbesBeforePause, notifyProbesBeforeResume, notifyProbesBeforeStart, notifyProbesBeforeStop, notifyProbesConfigChanged, notifyProbesPause, notifyProbesStop, obtainProcessor, setAttributeBuilder, setIOStrategy, setKernelPool0, setKernelThreadPool, setKernelThreadPoolConfig, setMemoryManager, setName, setProcessor, setProcessorSelector, setReadBufferSize, setReadTimeout, setWorkerThreadPool, setWorkerThreadPool0, setWorkerThreadPoolConfig, setWriteBufferSize, setWriteTimeout, stopclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitbind, bind, bind, bind, bind, bind, bindToInherited, unbindconnectconnect, connect, connect, connectgetAsyncQueueIOconfigureStandalone, fireIOEvent, getReader, getReader, getWriter, getWriterpublic static final int DEFAULT_SERVER_SOCKET_SO_TIMEOUT
public static final boolean DEFAULT_REUSE_ADDRESS
public static final int DEFAULT_CLIENT_SOCKET_SO_TIMEOUT
public static final int DEFAULT_CONNECTION_TIMEOUT
public static final int DEFAULT_SELECTOR_RUNNER_COUNT
public static final boolean DEFAULT_OPTIMIZED_FOR_MULTIPLEXING
protected SelectorHandler selectorHandler
protected SelectionKeyHandler selectionKeyHandler
protected ChannelConfigurator channelConfigurator
protected SelectorRunner[] selectorRunners
protected NIOChannelDistributor nioChannelDistributor
protected SelectorProvider selectorProvider
protected final TemporarySelectorIO temporarySelectorIO
protected Set<GracefulShutdownListener> shutdownListeners
protected FutureImpl<Transport> shutdownFuture
protected ExecutorService shutdownService
public NIOTransport(String name)
public abstract void unbindAll()
SocketBinderTransport connections.unbindAll in interface SocketBinderpublic boolean addShutdownListener(GracefulShutdownListener shutdownListener)
TransportGracefulShutdownListener which will be called when Transport.shutdown()
is called to enable graceful shutdown of transports. This allows the
owner of the listener to signal that all shutdown tasks are complete and
that it's safe to finalize the termination of the transportaddShutdownListener in interface TransportshutdownListener - the GracefulShutdownListenertrue if the listener was successfully registered,
otherwise false. When this method returns false
it means one of two things: the transport is stopping or is stopped, or
the listener has already been registered.public TemporarySelectorIO getTemporarySelectorIO()
getTemporarySelectorIO in interface TemporarySelectorsEnabledTransportpublic SelectionKeyHandler getSelectionKeyHandler()
public void setSelectionKeyHandler(SelectionKeyHandler selectionKeyHandler)
public SelectorHandler getSelectorHandler()
public void setSelectorHandler(SelectorHandler selectorHandler)
public ChannelConfigurator getChannelConfigurator()
SelectableChannel
configurationpublic void setChannelConfigurator(ChannelConfigurator channelConfigurator)
SelectableChannel
configuration.channelConfigurator - ChannelConfiguratorpublic int getSelectorRunnersCount()
SelectorRunners used for handling
NIO eventspublic void setSelectorRunnersCount(int selectorRunnersCount)
SelectorRunners used for handling
NIO events.selectorRunnersCount - public SelectorProvider getSelectorProvider()
SelectorProvider to be used by this transport.SelectorProvider to be used by this transport.public void setSelectorProvider(SelectorProvider selectorProvider)
SelectorProvider to be used by this transport.selectorProvider - the SelectorProvider.public boolean isOptimizedForMultiplexing()
AsyncQueueWriter, optimized to be used in connection multiplexing
mode, or false otherwise.AsyncQueueWriter, optimized to be used in connection multiplexing
mode, or false otherwise.public void setOptimizedForMultiplexing(boolean optimizedForMultiplexing)
protected void startSelectorRunners()
throws IOException
IOExceptionprotected void stopSelectorRunners()
public NIOChannelDistributor getNIOChannelDistributor()
public void setNIOChannelDistributor(NIOChannelDistributor nioChannelDistributor)
public void notifyTransportError(Throwable error)
notifyTransportError in interface Transporterror - Throwable.protected SelectorRunner[] getSelectorRunners()
protected static void notifyProbesError(NIOTransport transport, Throwable error)
TransportProbes about the error.transport - the Transport event occurred on.protected static void notifyProbesStart(NIOTransport transport)
TransportProbes about the start event.transport - the Transport event occurred on.protected static void notifyProbesStop(NIOTransport transport)
TransportProbes about the stop event.transport - the Transport event occurred on.protected static void notifyProbesPause(NIOTransport transport)
TransportProbes about the pause event.transport - the Transport event occurred on.protected static void notifyProbesResume(NIOTransport transport)
TransportProbes about the resume event.transport - the Transport event occurred on.public void start()
throws IOException
State#STOPPED,
otherwise the call will be ignored without exception thrown and the transport
state will remain the same as it was before the method call.start in interface TransportIOExceptionpublic GrizzlyFuture<Transport> shutdown()
TransportTransport.shutdownNow() to terminate
the transport if the graceful shutdown is taking too long.shutdown in interface TransportGrizzlyFuture which will return the stopped transport.GracefulShutdownListenerpublic GrizzlyFuture<Transport> shutdown(long gracePeriod, TimeUnit timeUnit)
shutdown in interface TransportgracePeriod - the grace period for a graceful shutdown before the
transport is forcibly terminated. If gracePeriod
is zero or less, then there is no time limit for
the shutdown.timeUnit - the TimeUnit of the specified grace period.GrizzlyFuture which will return the stopped transport.public void shutdownNow()
throws IOException
shutdownNow in interface TransportIOExceptionprotected abstract void closeConnection(Connection connection) throws IOException
AbstractTransportcloseConnection in class AbstractTransportIOExceptionprotected abstract TemporarySelectorIO createTemporarySelectorIO()
protected abstract void listen()
protected int getDefaultSelectorRunnersCount()
protected void finalizeShutdown()
public void pause()
UDPNIOConnections
will not be processed. Use resume() in order to resume UDPNIOTransport processing.
The transport will be paused only if its current state is Transport.State.STARTED,
otherwise the call will be ignored without exception thrown and the transport
state will remain the same as it was before the method call.public void resume()
pause().
The transport will be resumed only if its current state is Transport.State.PAUSED,
otherwise the call will be ignored without exception thrown and the transport
state will remain the same as it was before the method call.protected void configureNIOConnection(NIOConnection connection)
public boolean isReuseAddress()
public void setReuseAddress(boolean reuseAddress)
public int getClientSocketSoTimeout()
public void setClientSocketSoTimeout(int socketTimeout)
public int getConnectionTimeout()
public void setConnectionTimeout(int connectionTimeout)
public int getServerSocketSoTimeout()
public void setServerSocketSoTimeout(int serverSocketSoTimeout)
protected ExecutorService createShutdownExecutorService()
Copyright © 2017–2019 Oracle Corporation. All rights reserved.