Top Description Inners Fields Methods
org.glassfish.grizzly

public Interface Transport

extends MonitoringAware<TransportProbe>
Known Direct Implementers
org.glassfish.grizzly.AbstractTransport
Imports
java.io.IOException, java.util.concurrent.ExecutorService, .TimeUnit, org.glassfish.grizzly.attributes.Attribute, .AttributeBuilder, org.glassfish.grizzly.memory.MemoryManager, org.glassfish.grizzly.monitoring.MonitoringAware, .MonitoringConfig, org.glassfish.grizzly.threadpool.ThreadPoolConfig, .ThreadPoolProbe, org.glassfish.grizzly.utils.StateHolder

Transport interface describes the transport unit used in Grizzly. Transport implementation could operate over TCP, UDP or other custom protocol, using blocking, NIO or NIO.2 Java API.
Author
Alexey Stashok

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum

Field Summary

Modifier and TypeField and Description
public static final int
DEFAULT_READ_BUFFER_SIZE

The default read buffer size.

public static final int
DEFAULT_READ_TIMEOUT

Default read timeout in seconds.

public static final int
DEFAULT_WRITE_BUFFER_SIZE

The default write buffer size.

public static final int
DEFAULT_WRITE_TIMEOUT

Default write timeout in seconds.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true 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.
addShutdownListener
(final GracefulShutdownListener shutdownListener)

Adds a GracefulShutdownListener which will be called when shutdown() is called to enable graceful shutdown of transports.

public void
configureBlocking(boolean
the Transport mode. true, if Transport should operate in blocking mode, or false otherwise.
isBlocking
)

Sets the Transport mode.

public void
configureStandalone(boolean isStandalone)

public void
fireIOEvent(IOEvent
I/O event
ioEvent
,
Connection<L>
Connection, on which we fire the event.
connection
,
IOEventLifeCycleListener
I/O event life-cycle listener.
listener
)

Fires specific IOEvent on the Connection

public AttributeBuilder

Returns:

Transport associated AttributeBuilder, which will be used by Transport and its Connections to store custom Attributes.
getAttributeBuilder
()

Get Transport associated AttributeBuilder, which will be used by Transport and its Connections to store custom Attributes.

public MonitoringConfig<ConnectionProbe>

Returns:

the configuration
getConnectionMonitoringConfig
()

Get the monitoring configuration for Transport Connections.

public IOStrategy

Returns:

the IOStrategy implementation, which will be used by Transport to process IOEvent.
getIOStrategy
()

Get the IOStrategy implementation, which will be used by Transport to process IOEvent.

public ExecutorService
getKernelThreadPool()

Returns: ExecutorService responsible for running Transport internal tasks.

public ThreadPoolConfig
getKernelThreadPoolConfig()

Returns: the ThreadPoolConfig that will be used to construct the java.util.concurrent.ExecutorService which will run the org.glassfish.grizzly.Transport's internal tasks.

public MemoryManager<E extends Buffer>

Returns:

the Transport associated MemoryManager, which will be used by the Transport, its Connections and by during processing I/O events, occurred on Connections.
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.

public MonitoringConfig<TransportProbe>
public String

Returns:

the Transport name.
getName
()

Gets the Transport name.

public Processor<E extends Context>

Returns:

the default Processor, which will process Connection I/O events, if one doesn't have own Processor preferences.
getProcessor
()

Gets the default Processor, which will process Connection I/O events in case, if Connection doesn't have own Processor preferences.

public ProcessorSelector

Returns:

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.
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.

public int

Returns:

the default size of Buffers, which will be allocated for reading data from Transport's Connections.
getReadBufferSize
()

Get the default size of Buffers, which will be allocated for reading data from Transport's Connections.

public Reader<L>

Returns:

Reader.
getReader
(Connection<L> connection)

Get the Reader to read data from the Connection.

public Reader<L>

Returns:

Reader.
getReader
(boolean
blocking mode.
isBlocking
)

Get the Reader implementation, depending on the requested mode.

public long

Returns:

the value of the read timeout
getReadTimeout
(TimeUnit
the TimeUnit to convert the returned result to.
timeUnit
)

Returns the current value for the blocking read timeout converted to the provided TimeUnit specification.

public StateHolder<Transport.State>

Returns:

StateHolder state controller.
getState
()

Return the Transport state controller.

public MonitoringConfig<ThreadPoolProbe>

Returns:

the configuration
getThreadPoolMonitoringConfig
()

Get the monitoring configuration for Transport thread pool.

public ExecutorService

Returns:

ExecutorService transport worker thread pool.
getWorkerThreadPool
()

Get a thread pool, which will run IOEvent processing (depending on Transport IOStrategy) to let kernel threads continue their job.

public ThreadPoolConfig
getWorkerThreadPoolConfig()

Returns: the ThreadPoolConfig that will be used to construct the java.util.concurrent.ExecutorService for IOStrategies that require worker threads.

public int

