Class TransportFilter
java.lang.Object
org.glassfish.jersey.jdk.connector.internal.Filter<ByteBuffer,ByteBuffer,Void,ByteBuffer>
org.glassfish.jersey.jdk.connector.internal.TransportFilter
Writes and reads data to and from a socket. Only one
write(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 in Filter.onRead(Object)
or Filter.onConnect()
method will result in data not being read from a socket until these methods have completed.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
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
A default thread factory that gets used ifThreadPoolConfig.getThreadFactory()
is not specified. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static AsynchronousChannelGroup
private static ScheduledFuture<?>
private static final ScheduledExecutorService
private final int
private static Integer
Idle timeout that will be used when closing currentchannelGroup
private static ThreadPoolConfig
ThreadPoolConfig
currentchannelGroup
has been created with.private final int
private static final Logger
private static final AtomicInteger
private AsynchronousSocketChannel
private final ThreadPoolConfig
Fields inherited from class org.glassfish.jersey.jdk.connector.internal.Filter
downstreamFilter, upstreamFilter
-
Constructor Summary
ConstructorsConstructorDescriptionTransportFilter
(int inputBufferSize, ThreadPoolConfig threadPoolConfig, int containerIdleTimeout) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
_read
(ByteBuffer inputBuffer) (package private) void
close()
Close the filter, invokes close operation on the next filter in the filter chain.void
handleConnect
(SocketAddress serverAddress, Filter upstreamFilter) private void
private void
(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
(package private) void
write
(ByteBuffer data, CompletionHandler<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 Details
-
LOGGER
-
openedConnections
-
connectionCloseScheduler
-
channelGroup
-
closeWaitTask
-
currentThreadPoolConfig
ThreadPoolConfig
currentchannelGroup
has been created with. -
currentContainerIdleTimeout
Idle timeout that will be used when closing currentchannelGroup
-
inputBufferSize
private final int inputBufferSize -
threadPoolConfig
-
containerIdleTimeout
private final int containerIdleTimeout -
socketChannel
-
-
Constructor Details
-
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 Details
-
write
Description copied from class:Filter
Perform write operation for this filter and invokes write method on the next filter in the filter chain.- Overrides:
write
in classFilter<ByteBuffer,
ByteBuffer, Void, ByteBuffer> - Parameters:
data
- on which write operation is performed.completionHandler
- will be invoked when the write operation is completed or has failed.
-
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.- Overrides:
close
in classFilter<ByteBuffer,
ByteBuffer, Void, ByteBuffer>
-
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.- Overrides:
startSsl
in classFilter<ByteBuffer,
ByteBuffer, Void, ByteBuffer>
-
handleConnect
Description copied from class:Filter
- Overrides:
handleConnect
in classFilter<ByteBuffer,
ByteBuffer, Void, ByteBuffer> - Parameters:
serverAddress
- an address where to connect (server or proxy).upstreamFilter
- a filter positioned upstream.- See Also:
-
updateThreadPoolConfig
private void updateThreadPoolConfig() -
initializeChannelGroup
- Throws:
IOException
-
_read
-
scheduleClose
private void scheduleClose()
-