public abstract class AbstractTransport extends Object implements Transport
Transport.
Implements common transport functionality.Transport.State| Modifier and Type | Field and Description |
|---|---|
protected AttributeBuilder |
attributeBuilder
Transport AttributeBuilder, which will be used to create Attributes
|
protected DefaultMonitoringConfig<ConnectionProbe> |
connectionMonitoringConfig
Connection probes
|
protected boolean |
isBlocking
Transport mode
|
protected boolean |
isStandalone |
protected ExecutorService |
kernelPool
Kernel thread pool.
|
protected ThreadPoolConfig |
kernelPoolConfig |
protected boolean |
managedWorkerPool |
protected MemoryManager |
memoryManager
Transport MemoryManager
|
protected String |
name
Transport name
|
protected Processor |
processor
Transport default Processor
|
protected ProcessorSelector |
processorSelector
Transport default ProcessorSelector
|
protected int |
readBufferSize
Transport default buffer size for read operations
|
protected long |
readTimeout |
protected StateHolder<Transport.State> |
state
Transport state controller
|
protected IOStrategy |
strategy
Transport strategy
|
protected DefaultMonitoringConfig<ThreadPoolProbe> |
threadPoolMonitoringConfig
Thread pool probes
|
protected DefaultMonitoringConfig<TransportProbe> |
transportMonitoringConfig
Transport probes
|
protected ThreadPoolConfig |
workerPoolConfig |
protected ExecutorService |
workerThreadPool
Worker thread pool
|
protected int |
writeBufferSize
Transport default buffer size for write operations
|
protected long |
writeTimeout |
DEFAULT_READ_BUFFER_SIZE, DEFAULT_READ_TIMEOUT, DEFAULT_WRITE_BUFFER_SIZE, DEFAULT_WRITE_TIMEOUT| Constructor and Description |
|---|
AbstractTransport(String name) |
| Modifier and Type | Method and Description |
|---|---|
protected abstract void |
closeConnection(Connection connection)
Close the connection, managed by Transport
|
void |
configureBlocking(boolean isBlocking)
Sets the
Transport mode. |
protected abstract Object |
createJmxManagementObject()
Create the Transport JMX management object.
|
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. |
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. |
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.
|
protected static void |
notifyProbesBeforePause(AbstractTransport transport)
Notify registered
TransportProbes about the before-pause event. |
protected static void |
notifyProbesBeforeResume(AbstractTransport transport)
Notify registered
TransportProbes about the before-resume event. |
protected static void |
notifyProbesBeforeStart(AbstractTransport transport)
Notify registered
TransportProbes about the before-start event. |
protected static void |
notifyProbesBeforeStop(AbstractTransport transport)
Notify registered
TransportProbes about the before-stop event. |
protected static void |
notifyProbesConfigChanged(AbstractTransport transport)
Notify registered
TransportProbes about the config changed event. |
protected static void |
notifyProbesPause(AbstractTransport transport)
Notify registered
TransportProbes about the pause event. |
protected static void |
notifyProbesStop(AbstractTransport transport)
Notify registered
TransportProbes about the stop event. |
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 |
setAttributeBuilder(AttributeBuilder attributeBuilder)
Set
Transport associated AttributeBuilder, which will
be used by Transport and its Connections to store custom
Attributes. |
void |
setIOStrategy(IOStrategy IOStrategy)
|
protected void |
setKernelPool0(ExecutorService kernelPool) |
void |
setKernelThreadPool(ExecutorService kernelPool)
Set a thread pool which will run Transport internal tasks.
|
void |
setKernelThreadPoolConfig(ThreadPoolConfig kernelPoolConfig)
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. |
protected void |
setWorkerThreadPool0(ExecutorService threadPool) |
void |
setWorkerThreadPoolConfig(ThreadPoolConfig workerPoolConfig)
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.
|
void |
stop()
Deprecated.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddShutdownListener, configureStandalone, fireIOEvent, getReader, getReader, getWriter, getWriter, notifyTransportError, pause, resume, shutdown, shutdown, shutdownNow, startprotected String name
protected volatile boolean isBlocking
protected volatile boolean isStandalone
protected final StateHolder<Transport.State> state
protected Processor processor
protected ProcessorSelector processorSelector
protected IOStrategy strategy
protected MemoryManager memoryManager
protected ExecutorService workerThreadPool
protected ExecutorService kernelPool
protected AttributeBuilder attributeBuilder
protected int readBufferSize
protected int writeBufferSize
protected ThreadPoolConfig workerPoolConfig
protected ThreadPoolConfig kernelPoolConfig
protected boolean managedWorkerPool
protected long writeTimeout
protected long readTimeout
protected final DefaultMonitoringConfig<TransportProbe> transportMonitoringConfig
protected final DefaultMonitoringConfig<ConnectionProbe> connectionMonitoringConfig
protected final DefaultMonitoringConfig<ThreadPoolProbe> threadPoolMonitoringConfig
public AbstractTransport(String name)
public 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().isBlocking in interface TransportTransport mode.
true, if Transport is operating in blocking mode, or
false otherwise.public void configureBlocking(boolean isBlocking)
Transport mode.
Specific Transport Connections may override this setting
by Connection.configureBlocking(boolean).configureBlocking in interface TransportisBlocking - the Transport mode. true,
if Transport should operate in blocking mode, or
false otherwise.public boolean isStandalone()
isStandalone in interface Transportpublic StateHolder<Transport.State> getState()
Transport state controller. Using the state controller,
it is possible to get/set the Transport state in thread-safe manner.getState in interface TransportStateHolder state controller.public 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().getReadBufferSize in interface TransportBuffers, which will be allocated for
reading data from Transport's Connections.public 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
Transport.DEFAULT_READ_BUFFER_SIZE.setReadBufferSize in interface TransportreadBufferSize - the default size of Buffers, which will
be allocated for reading data from Transport's
Connections.public 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().getWriteBufferSize in interface TransportBuffers, which will be allocated for
writing data to Transport's Connections.public 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).setWriteBufferSize in interface TransportwriteBufferSize - the default size of Buffers, which will
be allocated for writing data to Transport's
Connections.public boolean isStopped()
public 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).obtainProcessor in interface TransportProcessor, which will process
Connection I/O events, if one doesn't have
own Processor preferences.public 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).getProcessor in interface TransportProcessor, which will process
Connection I/O events, if one doesn't have
own Processor preferences.public void setProcessor(Processor processor)
Processor, which will process Connection
I/O events in case, if Connection doesn't have own
Processor preferences.setProcessor in interface Transportprocessor - the default Processor, which will process
Connection I/O events, if one doesn't have own
Processor preferences.public 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.getProcessorSelector in interface TransportProcessorSelector, 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.public 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.setProcessorSelector in interface Transportselector - 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.public 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.getIOStrategy in interface TransportIOStrategy implementation, which will be used by
Transport to process IOEvent.public 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.setIOStrategy in interface TransportIOStrategy - the IOStrategy implementation, which will be used
by Transport to process IOEvent.public MemoryManager getMemoryManager()
Transport associated MemoryManager, which will
be used by the Transport, its Connections and by during
processing I/O events, occurred on Connections.getMemoryManager in interface TransportTransport associated MemoryManager,
which will be used by the Transport, its Connections
and by during processing I/O events, occurred on Connections.public 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.setMemoryManager in interface TransportmemoryManager - the Transport associated
MemoryManager, which will be used by the Transport,
its Connections and by during processing I/O events, occurred
on Connections.public ExecutorService getWorkerThreadPool()
IOStrategy) to let kernel threads continue
their job.getWorkerThreadPool in interface TransportExecutorService transport worker thread pool.public ExecutorService getKernelThreadPool()
getKernelThreadPool in interface TransportExecutorService responsible for running Transport internal
tasks. For example SelectorRunner
threads for NIO.public void setKernelThreadPool(ExecutorService kernelPool)
SelectorRunner threads for NIO.setKernelThreadPool in interface TransportkernelPool - ExecutorService for SelectorRunnerspublic void setKernelThreadPoolConfig(ThreadPoolConfig kernelPoolConfig)
ThreadPoolConfig to be used by the Transport internal
thread pool.setKernelThreadPoolConfig in interface TransportkernelPoolConfig - kernel thread
pool configuration.public void setWorkerThreadPoolConfig(ThreadPoolConfig workerPoolConfig)
ThreadPoolConfig to be used by the worker thread pool.setWorkerThreadPoolConfig in interface TransportworkerPoolConfig - worker thread pool configuration.public ThreadPoolConfig getKernelThreadPoolConfig()
getKernelThreadPoolConfig in interface TransportThreadPoolConfig that will be used to construct the
ExecutorService which will run the
Transport's internal tasks.
For example
SelectorRunners for NIO.public ThreadPoolConfig getWorkerThreadPoolConfig()
getWorkerThreadPoolConfig in interface TransportThreadPoolConfig that will be used to construct the
ExecutorService for IOStrategies
that require worker threads. Depending on the IOStrategy being
used, this may return null.public void setWorkerThreadPool(ExecutorService threadPool)
IOStrategy) to let kernel threads continue
their job.setWorkerThreadPool in interface TransportthreadPool - ExecutorService transport worker thread pool.protected void setWorkerThreadPool0(ExecutorService threadPool)
protected void setKernelPool0(ExecutorService kernelPool)
public AttributeBuilder getAttributeBuilder()
Transport associated AttributeBuilder, which will
be used by Transport and its Connections to store custom
Attributes.getAttributeBuilder in interface TransportTransport associated AttributeBuilder, which will
be used by Transport and its Connections to store custom
Attributes.public void setAttributeBuilder(AttributeBuilder attributeBuilder)
Transport associated AttributeBuilder, which will
be used by Transport and its Connections to store custom
Attributes.setAttributeBuilder in interface TransportattributeBuilder - Transport associated
AttributeBuilder, which will be used by Transport and
its Connections to store custom Attributes.protected abstract void closeConnection(Connection connection) throws IOException
connection - IOExceptionpublic MonitoringConfig<ConnectionProbe> getConnectionMonitoringConfig()
Connections.getConnectionMonitoringConfig in interface Transportpublic MonitoringConfig<TransportProbe> getMonitoringConfig()
MonitoringConfig.getMonitoringConfig in interface MonitoringAware<TransportProbe>getMonitoringConfig in interface TransportMonitoringConfig.public MonitoringConfig<ThreadPoolProbe> getThreadPoolMonitoringConfig()
getThreadPoolMonitoringConfig in interface Transportpublic long getReadTimeout(TimeUnit timeUnit)
TimeUnit specification. If this value hasn't been
explicitly set, it will default to 30 seconds.getReadTimeout in interface TransporttimeUnit - the TimeUnit to convert the returned result to.public void setReadTimeout(long timeout,
TimeUnit timeUnit)
setReadTimeout in interface Transporttimeout - the new timeout valuetimeUnit - the specification of the provided value.Connection.setReadTimeout(long, java.util.concurrent.TimeUnit)public long getWriteTimeout(TimeUnit timeUnit)
TimeUnit specification. If this value hasn't been
explicitly set, it will default to 30 seconds.getWriteTimeout in interface TransporttimeUnit - the TimeUnit to convert the returned result to.public void setWriteTimeout(long timeout,
TimeUnit timeUnit)
setWriteTimeout in interface Transporttimeout - the new timeout valuetimeUnit - the specification of the provided value.Connection.setWriteTimeout(long, java.util.concurrent.TimeUnit)protected static void notifyProbesBeforeStart(AbstractTransport transport)
TransportProbes about the before-start event.transport - the Transport event occurred on.protected static void notifyProbesBeforeStop(AbstractTransport transport)
TransportProbes about the before-stop event.transport - the Transport event occurred on.protected static void notifyProbesStop(AbstractTransport transport)
TransportProbes about the stop event.transport - the Transport event occurred on.protected static void notifyProbesBeforePause(AbstractTransport transport)
TransportProbes about the before-pause event.transport - the Transport event occurred on.protected static void notifyProbesPause(AbstractTransport transport)
TransportProbes about the pause event.transport - the Transport event occurred on.protected static void notifyProbesBeforeResume(AbstractTransport transport)
TransportProbes about the before-resume event.transport - the Transport event occurred on.protected static void notifyProbesConfigChanged(AbstractTransport transport)
TransportProbes about the config changed event.transport - the Transport event occurred on.@Deprecated public void stop() throws IOException
stop in interface TransportIOExceptionprotected abstract Object createJmxManagementObject()
Copyright © 2017–2019 Oracle Corporation. All rights reserved.