Returns:

the default size of Buffers, which will be allocated for writing data to Transport's Connections.
getWriteBufferSize
()

Get the default size of Buffers, which will be allocated for writing data to Transport's Connections.

public Writer<L>

Returns:

Writer.
getWriter
(Connection<L> connection)

Get the Writer to write data to the Connection.

public Writer<L>

Returns:

Writer.
getWriter
(boolean
blocking mode.
isBlocking
)

Get the Writer implementation, depending on the requested mode.

public long

Returns:

the value of the write timeout
getWriteTimeout
(TimeUnit
the TimeUnit to convert the returned result to.
timeUnit
)

Returns the current value for the blocking write timeout converted to the provided TimeUnit specification.

public boolean

Returns:

the Transport mode. true, if Transport is operating in blocking mode, or false otherwise.
isBlocking
()

Returns the Transport mode.

public boolean
public boolean
public boolean

Returns:

true, if this Transport is in stopped state, false otherwise.
isStopped
()

Returns true, if this Transport is in stopped state, false otherwise.

public void
notifyTransportError(Throwable error)

Method gets invoked, when error occur during the Transport lifecycle.

public Processor<E extends Context>

Returns:

the default Processor, which will process Connection I/O events, if one doesn't have own Processor preferences.
obtainProcessor
(IOEvent
the type of events the Processor should handle
ioEvent
,
Connection<L>
connection to obtain Processor for
connection
)

Gets the default Processor, which will process Transport Connections I/O events in case, if Connection doesn't have own Processor preferences.

public void
pause()

Pauses the transport

public void
resume()

Resumes the transport after a pause

public void
setAttributeBuilder(AttributeBuilder
Transport associated AttributeBuilder, which will be used by Transport and its Connections to store custom Attributes.
attributeBuilder
)

Set Transport associated AttributeBuilder, which will be used by Transport and its Connections to store custom Attributes.

public void
setIOStrategy(IOStrategy
the IOStrategy implementation, which will be used by Transport to process IOEvent.
IOStrategy
)

Set the IOStrategy implementation, which will be used by Transport to process IOEvent.

public void
setKernelThreadPool(ExecutorService threadPool)

Set a thread pool which will run Transport internal tasks.

public void
setKernelThreadPoolConfig(final ThreadPoolConfig
kernel thread pool configuration.
kernelConfig
)

Set the ThreadPoolConfig to be used by the Transport internal thread pool.

public void
setMemoryManager(MemoryManager<E extends Buffer>
the Transport associated MemoryManager, which will be used by the Transport, its Connections and by during processing I/O events, occurred on Connections.
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.

public void
setName(String
the Transport name.
name
)

Sets the Transport name.

public void
setProcessor(Processor<E extends Context>
the default Processor, which will process Connection I/O events, if one doesn't have own Processor preferences.
processor
)

Sets the default Processor, which will process Connection I/O events in case, if Connection doesn't have own Processor preferences.

public void
setProcessorSelector(ProcessorSelector
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.
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.

public void
setReadBufferSize(int
the default size of Buffers, which will be allocated for reading data from Transport's Connections.
readBufferSize
)

Set the default size of Buffers, which will be allocated for reading data from Transport's Connections.

public void
setReadTimeout(long
the new timeout value
timeout
,
TimeUnit
the TimeUnit specification of the provided value.
timeUnit
)

Specifies the timeout for the blocking reads.

public void
setWorkerThreadPool(ExecutorService
ExecutorService transport worker thread pool.
threadPool
)

Set a thread pool, which will run IOEvent processing (depending on Transport IOStrategy) to let kernel threads continue their job.

public void
setWorkerThreadPoolConfig(final ThreadPoolConfig
worker thread pool configuration.
workerConfig
)

Set the ThreadPoolConfig to be used by the worker thread pool.

public void
setWriteBufferSize(int
the default size of Buffers, which will be allocated for writing data to Transport's Connections.
writeBufferSize
)

Set the default size of Buffers, which will be allocated for writing data to Transport's Connections.

public void
setWriteTimeout(long
the new timeout value
timeout
,
TimeUnit
the TimeUnit specification of the provided value.
timeUnit
)

Specifies the timeout for the blocking writes.

public GrizzlyFuture<Transport>

Returns:

a GrizzlyFuture which will return the stopped transport.
shutdown
()

Gracefully stops the transport accepting new connections and allows existing work to complete before finalizing the shutdown.

public GrizzlyFuture<Transport>

Returns:

a GrizzlyFuture which will return the stopped transport.
shutdown
(final long
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.
gracePeriod
,
final TimeUnit
the TimeUnit of the specified grace period.
timeUnit
)

Gracefully stops the transport accepting new connections and allows existing work to complete before finalizing the shutdown.

public void
shutdownNow()

Forcibly stops the transport and closes all connections.

public void
start()

Starts the transport

public void
stop()
Deprecated Use shutdownNow().

Stops the transport and closes all the connections