public final class TCPNIOTransport extends NIOTransport implements SocketBinder, SocketConnectorHandler, AsyncQueueEnabledTransport, FilterChainEnabledTransport, TemporarySelectorsEnabledTransport
Transport.StatenioChannelDistributor, RANDOM, selectionKeyHandler, selectorHandler, selectorProvider, selectorRunnersattributeBuilder, connectionMonitoringConfig, isBlocking, isStandalone, kernelPool, kernelPoolConfig, managedWorkerPool, memoryManager, name, processor, processorSelector, readBufferSize, readTimeout, state, strategy, threadPoolMonitoringConfig, transportMonitoringConfig, workerPoolConfig, workerThreadPool, writeBufferSize, writeTimeoutDEFAULT_READ_TIMEOUT, DEFAULT_WRITE_TIMEOUT| Constructor and Description |
|---|
TCPNIOTransport() |
| Modifier and Type | Method and Description |
|---|---|
TCPNIOServerConnection |
bind(int port)
Binds Transport to the specific port on localhost.
|
TCPNIOServerConnection |
bind(SocketAddress socketAddress)
Binds Transport to the specific SocketAddress.
|
TCPNIOServerConnection |
bind(SocketAddress socketAddress,
int backlog)
Binds Transport to the specific SocketAddress.
|
TCPNIOServerConnection |
bind(String host,
int port)
Binds Transport to the specific host and port.
|
TCPNIOServerConnection |
bind(String host,
int port,
int backlog)
Binds Transport to the specific host and port.
|
TCPNIOServerConnection |
bind(String host,
PortRange portRange,
int backlog)
Binds Transport to the specific host, and port within a
PortRange. |
TCPNIOServerConnection |
bindToInherited()
Binds the Transport to the channel inherited from the entity that
created this Java virtual machine.
|
protected void |
closeConnection(Connection connection)
Close the connection, managed by Transport
|
void |
configureStandalone(boolean isStandalone) |
GrizzlyFuture<Connection> |
connect(SocketAddress remoteAddress)
Creates, initializes and connects socket to the specific
SocketAddress and returns Connection, representing socket. |
void |
connect(SocketAddress remoteAddress,
CompletionHandler<Connection> completionHandler)
Creates, initializes and connects socket to the specific
SocketAddress and returns Connection, representing socket. |
GrizzlyFuture<Connection> |
connect(SocketAddress remoteAddress,
SocketAddress localAddress)
Creates, initializes socket, binds it to the specific local and remote
SocketAddress and returns Connection, representing socket. |
void |
connect(SocketAddress remoteAddress,
SocketAddress localAddress,
CompletionHandler<Connection> completionHandler)
Creates, initializes socket, binds it to the specific local and remote
SocketAddress and returns Connection, representing socket. |
GrizzlyFuture<Connection> |
connect(String host,
int port)
Creates, initializes and connects socket to the specific remote host
and port and returns
Connection, representing socket. |
protected Object |
createJmxManagementObject()
Create the Transport JMX management object.
|
void |
fireIOEvent(IOEvent ioEvent,
Connection connection,
IOEventProcessingHandler processingHandler)
Fires specific
IOEvent on the Connection |
AsyncQueueIO<SocketAddress> |
getAsyncQueueIO()
Get asynchronous queue implementation.
|
int |
getClientSocketSoTimeout() |
int |
getConnectionTimeout() |
protected int |
getDefaultSelectorRunnersCount() |
int |
getLinger() |
Reader<SocketAddress> |
getReader(boolean isBlocking)
Get the
Reader implementation, depending on the requested mode. |
Reader<SocketAddress> |
getReader(Connection connection)
Get the
Reader to read data from the Connection. |
int |
getServerConnectionBackLog()
Get the default server connection backlog size.
|
int |
getServerSocketSoTimeout() |
TemporarySelectorIO |
getTemporarySelectorIO() |
Filter |
getTransportFilter()
Get transport
Filter, which is aware of Transport
specifics; knows how to read/write from/to Transport
specific Connection streams. |
Writer<SocketAddress> |
getWriter(boolean isBlocking)
Get the
Writer implementation, depending on the requested mode. |
Writer<SocketAddress> |
getWriter(Connection connection)
Get the
Writer to write data to the Connection. |
boolean |
isKeepAlive() |
boolean |
isOptimizedForMultiplexing()
Returns true, if TCPNIOTransport is configured to use
AsyncQueueWriter, optimized to be used in connection multiplexing
mode, or false otherwise. |
boolean |
isReuseAddress() |
boolean |
isTcpNoDelay() |
void |
pause()
Pause TCPNIOTransport, so I/O events coming on its
TCPNIOConnections
will not be processed. |
Buffer |
read(Connection connection,
Buffer buffer) |
void |
resume()
Resume TCPNIOTransport, which has been paused before using
pause(). |
void |
setClientSocketSoTimeout(int socketTimeout) |
void |
setConnectionTimeout(int connectionTimeout) |
void |
setKeepAlive(boolean isKeepAlive) |
void |
setLinger(int linger) |
void |
setOptimizedForMultiplexing(boolean isOptimizedForMultiplexing)
Configures TCPNIOTransport to be optimized for specific for the
connection multiplexing usecase, when different threads will try to
write data simultaneously.
|
void |
setReuseAddress(boolean reuseAddress) |
void |
setServerConnectionBackLog(int serverConnectionBackLog)
Set the default server connection backlog size.
|
void |
setServerSocketSoTimeout(int serverSocketSoTimeout) |
void |
setTcpNoDelay(boolean tcpNoDelay) |
void |
start()
Start TCPNIOTransport.
|
void |
stop()
Stop TCPNIOTransport.
|
void |
unbind(Connection connection)
Unbinds bound
Transport connection. |
void |
unbindAll()
Unbinds all bound
Transport connections. |
int |
write(TCPNIOConnection connection,
WritableMessage message) |
int |
write(TCPNIOConnection connection,
WritableMessage message,
WriteResult currentResult) |
getNIOChannelDistributor, getSelectionKeyHandler, getSelectorHandler, getSelectorProvider, getSelectorRunners, getSelectorRunnersCount, notifyProbesError, notifyProbesPause, notifyProbesResume, notifyProbesStart, notifyProbesStop, notifyTransportError, setNIOChannelDistributor, setSelectionKeyHandler, setSelectorHandler, setSelectorProvider, setSelectorRunnersCount, startSelectorRunners, stopSelectorRunnersconfigureBlocking, 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, setWriteTimeoutpublic 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 Transportstart in class NIOTransportIOExceptionprotected int getDefaultSelectorRunnersCount()
getDefaultSelectorRunnersCount in class NIOTransportpublic void stop()
throws IOException
State#STOPPED - the call will be
ignored and no exception thrown.stop in interface Transportstop in class AbstractTransportIOExceptionpublic void pause()
throws IOException
TCPNIOConnections
will not be processed. Use resume() in order to resume TCPNIOTransport processing.
The transport will be paused only if its current state is 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.pause in interface Transportpause in class AbstractTransportIOExceptionpublic void resume()
throws IOException
pause().
The transport will be resumed only if its current state is 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.resume in interface Transportresume in class AbstractTransportIOExceptionpublic TCPNIOServerConnection bind(int port) throws IOException
bind in interface SocketBinderConnectionIOExceptionpublic TCPNIOServerConnection bind(String host, int port) throws IOException
bind in interface SocketBinderhost - the local host the server will bind toConnectionIOExceptionpublic TCPNIOServerConnection bind(String host, int port, int backlog) throws IOException
bind in interface SocketBinderhost - the local host the server will bind tobacklog - the maximum length of the queueConnectionIOExceptionpublic TCPNIOServerConnection bind(SocketAddress socketAddress) throws IOException
bind in interface SocketBindersocketAddress - the local address the server will bind toConnectionIOExceptionpublic TCPNIOServerConnection bind(SocketAddress socketAddress, int backlog) throws IOException
bind in interface SocketBindersocketAddress - the local address the server will bind tobacklog - the maximum length of the queueConnectionIOExceptionpublic TCPNIOServerConnection bindToInherited() throws IOException
bindToInherited in interface SocketBinderConnectionIOExceptionpublic TCPNIOServerConnection bind(String host, PortRange portRange, int backlog) throws IOException
PortRange.bind in interface SocketBinderhost - the local host the server will bind toportRange - PortRange.backlog - the maximum length of the queueConnectionIOExceptionpublic void unbind(Connection connection) throws IOException
Transport connection.unbind in interface SocketBinderconnection - ConnectionIOExceptionpublic void unbindAll()
throws IOException
SocketBinderTransport connections.unbindAll in interface SocketBinderIOExceptionpublic GrizzlyFuture<Connection> connect(String host, int port)
Connection, representing socket.connect in interface SocketConnectorHandlerhost - remote host to connect to.port - remote port to connect to.GrizzlyFuture of connect operation, which could be used to get
resulting Connection.public GrizzlyFuture<Connection> connect(SocketAddress remoteAddress)
SocketAddress and returns Connection, representing socket.connect in interface ConnectorHandler<SocketAddress>remoteAddress - remote address to connect to.GrizzlyFuture of connect operation, which could be used to get
resulting Connection.public void connect(SocketAddress remoteAddress, CompletionHandler<Connection> completionHandler)
SocketAddress and returns Connection, representing socket.connect in interface ConnectorHandler<SocketAddress>remoteAddress - remote address to connect to.completionHandler - CompletionHandler.public GrizzlyFuture<Connection> connect(SocketAddress remoteAddress, SocketAddress localAddress)
SocketAddress and returns Connection, representing socket.connect in interface ConnectorHandler<SocketAddress>remoteAddress - remote address to connect to.localAddress - local address to bind socket to.GrizzlyFuture of connect operation, which could be used to get
resulting Connection.public void connect(SocketAddress remoteAddress, SocketAddress localAddress, CompletionHandler<Connection> completionHandler)
SocketAddress and returns Connection, representing socket.connect in interface ConnectorHandler<SocketAddress>remoteAddress - remote address to connect to.localAddress - local address to bind socket to.completionHandler - CompletionHandler.protected void closeConnection(Connection connection) throws IOException
AbstractTransportcloseConnection in class NIOTransportIOExceptionpublic AsyncQueueIO<SocketAddress> getAsyncQueueIO()
AsyncQueueEnabledTransportgetAsyncQueueIO in interface AsyncQueueEnabledTransportpublic void configureStandalone(boolean isStandalone)
configureStandalone in interface Transportpublic int getLinger()
public void setLinger(int linger)
public int getServerConnectionBackLog()
public void setServerConnectionBackLog(int serverConnectionBackLog)
serverConnectionBackLog - the default server connection backlog size.public boolean isKeepAlive()
public void setKeepAlive(boolean isKeepAlive)
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 boolean isTcpNoDelay()
public void setTcpNoDelay(boolean tcpNoDelay)
public int getServerSocketSoTimeout()
public void setServerSocketSoTimeout(int serverSocketSoTimeout)
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 isOptimizedForMultiplexing)
public Filter getTransportFilter()
FilterChainEnabledTransportFilter, which is aware of Transport
specifics; knows how to read/write from/to Transport
specific Connection streams.
Each Transport should provide transport Filter
implementation.getTransportFilter in interface FilterChainEnabledTransportFilter, which is aware of Transport
specifics; knows how to read/write from/to Transport
specific Connections.public TemporarySelectorIO getTemporarySelectorIO()
getTemporarySelectorIO in interface TemporarySelectorsEnabledTransportpublic void fireIOEvent(IOEvent ioEvent, Connection connection, IOEventProcessingHandler processingHandler)
TransportIOEvent on the ConnectionfireIOEvent in interface TransportioEvent - I/O eventconnection - Connection, on which we fire the event.processingHandler - I/O event processing handler.public Reader<SocketAddress> getReader(Connection connection)
Reader to read data from the Connection.
The Transport may decide to return blocking or non-blocking Reader
depending on the Connection settings.getReader in interface Transportconnection - Connection.Reader.public Reader<SocketAddress> getReader(boolean isBlocking)
Reader implementation, depending on the requested mode.public Writer<SocketAddress> getWriter(Connection connection)
Writer to write data to the Connection.
The Transport may decide to return blocking or non-blocking Writer
depending on the Connection settings.getWriter in interface Transportconnection - Connection.Writer.public Writer<SocketAddress> getWriter(boolean isBlocking)
Writer implementation, depending on the requested mode.public Buffer read(Connection connection, Buffer buffer) throws IOException
IOExceptionpublic int write(TCPNIOConnection connection, WritableMessage message) throws IOException
IOExceptionpublic int write(TCPNIOConnection connection, WritableMessage message, WriteResult currentResult) throws IOException
IOExceptionprotected Object createJmxManagementObject()
createJmxManagementObject in class AbstractTransportCopyright © 2013 Oracle Corporation. All Rights Reserved.