Class TransportFilter
- java.lang.Object
-
- org.glassfish.jersey.jdk.connector.internal.Filter<java.nio.ByteBuffer,java.nio.ByteBuffer,java.lang.Void,java.nio.ByteBuffer>
-
- org.glassfish.jersey.jdk.connector.internal.TransportFilter
-
class TransportFilter extends Filter<java.nio.ByteBuffer,java.nio.ByteBuffer,java.lang.Void,java.nio.ByteBuffer>
Writes and reads data to and from a socket. Only onewrite(ByteBuffer, org.glassfish.jersey.jdk.connector.internal.CompletionHandler)
method call can be processed at a time. Only one_read(ByteBuffer)
operation is supported at a time, another one is started only after the previous one has completed. Blocking inFilter.onRead(Object)
orFilter.onConnect()
method will result in data not being read from a socket until these methods have completed.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
TransportFilter.QueuingExecutor
A thread pool executor that prefers creating new worker threads over queueing tasks until the maximum poll size has been reached, after which it will start queueing tasks.private static class
TransportFilter.TransportThreadFactory
A default thread factory that gets used ifThreadPoolConfig.getThreadFactory()
is not specified.
-
Field Summary
Fields Modifier and Type Field Description private static java.nio.channels.AsynchronousChannelGroup
channelGroup
private static java.util.concurrent.ScheduledFuture<?>
closeWaitTask
private static java.util.concurrent.ScheduledExecutorService
connectionCloseScheduler
private int
containerIdleTimeout
private static java.lang.Integer
currentContainerIdleTimeout
Idle timeout that will be used when closing currentchannelGroup
private static ThreadPoolConfig
currentThreadPoolConfig
ThreadPoolConfig
currentchannelGroup
has been created with.private int
inputBufferSize
private static java.util.logging.Logger
LOGGER
private static java.util.concurrent.atomic.AtomicInteger
openedConnections
private java.nio.channels.AsynchronousSocketChannel
socketChannel
private ThreadPoolConfig
threadPoolConfig
-
Fields inherited from class org.glassfish.jersey.jdk.connector.internal.Filter
downstreamFilter, upstreamFilter
-
-
Constructor Summary
Constructors Constructor Description TransportFilter(int inputBufferSize, ThreadPoolConfig threadPoolConfig, int containerIdleTimeout)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
_read(java.nio.ByteBuffer inputBuffer)
(package private) void
close()
Close the filter, invokes close operation on the next filter in the filter chain.void
handleConnect(java.net.SocketAddress serverAddress, Filter upstreamFilter)
private void
initializeChannelGroup()
private void
scheduleClose()
(package private) void
startSsl()
Signal to turn on SSL, it is passed on in the filter chain until a filter responsible for SSL is reached.private void
updateThreadPoolConfig()
(package private) void
write(java.nio.ByteBuffer data, CompletionHandler<java.nio.ByteBuffer> completionHandler)
Perform write operation for this filter and invokes write method on the next filter in the filter chain.-
Methods inherited from class org.glassfish.jersey.jdk.connector.internal.Filter
connect, onConnect, onConnectionClosed, onError, onRead, onSslHandshakeCompleted, processConnect, processConnectionClosed, processError, processRead, processSslHandshakeCompleted
-
-
-
-
Field Detail
-
LOGGER
private static final java.util.logging.Logger LOGGER
-
openedConnections
private static final java.util.concurrent.atomic.AtomicInteger openedConnections
-
connectionCloseScheduler
private static final java.util.concurrent.ScheduledExecutorService connectionCloseScheduler
-
channelGroup
private static volatile java.nio.channels.AsynchronousChannelGroup channelGroup
-
closeWaitTask
private static volatile java.util.concurrent.ScheduledFuture<?> closeWaitTask
-
currentThreadPoolConfig
private static volatile ThreadPoolConfig currentThreadPoolConfig
ThreadPoolConfig
currentchannelGroup
has been created with.
-
currentContainerIdleTimeout
private static volatile java.lang.Integer currentContainerIdleTimeout
Idle timeout that will be used when closing currentchannelGroup
-
inputBufferSize
private final int inputBufferSize
-
threadPoolConfig
private final ThreadPoolConfig threadPoolConfig
-
containerIdleTimeout
private final int containerIdleTimeout
-
socketChannel
private volatile java.nio.channels.AsynchronousSocketChannel socketChannel
-
-
Constructor Detail
-
TransportFilter
TransportFilter(int inputBufferSize, ThreadPoolConfig threadPoolConfig, int containerIdleTimeout)
Constructor. If the channel group is not active (all connections have been closed and the shutdown timeout is running) and a new transport is created with tread pool configuration different from the one of the current thread pool, the current thread pool will be shut down and a new one created with the new configuration.- Parameters:
inputBufferSize
- size of buffer to be allocated for reading data from a socket.threadPoolConfig
- thread pool configuration used for creating thread pool.containerIdleTimeout
- idle time after which the shared thread pool will be destroyed.
-
-
Method Detail
-
write
void write(java.nio.ByteBuffer data, CompletionHandler<java.nio.ByteBuffer> completionHandler)
Description copied from class:Filter
Perform write operation for this filter and invokes write method on the next filter in the filter chain.
-
close
void close()
Description copied from class:Filter
Close the filter, invokes close operation on the next filter in the filter chain. The filter is expected to clean up any allocated resources and pass the invocation to downstream filter.
-
startSsl
void startSsl()
Description copied from class:Filter
Signal to turn on SSL, it is passed on in the filter chain until a filter responsible for SSL is reached.
-
handleConnect
public void handleConnect(java.net.SocketAddress serverAddress, Filter upstreamFilter)
Description copied from class:Filter
- Overrides:
handleConnect
in classFilter<java.nio.ByteBuffer,java.nio.ByteBuffer,java.lang.Void,java.nio.ByteBuffer>
- Parameters:
serverAddress
- an address where to connect (server or proxy).upstreamFilter
- a filter positioned upstream.- See Also:
Filter.connect(SocketAddress, Filter)
-
updateThreadPoolConfig
private void updateThreadPoolConfig()
-
initializeChannelGroup
private void initializeChannelGroup() throws java.io.IOException
- Throws:
java.io.IOException
-
_read
private void _read(java.nio.ByteBuffer inputBuffer)
-
scheduleClose
private void scheduleClose()
-
-