public final class UDPNIOTransport extends NIOTransport implements SocketBinder, SocketConnectorHandler, AsyncQueueEnabledTransport, FilterChainEnabledTransport, TemporarySelectorsEnabledTransport
Modifier and Type | Class and Description |
---|---|
protected class |
UDPNIOTransport.RegisterChannelCompletionHandler |
protected class |
UDPNIOTransport.TransportConnectorHandler
Transport default
UDPNIOConnectorHandler . |
Transport.State
Modifier and Type | Field and Description |
---|---|
protected AsyncQueueIO<SocketAddress> |
asyncQueueIO
Transport AsyncQueueIO
|
protected int |
connectionTimeout
Default channel connection timeout
|
protected UDPNIOTransport.RegisterChannelCompletionHandler |
registerChannelCompletionHandler |
protected boolean |
reuseAddress
The socket reuseAddress
|
protected Collection<UDPNIOServerConnection> |
serverConnections
The Server connections.
|
protected int |
serverSocketSoTimeout
The server socket time out
|
protected TemporarySelectorIO |
temporarySelectorIO
Server socket backlog.
|
nioChannelDistributor, RANDOM, selectionKeyHandler, selectorHandler, selectorProvider, selectorRunners
attributeBuilder, connectionMonitoringConfig, isBlocking, isStandalone, kernelPool, kernelPoolConfig, managedWorkerPool, memoryManager, name, processor, processorSelector, readBufferSize, readTimeout, state, strategy, threadPoolMonitoringConfig, transportMonitoringConfig, workerPoolConfig, workerThreadPool, writeBufferSize, writeTimeout
DEFAULT_READ_BUFFER_SIZE, DEFAULT_READ_TIMEOUT, DEFAULT_WRITE_TIMEOUT
Constructor and Description |
---|
UDPNIOTransport() |
UDPNIOTransport(String name) |
Modifier and Type | Method and Description |
---|---|
UDPNIOServerConnection |
bind(int port)
Binds Transport to the specific port on localhost.
|
UDPNIOServerConnection |
bind(SocketAddress socketAddress)
Binds Transport to the specific SocketAddress.
|
UDPNIOServerConnection |
bind(SocketAddress socketAddress,
int backlog)
Binds Transport to the specific SocketAddress.
|
UDPNIOServerConnection |
bind(String host,
int port)
Binds Transport to the specific host and port.
|
UDPNIOServerConnection |
bind(String host,
int port,
int backlog)
Binds Transport to the specific host and port.
|
UDPNIOServerConnection |
bind(String host,
PortRange portRange,
int backlog)
Binds Transport to the specific host, and port within a
PortRange . |
Connection |
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
|
protected void |
configureNIOConnection(UDPNIOConnection connection) |
void |
configureStandalone(boolean isStandalone) |
GrizzlyFuture<Connection> |
connect()
Creates non-connected UDP
Connection . |
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 JmxObject |
createJmxManagementObject()
Create the Transport JMX managment object.
|
void |
fireIOEvent(IOEvent ioEvent,
Connection connection,
IOEventProcessingHandler processingHandler)
Fires specific
IOEvent on the Connection |
AsyncQueueIO |
getAsyncQueueIO()
Get asynchronous queue implementation.
|
int |
getConnectionTimeout() |
Reader |
getReader(boolean isBlocking)
Get the
Reader implementation, depending on the requested mode. |
Reader |
getReader(Connection connection)
Get the
Reader to read data from the Connection . |
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 |
getWriter(boolean isBlocking)
Get the
Writer implementation, depending on the requested mode. |
Writer |
getWriter(Connection connection)
Get the
Writer to write data to the Connection . |
boolean |
isReuseAddress() |
void |
pause()
Pause UDPNIOTransport, so I/O events coming on its
UDPNIOConnection s
will not be processed. |
int |
read(UDPNIOConnection connection,
Buffer buffer) |
int |
read(UDPNIOConnection connection,
Buffer buffer,
ReadResult<Buffer,SocketAddress> currentResult) |
void |
resume()
Resume UDPNIOTransport, which has been paused before using
pause() . |
void |
setConnectionTimeout(int connectionTimeout) |
void |
setReuseAddress(boolean reuseAddress) |
void |
start()
Start UDPNIOTransport.
|
void |
stop()
Stop UDPNIOTransport.
|
void |
unbind(Connection connection)
Unbinds bound
Transport connection. |
void |
unbindAll()
Unbinds all bound
Transport connections. |
long |
write(UDPNIOConnection connection,
SocketAddress dstAddress,
WritableMessage message) |
long |
write(UDPNIOConnection connection,
SocketAddress dstAddress,
WritableMessage message,
WriteResult<WritableMessage,SocketAddress> currentResult) |
getDefaultSelectorRunnersCount, getNIOChannelDistributor, getSelectionKeyHandler, getSelectorHandler, getSelectorProvider, getSelectorRunners, getSelectorRunnersCount, notifyProbesError, notifyProbesPause, notifyProbesResume, notifyProbesStart, notifyProbesStop, notifyTransportError, setNIOChannelDistributor, setSelectionKeyHandler, setSelectorHandler, setSelectorProvider, setSelectorRunnersCount, startSelectorRunners, stopSelectorRunners
configureBlocking, 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
protected final int serverSocketSoTimeout
protected boolean reuseAddress
protected int connectionTimeout
protected final Collection<UDPNIOServerConnection> serverConnections
protected final AsyncQueueIO<SocketAddress> asyncQueueIO
protected final TemporarySelectorIO temporarySelectorIO
protected final UDPNIOTransport.RegisterChannelCompletionHandler registerChannelCompletionHandler
public UDPNIOTransport()
public UDPNIOTransport(String name)
public UDPNIOServerConnection bind(int port) throws IOException
bind
in interface SocketBinder
Connection
IOException
public UDPNIOServerConnection bind(String host, int port) throws IOException
bind
in interface SocketBinder
host
- the local host the server will bind toConnection
IOException
public UDPNIOServerConnection bind(String host, int port, int backlog) throws IOException
bind
in interface SocketBinder
host
- the local host the server will bind tobacklog
- the maximum length of the queueConnection
IOException
public UDPNIOServerConnection bind(SocketAddress socketAddress) throws IOException
bind
in interface SocketBinder
socketAddress
- the local address the server will bind toConnection
IOException
public UDPNIOServerConnection bind(SocketAddress socketAddress, int backlog) throws IOException
bind
in interface SocketBinder
socketAddress
- the local address the server will bind tobacklog
- the maximum length of the queueConnection
IOException
public Connection bindToInherited() throws IOException
SocketBinder
bindToInherited
in interface SocketBinder
Connection
IOException
public UDPNIOServerConnection bind(String host, PortRange portRange, int backlog) throws IOException
PortRange
.bind
in interface SocketBinder
host
- the local host the server will bind toportRange
- PortRange
.backlog
- the maximum length of the queueConnection
IOException
public void unbind(Connection connection) throws IOException
Transport
connection.unbind
in interface SocketBinder
connection
- Connection
IOException
public void unbindAll() throws IOException
SocketBinder
Transport
connections.unbindAll
in interface SocketBinder
IOException
public GrizzlyFuture<Connection> connect() throws IOException
Connection
.Connection
.IOException
public GrizzlyFuture<Connection> connect(String host, int port) throws IOException
Connection
, representing socket.connect
in interface SocketConnectorHandler
host
- remote host to connect to.port
- remote port to connect to.GrizzlyFuture
of connect operation, which could be used to get
resulting Connection
.IOException
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
.IOException
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
AbstractTransport
closeConnection
in class NIOTransport
IOException
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 Transport
start
in class NIOTransport
IOException
public void stop() throws IOException
State#STOPPED
- the call will be
ignored and no exception thrown.stop
in interface Transport
stop
in class AbstractTransport
IOException
public void pause() throws IOException
UDPNIOConnection
s
will not be processed. Use resume()
in order to resume UDPNIOTransport 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 Transport
pause
in class AbstractTransport
IOException
public 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 Transport
resume
in class AbstractTransport
IOException
public void configureStandalone(boolean isStandalone)
configureStandalone
in interface Transport
public Filter getTransportFilter()
FilterChainEnabledTransport
Filter
, 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 FilterChainEnabledTransport
Filter
, which is aware of Transport
specifics; knows how to read/write from/to Transport
specific Connection
s.public AsyncQueueIO getAsyncQueueIO()
AsyncQueueEnabledTransport
getAsyncQueueIO
in interface AsyncQueueEnabledTransport
public TemporarySelectorIO getTemporarySelectorIO()
getTemporarySelectorIO
in interface TemporarySelectorsEnabledTransport
public int getConnectionTimeout()
public void setConnectionTimeout(int connectionTimeout)
public boolean isReuseAddress()
public void setReuseAddress(boolean reuseAddress)
public void fireIOEvent(IOEvent ioEvent, Connection connection, IOEventProcessingHandler processingHandler)
Transport
IOEvent
on the Connection
fireIOEvent
in interface Transport
ioEvent
- I/O eventconnection
- Connection
, on which we fire the event.processingHandler
- I/O event processing handler.public Reader 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 Transport
connection
- Connection
.Reader
.public Reader getReader(boolean isBlocking)
Reader
implementation, depending on the requested mode.public Writer 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 Transport
connection
- Connection
.Writer
.public Writer getWriter(boolean isBlocking)
Writer
implementation, depending on the requested mode.public int read(UDPNIOConnection connection, Buffer buffer) throws IOException
IOException
public int read(UDPNIOConnection connection, Buffer buffer, ReadResult<Buffer,SocketAddress> currentResult) throws IOException
IOException
public long write(UDPNIOConnection connection, SocketAddress dstAddress, WritableMessage message) throws IOException
IOException
public long write(UDPNIOConnection connection, SocketAddress dstAddress, WritableMessage message, WriteResult<WritableMessage,SocketAddress> currentResult) throws IOException
IOException
protected void configureNIOConnection(UDPNIOConnection connection)
protected JmxObject createJmxManagementObject()
createJmxManagementObject
in class AbstractTransport
Copyright © 2013 Oracle Corporation. All Rights Reserved.