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 classA 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 classA default thread factory that gets used ifThreadPoolConfig.getThreadFactory()is not specified. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static AsynchronousChannelGroupprivate static ScheduledFuture<?> private static final ScheduledExecutorServiceprivate final intprivate static IntegerIdle timeout that will be used when closing currentchannelGroupprivate static ThreadPoolConfigThreadPoolConfigcurrentchannelGrouphas been created with.private final intprivate static final Loggerprivate static final AtomicIntegerprivate AsynchronousSocketChannelprivate final ThreadPoolConfigFields 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) voidclose()Close the filter, invokes close operation on the next filter in the filter chain.voidhandleConnect(SocketAddress serverAddress, Filter upstreamFilter) private voidprivate void(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 void(package private) voidwrite(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
ThreadPoolConfigcurrentchannelGrouphas 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:FilterPerform write operation for this filter and invokes write method on the next filter in the filter chain.- Overrides:
writein 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: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.- Overrides:
closein classFilter<ByteBuffer,ByteBuffer, Void, ByteBuffer>
-
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.- Overrides:
startSslin classFilter<ByteBuffer,ByteBuffer, Void, ByteBuffer>
-
handleConnect
Description copied from class:Filter- Overrides:
handleConnectin 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()
-