Class AbstractH2StreamMultiplexer
java.lang.Object
org.apache.hc.core5.http2.impl.nio.AbstractH2StreamMultiplexer
- All Implemented Interfaces:
Closeable
,AutoCloseable
,HttpConnection
,SocketModalCloseable
,ModalCloseable
,Identifiable
- Direct Known Subclasses:
ClientH2StreamMultiplexer
,ServerH2StreamMultiplexer
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static enum
private static class
(package private) static class
private class
(package private) static enum
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final long
private final AtomicInteger
private final BasicHttpConnectionMetrics
private final AtomicInteger
private EndpointDetails
private final FrameFactory
private boolean
private final HPackDecoder
private final HPackEncoder
private final HttpProcessor
private final StreamIdGenerator
private int
private int
private final FrameInputBuffer
private final BasicH2TransportMetrics
private final ProtocolIOSession
private final AtomicInteger
private static final long
private final H2Config
private int
private final FrameOutputBuffer
private final BasicH2TransportMetrics
private final AtomicInteger
private final Queue
<AsyncPingHandler> private int
private H2Config
private final H2StreamListener
private final Map
<Integer, AbstractH2StreamMultiplexer.H2Stream> -
Constructor Summary
ConstructorsConstructorDescriptionAbstractH2StreamMultiplexer
(ProtocolIOSession ioSession, FrameFactory frameFactory, StreamIdGenerator idGenerator, HttpProcessor httpProcessor, CharCodingConfig charCodingConfig, H2Config h2Config, H2StreamListener streamListener) -
Method Summary
Modifier and TypeMethodDescription(package private) abstract void
(package private) abstract void
(package private) abstract void
(package private) void
appendState
(StringBuilder buf) private void
private void
applyRemoteSettings
(H2Config config) void
close()
Closes this connection gracefully.void
Closes this process or endpoint and releases any system resources associated with it.private void
commitFrame
(RawFrame frame) private void
commitFrameInternal
(RawFrame frame) private void
commitHeaders
(int streamId, List<? extends Header> headers, boolean endStream) private void
commitPushPromise
(int streamId, int promisedStreamId, List<Header> headers) private void
consumeContinuationFrame
(RawFrame frame, AbstractH2StreamMultiplexer.H2Stream stream) private void
consumeDataFrame
(RawFrame frame, AbstractH2StreamMultiplexer.H2Stream stream) private void
consumeFrame
(RawFrame frame) private void
consumeHeaderFrame
(RawFrame frame, AbstractH2StreamMultiplexer.H2Stream stream) private void
consumePushPromiseFrame
(RawFrame frame, ByteBuffer payload, AbstractH2StreamMultiplexer.H2Stream promisedStream) private void
consumeSettingsFrame
(ByteBuffer payload) (package private) abstract H2StreamHandler
createLocallyInitiatedStream
(ExecutableCommand command, H2StreamChannel channel, HttpProcessor httpProcessor, BasicHttpConnectionMetrics connMetrics) (package private) abstract H2StreamHandler
createRemotelyInitiatedStream
(H2StreamChannel channel, HttpProcessor httpProcessor, BasicHttpConnectionMetrics connMetrics, HandlerFactory<AsyncPushConsumer> pushHandlerFactory) decodeHeaders
(ByteBuffer payload) private int
Returns this connection's endpoint details.getId()
Returns this connection's local address ornull
if it is not bound yet.Returns this connection's protocol version ornull
if unknown.Returns this connection's remote address ornull
if it is not connected yet or unconnected.Returns the socket timeout value.Returns this connection's SSL session ornull
if TLS has not been activated.getValidStream
(int streamId) private void
incrementInputCapacity
(int streamId, AtomicInteger inputWindow, int inputCapacity) boolean
isOpen()
Checks if this connection is open.private void
maximizeConnWindow
(int connWinSize) final void
final void
final void
onException
(Exception cause) final void
onInput
(ByteBuffer src) final void
onOutput()
final void
private void
private void
private void
void
setSocketTimeout
(Timeout timeout) Sets the socket timeout value.private int
streamData
(int streamId, AtomicInteger streamOutputWindow, ByteBuffer payload) private void
streamDataFrame
(int streamId, AtomicInteger streamOutputWindow, ByteBuffer payload, int chunk) private int
updateInputWindow
(int streamId, AtomicInteger window, int delta) private void
updateLastStreamId
(int streamId) private int
updateOutputWindow
(int streamId, AtomicInteger window, int delta) private int
updateWindow
(AtomicInteger window, int delta)
-
Field Details
-
LINGER_TIME
private static final long LINGER_TIME- See Also:
-
CONNECTION_WINDOW_LOW_MARK
private static final long CONNECTION_WINDOW_LOW_MARK- See Also:
-
ioSession
-
frameFactory
-
idGenerator
-
httpProcessor
-
localConfig
-
inputMetrics
-
outputMetrics
-
connMetrics
-
inputBuffer
-
outputBuffer
-
outputQueue
-
hPackEncoder
-
hPackDecoder
-
streamMap
-
pingHandlers
-
connInputWindow
-
connOutputWindow
-
outputRequests
-
lastStreamId
-
streamListener
-
connState
-
localSettingState
-
remoteSettingState
-
initInputWinSize
private int initInputWinSize -
initOutputWinSize
private int initOutputWinSize -
lowMark
private int lowMark -
remoteConfig
-
continuation
-
processedRemoteStreamId
private int processedRemoteStreamId -
endpointDetails
-
goAwayReceived
private boolean goAwayReceived
-
-
Constructor Details
-
AbstractH2StreamMultiplexer
AbstractH2StreamMultiplexer(ProtocolIOSession ioSession, FrameFactory frameFactory, StreamIdGenerator idGenerator, HttpProcessor httpProcessor, CharCodingConfig charCodingConfig, H2Config h2Config, H2StreamListener streamListener)
-
-
Method Details
-
getId
- Specified by:
getId
in interfaceIdentifiable
-
acceptHeaderFrame
- Throws:
H2ConnectionException
-
acceptPushRequest
- Throws:
H2ConnectionException
-
acceptPushFrame
- Throws:
H2ConnectionException
-
createRemotelyInitiatedStream
abstract H2StreamHandler createRemotelyInitiatedStream(H2StreamChannel channel, HttpProcessor httpProcessor, BasicHttpConnectionMetrics connMetrics, HandlerFactory<AsyncPushConsumer> pushHandlerFactory) throws IOException - Throws:
IOException
-
createLocallyInitiatedStream
abstract H2StreamHandler createLocallyInitiatedStream(ExecutableCommand command, H2StreamChannel channel, HttpProcessor httpProcessor, BasicHttpConnectionMetrics connMetrics) throws IOException - Throws:
IOException
-
updateWindow
- Throws:
ArithmeticException
-
updateInputWindow
private int updateInputWindow(int streamId, AtomicInteger window, int delta) throws ArithmeticException - Throws:
ArithmeticException
-
updateOutputWindow
private int updateOutputWindow(int streamId, AtomicInteger window, int delta) throws ArithmeticException - Throws:
ArithmeticException
-
commitFrameInternal
- Throws:
IOException
-
commitFrame
- Throws:
IOException
-
commitHeaders
private void commitHeaders(int streamId, List<? extends Header> headers, boolean endStream) throws IOException - Throws:
IOException
-
commitPushPromise
private void commitPushPromise(int streamId, int promisedStreamId, List<Header> headers) throws IOException - Throws:
IOException
-
streamDataFrame
private void streamDataFrame(int streamId, AtomicInteger streamOutputWindow, ByteBuffer payload, int chunk) throws IOException - Throws:
IOException
-
streamData
private int streamData(int streamId, AtomicInteger streamOutputWindow, ByteBuffer payload) throws IOException - Throws:
IOException
-
incrementInputCapacity
private void incrementInputCapacity(int streamId, AtomicInteger inputWindow, int inputCapacity) throws IOException - Throws:
IOException
-
requestSessionOutput
private void requestSessionOutput() -
updateLastStreamId
private void updateLastStreamId(int streamId) -
generateStreamId
private int generateStreamId() -
onConnect
- Throws:
HttpException
IOException
-
onInput
- Throws:
HttpException
IOException
-
onOutput
- Throws:
HttpException
IOException
-
onTimeout
- Throws:
HttpException
IOException
-
onDisconnect
public final void onDisconnect() -
processPendingCommands
- Throws:
IOException
HttpException
-
onException
-
getValidStream
private AbstractH2StreamMultiplexer.H2Stream getValidStream(int streamId) throws H2ConnectionException - Throws:
H2ConnectionException
-
consumeFrame
- Throws:
HttpException
IOException
-
consumeDataFrame
private void consumeDataFrame(RawFrame frame, AbstractH2StreamMultiplexer.H2Stream stream) throws HttpException, IOException - Throws:
HttpException
IOException
-
maximizeConnWindow
- Throws:
IOException
-
consumePushPromiseFrame
private void consumePushPromiseFrame(RawFrame frame, ByteBuffer payload, AbstractH2StreamMultiplexer.H2Stream promisedStream) throws HttpException, IOException - Throws:
HttpException
IOException
-
decodeHeaders
- Throws:
HttpException
-
consumeHeaderFrame
private void consumeHeaderFrame(RawFrame frame, AbstractH2StreamMultiplexer.H2Stream stream) throws HttpException, IOException - Throws:
HttpException
IOException
-
consumeContinuationFrame
private void consumeContinuationFrame(RawFrame frame, AbstractH2StreamMultiplexer.H2Stream stream) throws HttpException, IOException - Throws:
HttpException
IOException
-
consumeSettingsFrame
- Throws:
HttpException
IOException
-
produceOutput
- Throws:
HttpException
IOException
-
applyRemoteSettings
- Throws:
H2ConnectionException
-
applyLocalSettings
- Throws:
H2ConnectionException
-
close
Description copied from interface:HttpConnection
Closes this connection gracefully. This method will attempt to flush the internal output buffer prior to closing the underlying socket. This method MUST NOT be called from a different thread to force shutdown of the connection. Useshutdown
instead.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceHttpConnection
- Throws:
IOException
-
close
Description copied from interface:ModalCloseable
Closes this process or endpoint and releases any system resources associated with it. If the endpoint or the process is already closed then invoking this method has no effect.- Specified by:
close
in interfaceModalCloseable
- Parameters:
closeMode
- How to close the receiver.
-
isOpen
public boolean isOpen()Description copied from interface:HttpConnection
Checks if this connection is open.- Specified by:
isOpen
in interfaceHttpConnection
- Returns:
- true if it is open, false if it is closed.
-
setSocketTimeout
Description copied from interface:SocketModalCloseable
Sets the socket timeout value.- Specified by:
setSocketTimeout
in interfaceSocketModalCloseable
- Parameters:
timeout
- timeout value
-
getSSLSession
Description copied from interface:HttpConnection
Returns this connection's SSL session ornull
if TLS has not been activated.- Specified by:
getSSLSession
in interfaceHttpConnection
- Returns:
- this connection's SSL session or
null
if TLS has not been activated.
-
getEndpointDetails
Description copied from interface:HttpConnection
Returns this connection's endpoint details.- Specified by:
getEndpointDetails
in interfaceHttpConnection
- Returns:
- this connection's endpoint details.
-
getSocketTimeout
Description copied from interface:SocketModalCloseable
Returns the socket timeout value.- Specified by:
getSocketTimeout
in interfaceSocketModalCloseable
- Returns:
- timeout value.
-
getProtocolVersion
Description copied from interface:HttpConnection
Returns this connection's protocol version ornull
if unknown.- Specified by:
getProtocolVersion
in interfaceHttpConnection
- Returns:
- this connection's protocol version or
null
if unknown.
-
getRemoteAddress
Description copied from interface:HttpConnection
Returns this connection's remote address ornull
if it is not connected yet or unconnected.- Specified by:
getRemoteAddress
in interfaceHttpConnection
- Returns:
- this connection's remote address or
null
if it is not connected yet or unconnected.
-
getLocalAddress
Description copied from interface:HttpConnection
Returns this connection's local address ornull
if it is not bound yet.- Specified by:
getLocalAddress
in interfaceHttpConnection
- Returns:
- this connection's local address or
null
if it is not bound yet.
-
appendState
-