public interface Transport extends MonitoringAware<TransportProbe>
| Modifier and Type | Interface and Description |
|---|---|
static class |
Transport.State |
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_READ_BUFFER_SIZE
The default read buffer size.
|
static int |
DEFAULT_READ_TIMEOUT
Default read timeout in seconds.
|
static int |
DEFAULT_WRITE_BUFFER_SIZE
The default write buffer size.
|
static int |
DEFAULT_WRITE_TIMEOUT
Default write timeout in seconds.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
addShutdownListener(GracefulShutdownListener shutdownListener)
Adds a
GracefulShutdownListener which will be called when shutdown() is called to enable graceful
shutdown of transports. |
void |
configureBlocking(boolean isBlocking)
Sets the
Transport mode. |
void |
configureStandalone(boolean isStandalone) |
void |
fireIOEvent(IOEvent ioEvent,
Connection connection,
IOEventLifeCycleListener listener)
Fires specific
IOEvent on the Connection |
AttributeBuilder |
getAttributeBuilder()
Get
Transport associated AttributeBuilder, which will be used by Transport and its
Connections to store custom Attributes. |
MonitoringConfig<ConnectionProbe> |
getConnectionMonitoringConfig()
Get the monitoring configuration for Transport
Connections. |
IOStrategy |
getIOStrategy()
|
ExecutorService |
getKernelThreadPool() |
ThreadPoolConfig |
getKernelThreadPoolConfig() |
MemoryManager |
getMemoryManager()
Get the
Transport associated MemoryManager, which will be used by the Transport, its
Connections and by during processing I/O events, occurred on Connections. |
MonitoringConfig<TransportProbe> |
getMonitoringConfig()
Get the Transport monitoring configuration
MonitoringConfig. |
String |
getName()
Gets the
Transport name. |
Processor |
getProcessor()
Gets the default
Processor, which will process Connection I/O events in case, if Connection
doesn't have own Processor preferences. |
ProcessorSelector |
getProcessorSelector()
Gets the default
ProcessorSelector, which will be used to get Processor to process Connection
I/O events, in case if this Transport's Processor is null and Connection doesn't
have neither preferred Processor nor ProcessorSelector. |
int |
getReadBufferSize()
Get the default size of
Buffers, which will be allocated for reading data from Transport's
Connections. |
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. |
long |
getReadTimeout(TimeUnit timeUnit)
Returns the current value for the blocking read timeout converted to the provided
TimeUnit specification. |
StateHolder<Transport.State> |
getState()
Return the
Transport state controller. |
MonitoringConfig<ThreadPoolProbe> |
getThreadPoolMonitoringConfig()
Get the monitoring configuration for Transport thread pool.
|
ExecutorService |
getWorkerThreadPool()
Get a thread pool, which will run IOEvent processing (depending on Transport
IOStrategy) to let kernel
threads continue their job. |
ThreadPoolConfig |
getWorkerThreadPoolConfig() |
int |
getWriteBufferSize()
Get the default size of
Buffers, which will be allocated for writing data to Transport's
Connections. |
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. |
long |
getWriteTimeout(TimeUnit timeUnit)
Returns the current value for the blocking write timeout converted to the provided
TimeUnit specification. |
boolean |
isBlocking()
Returns the
Transport mode. |
boolean |
isPaused() |
boolean |
isStandalone() |
boolean |
isStopped()
Returns true, if this Transport is in stopped state, false otherwise.
|
void |
notifyTransportError(Throwable error)
Method gets invoked, when error occur during the Transport lifecycle.
|
Processor |
obtainProcessor(IOEvent ioEvent,
Connection connection)
Gets the default
Processor, which will process Transport Connections I/O events in case, if
Connection doesn't have own Processor preferences. |
void |
pause()
Pauses the transport
|
void |
resume()
Resumes the transport after a pause
|
void |
setAttributeBuilder(AttributeBuilder attributeBuilder)
Set
Transport associated AttributeBuilder, which will be used by Transport and its
Connections to store custom Attributes. |
void |
setIOStrategy(IOStrategy IOStrategy)
|
void |
setKernelThreadPool(ExecutorService threadPool)
Set a thread pool which will run Transport internal tasks.
|
void |
setKernelThreadPoolConfig(ThreadPoolConfig kernelConfig)
Set the
ThreadPoolConfig to be used by the Transport internal thread pool. |
void |
setMemoryManager(MemoryManager memoryManager)
Set the
Transport associated MemoryManager, which will be used by the Transport, its
Connections and by during processing I/O events, occurred on Connections. |
void |
setName(String name)
Sets the
Transport name. |
void |
setProcessor(Processor processor)
Sets the default
Processor, which will process Connection I/O events in case, if Connection
doesn't have own Processor preferences. |
void |
setProcessorSelector(ProcessorSelector selector)
Sets the default
ProcessorSelector, which will be used to get Processor to process Connection
I/O events, in case if this Transport's Processor is null and Connection doesn't
have neither preferred Processor nor ProcessorSelector. |
void |
setReadBufferSize(int readBufferSize)
Set the default size of
Buffers, which will be allocated for reading data from Transport's
Connections. |
void |
setReadTimeout(long timeout,
TimeUnit timeUnit)
Specifies the timeout for the blocking reads.
|
void |
setWorkerThreadPool(ExecutorService threadPool)
Set a thread pool, which will run IOEvent processing (depending on Transport
IOStrategy) to let kernel
threads continue their job. |
void |
setWorkerThreadPoolConfig(ThreadPoolConfig workerConfig)
Set the
ThreadPoolConfig to be used by the worker thread pool. |
void |
setWriteBufferSize(int writeBufferSize)
Set the default size of
Buffers, which will be allocated for writing data to Transport's
Connections. |
void |
setWriteTimeout(long timeout,
TimeUnit timeUnit)
Specifies the timeout for the blocking writes.
|
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()
Starts the transport
|
void |
stop()
Deprecated.
Use
shutdownNow(). |
static final int DEFAULT_READ_BUFFER_SIZE
static final int DEFAULT_WRITE_BUFFER_SIZE
static final int DEFAULT_READ_TIMEOUT
static final int DEFAULT_WRITE_TIMEOUT
StateHolder<Transport.State> getState()
Transport state controller. Using the state controller, it is possible to get/set the
Transport state in thread-safe manner.StateHolder state controller.boolean isBlocking()
Transport mode. true, if Transport is operating in blocking mode, or
false otherwise. Specific Transport Connections may override this setting by
Connection.isBlocking().void configureBlocking(boolean isBlocking)
Transport mode. Specific Transport Connections may override this setting by
Connection.configureBlocking(boolean).void configureStandalone(boolean isStandalone)
boolean isStandalone()
Processor obtainProcessor(IOEvent ioEvent, Connection connection)
Processor, which will process Transport Connections I/O events in case, if
Connection doesn't have own Processor preferences. If Transport associated Processor
is null, and Connection doesn't have any preferred Processor - then Transport will
try to get Processor using ProcessorSelector.select(IOEvent, Connection).ioEvent - the type of events the Processor should handleconnection - connection to obtain Processor forProcessor, which will process Connection I/O events, if one doesn't have own
Processor preferences.Processor getProcessor()
Processor, which will process Connection I/O events in case, if Connection
doesn't have own Processor preferences. If Transport associated Processor is null,
and Connection doesn't have any preferred Processor - then Transport will try to get
Processor using ProcessorSelector.select(IOEvent, Connection).Processor, which will process Connection I/O events, if one doesn't have own
Processor preferences.void setProcessor(Processor processor)
Processor, which will process Connection I/O events in case, if Connection
doesn't have own Processor preferences.processor - the default Processor, which will process Connection I/O events, if one doesn't have
own Processor preferences.ProcessorSelector getProcessorSelector()
ProcessorSelector, which will be used to get Processor to process Connection
I/O events, in case if this Transport's Processor is null and Connection doesn't
have neither preferred Processor nor ProcessorSelector.
Transport's ProcessorSelector is the last place, where Transport will try to get
Processor to process Connection I/O event. If ProcessorSelector is not set -
IllegalStateException will be thrown.ProcessorSelector, which will be used to get Processor to process
Connection I/O events, in case if this Transport's Processor is null and
Connection doesn't have neither preferred Processor nor ProcessorSelector.void setProcessorSelector(ProcessorSelector selector)
ProcessorSelector, which will be used to get Processor to process Connection
I/O events, in case if this Transport's Processor is null and Connection doesn't
have neither preferred Processor nor ProcessorSelector.
Transport's ProcessorSelector is the last place, where Transport will try to get
Processor to process Connection I/O event. If ProcessorSelector is not set -
IllegalStateException will be thrown.selector - the default ProcessorSelector, which will be used to get Processor to process
Connection I/O events, in case if this Transport's Processor is null and
Connection doesn't have neither preferred Processor nor ProcessorSelector.MemoryManager getMemoryManager()
Transport associated MemoryManager, which will be used by the Transport, its
Connections and by during processing I/O events, occurred on Connections.Transport associated MemoryManager, which will be used by the Transport, its
Connections and by during processing I/O events, occurred on Connections.void setMemoryManager(MemoryManager memoryManager)
Transport associated MemoryManager, which will be used by the Transport, its
Connections and by during processing I/O events, occurred on Connections.memoryManager - the Transport associated MemoryManager, which will be used by the
Transport, its Connections and by during processing I/O events, occurred on Connections.IOStrategy getIOStrategy()
IOStrategy implementation, which will be used by Transport to process IOEvent.
IOStrategy is responsible for choosing the way, how I/O event will be processed: using current
Thread, worker Thread; or make any other decisions.IOStrategy implementation, which will be used by Transport to process IOEvent.void setIOStrategy(IOStrategy IOStrategy)
IOStrategy implementation, which will be used by Transport to process IOEvent.
IOStrategy is responsible for choosing the way, how I/O event will be processed: using current
Thread, worker Thread; or make any other decisions.IOStrategy - the IOStrategy implementation, which will be used by Transport to process
IOEvent.int getReadBufferSize()
Buffers, which will be allocated for reading data from Transport's
Connections. For particular Connection, this setting could be overridden by
Connection.getReadBufferSize().Buffers, which will be allocated for reading data from Transport's
Connections.void setReadBufferSize(int readBufferSize)
Buffers, which will be allocated for reading data from Transport's
Connections. For particular Connection, this setting could be overridden by
Connection.setReadBufferSize(int).
If not explicitly configured, this value will be set to DEFAULT_READ_BUFFER_SIZE.readBufferSize - the default size of Buffers, which will be allocated for reading data from
Transport's Connections.int getWriteBufferSize()
Buffers, which will be allocated for writing data to Transport's
Connections. For particular Connection, this setting could be overridden by
Connection.getWriteBufferSize().Buffers, which will be allocated for writing data to Transport's
Connections.void setWriteBufferSize(int writeBufferSize)
Buffers, which will be allocated for writing data to Transport's
Connections. For particular Connection, this setting could be overridden by
Connection.setWriteBufferSize(int).writeBufferSize - the default size of Buffers, which will be allocated for writing data to
Transport's Connections.ExecutorService getWorkerThreadPool()
IOStrategy) to let kernel
threads continue their job.ExecutorService transport worker thread pool.ExecutorService getKernelThreadPool()
ExecutorService responsible for running Transport internal tasks. For example
SelectorRunner threads for NIO.void setWorkerThreadPool(ExecutorService threadPool)
IOStrategy) to let kernel
threads continue their job.threadPool - ExecutorService transport worker thread pool.void setKernelThreadPool(ExecutorService threadPool)
SelectorRunner threads for NIO.threadPool - ExecutorService for SelectorRunnersvoid setKernelThreadPoolConfig(ThreadPoolConfig kernelConfig)
ThreadPoolConfig to be used by the Transport internal thread pool.kernelConfig - kernel thread pool configuration.void setWorkerThreadPoolConfig(ThreadPoolConfig workerConfig)
ThreadPoolConfig to be used by the worker thread pool.workerConfig - worker thread pool configuration.ThreadPoolConfig getKernelThreadPoolConfig()
ThreadPoolConfig that will be used to construct the ExecutorService
which will run the Transport's internal tasks. For example
SelectorRunners for NIO.ThreadPoolConfig getWorkerThreadPoolConfig()
ThreadPoolConfig that will be used to construct the ExecutorService
for IOStrategies that require worker threads. Depending on the IOStrategy being used, this may
return null.AttributeBuilder getAttributeBuilder()
Transport associated AttributeBuilder, which will be used by Transport and its
Connections to store custom Attributes.Transport associated AttributeBuilder, which will be used by Transport and its
Connections to store custom Attributes.void setAttributeBuilder(AttributeBuilder attributeBuilder)
Transport associated AttributeBuilder, which will be used by Transport and its
Connections to store custom Attributes.attributeBuilder - Transport associated AttributeBuilder, which will be used by
Transport and its Connections to store custom Attributes.void start()
throws IOException
IOException - if transport fails to start. This may not occur if Transport was not in Transport.State.STOPPED.@Deprecated void stop() throws IOException
shutdownNow().IOException - if there was an error shutting downGrizzlyFuture<Transport> shutdown()
shutdownNow() to terminate the transport if the graceful shutdown is taking too long.GrizzlyFuture which will return the stopped transport.GracefulShutdownListenerGrizzlyFuture<Transport> shutdown(long gracePeriod, TimeUnit timeUnit)
gracePeriod - 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.void shutdownNow()
throws IOException
IOException - if there was an error shutting downto complete gracefullyboolean addShutdownListener(GracefulShutdownListener shutdownListener)
GracefulShutdownListener which will be called when 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 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.void pause()
void resume()
void fireIOEvent(IOEvent ioEvent, Connection connection, IOEventLifeCycleListener listener)
IOEvent on the ConnectionioEvent - I/O eventconnection - Connection, on which we fire the event.listener - I/O event life-cycle listener.boolean isStopped()
boolean isPaused()
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.connection - Connection.Reader.Reader getReader(boolean isBlocking)
Reader implementation, depending on the requested mode.isBlocking - blocking mode.Reader.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.connection - Connection.Writer.Writer getWriter(boolean isBlocking)
Writer implementation, depending on the requested mode.isBlocking - blocking mode.Writer.MonitoringConfig<ConnectionProbe> getConnectionMonitoringConfig()
Connections.MonitoringConfig<ThreadPoolProbe> getThreadPoolMonitoringConfig()
MonitoringConfig<TransportProbe> getMonitoringConfig()
MonitoringConfig.getMonitoringConfig in interface MonitoringAware<TransportProbe>MonitoringConfig.void notifyTransportError(Throwable error)
error - Throwable.long getReadTimeout(TimeUnit timeUnit)
TimeUnit specification. If
this value hasn't been explicitly set, it will default to 30 seconds.timeUnit - the TimeUnit to convert the returned result to.void setReadTimeout(long timeout,
TimeUnit timeUnit)
timeout - the new timeout valuetimeUnit - the TimeUnit specification of the provided value.Connection.setReadTimeout(long, java.util.concurrent.TimeUnit)long getWriteTimeout(TimeUnit timeUnit)
TimeUnit specification. If
this value hasn't been explicitly set, it will default to 30 seconds.timeUnit - the TimeUnit to convert the returned result to.void setWriteTimeout(long timeout,
TimeUnit timeUnit)
timeout - the new timeout valuetimeUnit - the TimeUnit specification of the provided value.Connection.setWriteTimeout(long, java.util.concurrent.TimeUnit)Copyright © 2017–2020 Oracle Corporation. All rights reserved.