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 classTransportFilter.QueuingExecutorA 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 classTransportFilter.TransportThreadFactoryA default thread factory that gets used ifThreadPoolConfig.getThreadFactory()is not specified.
-
Field Summary
Fields Modifier and Type Field Description private static java.nio.channels.AsynchronousChannelGroupchannelGroupprivate static java.util.concurrent.ScheduledFuture<?>closeWaitTaskprivate static java.util.concurrent.ScheduledExecutorServiceconnectionCloseSchedulerprivate intcontainerIdleTimeoutprivate static java.lang.IntegercurrentContainerIdleTimeoutIdle timeout that will be used when closing currentchannelGroupprivate static ThreadPoolConfigcurrentThreadPoolConfigThreadPoolConfigcurrentchannelGrouphas been created with.private intinputBufferSizeprivate static java.util.logging.LoggerLOGGERprivate static java.util.concurrent.atomic.AtomicIntegeropenedConnectionsprivate java.nio.channels.AsynchronousSocketChannelsocketChannelprivate ThreadPoolConfigthreadPoolConfig-
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) voidclose()Close the filter, invokes close operation on the next filter in the filter chain.voidhandleConnect(java.net.SocketAddress serverAddress, Filter upstreamFilter)private voidinitializeChannelGroup()private voidscheduleClose()(package private) voidstartSsl()Signal to turn on SSL, it is passed on in the filter chain until a filter responsible for SSL is reached.private voidupdateThreadPoolConfig()(package private) voidwrite(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
ThreadPoolConfigcurrentchannelGrouphas 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:FilterPerform write operation for this filter and invokes write method on the next filter in the filter chain.
-
close
void close()
Description copied from class:FilterClose 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:FilterSignal 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:
handleConnectin 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()
-
-