Class AbstractH2StreamMultiplexer
- java.lang.Object
-
- org.apache.hc.core5.http2.impl.nio.AbstractH2StreamMultiplexer
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,HttpConnection
,SocketModalCloseable
,ModalCloseable
,Identifiable
- Direct Known Subclasses:
ClientH2StreamMultiplexer
,ServerH2StreamMultiplexer
abstract class AbstractH2StreamMultiplexer extends java.lang.Object implements Identifiable, HttpConnection
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
AbstractH2StreamMultiplexer.ConnectionHandshake
private static class
AbstractH2StreamMultiplexer.Continuation
(package private) static class
AbstractH2StreamMultiplexer.H2Stream
private class
AbstractH2StreamMultiplexer.H2StreamChannelImpl
(package private) static class
AbstractH2StreamMultiplexer.SettingsHandshake
-
Field Summary
-
Constructor Summary
Constructors Constructor Description AbstractH2StreamMultiplexer(ProtocolIOSession ioSession, FrameFactory frameFactory, StreamIdGenerator idGenerator, HttpProcessor httpProcessor, CharCodingConfig charCodingConfig, H2Config h2Config, H2StreamListener streamListener)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description (package private) abstract void
acceptHeaderFrame()
(package private) abstract void
acceptPushFrame()
(package private) abstract void
acceptPushRequest()
(package private) void
appendState(java.lang.StringBuilder buf)
private void
applyLocalSettings()
private void
applyRemoteSettings(H2Config config)
void
close()
Closes this connection gracefully.void
close(CloseMode closeMode)
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, java.util.List<? extends Header> headers, boolean endStream)
private void
commitPushPromise(int streamId, int promisedStreamId, java.util.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, java.nio.ByteBuffer payload, AbstractH2StreamMultiplexer.H2Stream promisedStream)
private void
consumeSettingsFrame(java.nio.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)
(package private) java.util.List<Header>
decodeHeaders(java.nio.ByteBuffer payload)
private int
generateStreamId()
EndpointDetails
getEndpointDetails()
Returns this connection's endpoint details.java.lang.String
getId()
java.net.SocketAddress
getLocalAddress()
Returns this connection's local address ornull
if it is not bound yet.ProtocolVersion
getProtocolVersion()
Returns this connection's protocol version ornull
if unknown.java.net.SocketAddress
getRemoteAddress()
Returns this connection's remote address ornull
if it is not connected yet or unconnected.Timeout
getSocketTimeout()
Returns the socket timeout value.javax.net.ssl.SSLSession
getSSLSession()
Returns this connection's SSL session ornull
if TLS has not been activated.private AbstractH2StreamMultiplexer.H2Stream
getValidStream(int streamId)
private void
incrementInputCapacity(int streamId, java.util.concurrent.atomic.AtomicInteger inputWindow, int inputCapacity)
boolean
isOpen()
Checks if this connection is open.private void
maximizeConnWindow(int connWinSize)
void
onConnect()
void
onDisconnect()
void
onException(java.lang.Exception cause)
void
onInput(java.nio.ByteBuffer src)
void
onOutput()
void
onTimeout(Timeout timeout)
private void
processPendingCommands()
private void
produceOutput()
private void
requestSessionOutput()
void
setSocketTimeout(Timeout timeout)
Sets the socket timeout value.private int
streamData(int streamId, java.util.concurrent.atomic.AtomicInteger streamOutputWindow, java.nio.ByteBuffer payload)
private void
streamDataFrame(int streamId, java.util.concurrent.atomic.AtomicInteger streamOutputWindow, java.nio.ByteBuffer payload, int chunk)
private int
updateInputWindow(int streamId, java.util.concurrent.atomic.AtomicInteger window, int delta)
private void
updateLastStreamId(int streamId)
private int
updateOutputWindow(int streamId, java.util.concurrent.atomic.AtomicInteger window, int delta)
private int
updateWindow(java.util.concurrent.atomic.AtomicInteger window, int delta)
-
-
-
Field Detail
-
LINGER_TIME
private static final long LINGER_TIME
- See Also:
- Constant Field Values
-
CONNECTION_WINDOW_LOW_MARK
private static final long CONNECTION_WINDOW_LOW_MARK
- See Also:
- Constant Field Values
-
ioSession
private final ProtocolIOSession ioSession
-
frameFactory
private final FrameFactory frameFactory
-
idGenerator
private final StreamIdGenerator idGenerator
-
httpProcessor
private final HttpProcessor httpProcessor
-
localConfig
private final H2Config localConfig
-
inputMetrics
private final BasicH2TransportMetrics inputMetrics
-
outputMetrics
private final BasicH2TransportMetrics outputMetrics
-
connMetrics
private final BasicHttpConnectionMetrics connMetrics
-
inputBuffer
private final FrameInputBuffer inputBuffer
-
outputBuffer
private final FrameOutputBuffer outputBuffer
-
outputQueue
private final java.util.Deque<RawFrame> outputQueue
-
hPackEncoder
private final HPackEncoder hPackEncoder
-
hPackDecoder
private final HPackDecoder hPackDecoder
-
streamMap
private final java.util.Map<java.lang.Integer,AbstractH2StreamMultiplexer.H2Stream> streamMap
-
pingHandlers
private final java.util.Queue<AsyncPingHandler> pingHandlers
-
connInputWindow
private final java.util.concurrent.atomic.AtomicInteger connInputWindow
-
connOutputWindow
private final java.util.concurrent.atomic.AtomicInteger connOutputWindow
-
outputRequests
private final java.util.concurrent.atomic.AtomicInteger outputRequests
-
lastStreamId
private final java.util.concurrent.atomic.AtomicInteger lastStreamId
-
streamListener
private final H2StreamListener streamListener
-
connState
private AbstractH2StreamMultiplexer.ConnectionHandshake connState
-
localSettingState
private AbstractH2StreamMultiplexer.SettingsHandshake localSettingState
-
remoteSettingState
private AbstractH2StreamMultiplexer.SettingsHandshake remoteSettingState
-
initInputWinSize
private int initInputWinSize
-
initOutputWinSize
private int initOutputWinSize
-
lowMark
private int lowMark
-
remoteConfig
private volatile H2Config remoteConfig
-
continuation
private AbstractH2StreamMultiplexer.Continuation continuation
-
processedRemoteStreamId
private int processedRemoteStreamId
-
endpointDetails
private EndpointDetails endpointDetails
-
goAwayReceived
private boolean goAwayReceived
-
-
Constructor Detail
-
AbstractH2StreamMultiplexer
AbstractH2StreamMultiplexer(ProtocolIOSession ioSession, FrameFactory frameFactory, StreamIdGenerator idGenerator, HttpProcessor httpProcessor, CharCodingConfig charCodingConfig, H2Config h2Config, H2StreamListener streamListener)
-
-
Method Detail
-
getId
public java.lang.String getId()
- Specified by:
getId
in interfaceIdentifiable
-
acceptHeaderFrame
abstract void acceptHeaderFrame() throws H2ConnectionException
- Throws:
H2ConnectionException
-
acceptPushRequest
abstract void acceptPushRequest() throws H2ConnectionException
- Throws:
H2ConnectionException
-
acceptPushFrame
abstract void acceptPushFrame() throws H2ConnectionException
- Throws:
H2ConnectionException
-
createRemotelyInitiatedStream
abstract H2StreamHandler createRemotelyInitiatedStream(H2StreamChannel channel, HttpProcessor httpProcessor, BasicHttpConnectionMetrics connMetrics, HandlerFactory<AsyncPushConsumer> pushHandlerFactory) throws java.io.IOException
- Throws:
java.io.IOException
-
createLocallyInitiatedStream
abstract H2StreamHandler createLocallyInitiatedStream(ExecutableCommand command, H2StreamChannel channel, HttpProcessor httpProcessor, BasicHttpConnectionMetrics connMetrics) throws java.io.IOException
- Throws:
java.io.IOException
-
updateWindow
private int updateWindow(java.util.concurrent.atomic.AtomicInteger window, int delta) throws java.lang.ArithmeticException
- Throws:
java.lang.ArithmeticException
-
updateInputWindow
private int updateInputWindow(int streamId, java.util.concurrent.atomic.AtomicInteger window, int delta) throws java.lang.ArithmeticException
- Throws:
java.lang.ArithmeticException
-
updateOutputWindow
private int updateOutputWindow(int streamId, java.util.concurrent.atomic.AtomicInteger window, int delta) throws java.lang.ArithmeticException
- Throws:
java.lang.ArithmeticException
-
commitFrameInternal
private void commitFrameInternal(RawFrame frame) throws java.io.IOException
- Throws:
java.io.IOException
-
commitFrame
private void commitFrame(RawFrame frame) throws java.io.IOException
- Throws:
java.io.IOException
-
commitHeaders
private void commitHeaders(int streamId, java.util.List<? extends Header> headers, boolean endStream) throws java.io.IOException
- Throws:
java.io.IOException
-
commitPushPromise
private void commitPushPromise(int streamId, int promisedStreamId, java.util.List<Header> headers) throws java.io.IOException
- Throws:
java.io.IOException
-
streamDataFrame
private void streamDataFrame(int streamId, java.util.concurrent.atomic.AtomicInteger streamOutputWindow, java.nio.ByteBuffer payload, int chunk) throws java.io.IOException
- Throws:
java.io.IOException
-
streamData
private int streamData(int streamId, java.util.concurrent.atomic.AtomicInteger streamOutputWindow, java.nio.ByteBuffer payload) throws java.io.IOException
- Throws:
java.io.IOException
-
incrementInputCapacity
private void incrementInputCapacity(int streamId, java.util.concurrent.atomic.AtomicInteger inputWindow, int inputCapacity) throws java.io.IOException
- Throws:
java.io.IOException
-
requestSessionOutput
private void requestSessionOutput()
-
updateLastStreamId
private void updateLastStreamId(int streamId)
-
generateStreamId
private int generateStreamId()
-
onConnect
public final void onConnect() throws HttpException, java.io.IOException
- Throws:
HttpException
java.io.IOException
-
onInput
public final void onInput(java.nio.ByteBuffer src) throws HttpException, java.io.IOException
- Throws:
HttpException
java.io.IOException
-
onOutput
public final void onOutput() throws HttpException, java.io.IOException
- Throws:
HttpException
java.io.IOException
-
onTimeout
public final void onTimeout(Timeout timeout) throws HttpException, java.io.IOException
- Throws:
HttpException
java.io.IOException
-
onDisconnect
public final void onDisconnect()
-
processPendingCommands
private void processPendingCommands() throws java.io.IOException, HttpException
- Throws:
java.io.IOException
HttpException
-
onException
public final void onException(java.lang.Exception cause)
-
getValidStream
private AbstractH2StreamMultiplexer.H2Stream getValidStream(int streamId) throws H2ConnectionException
- Throws:
H2ConnectionException
-
consumeFrame
private void consumeFrame(RawFrame frame) throws HttpException, java.io.IOException
- Throws:
HttpException
java.io.IOException
-
consumeDataFrame
private void consumeDataFrame(RawFrame frame, AbstractH2StreamMultiplexer.H2Stream stream) throws HttpException, java.io.IOException
- Throws:
HttpException
java.io.IOException
-
maximizeConnWindow
private void maximizeConnWindow(int connWinSize) throws java.io.IOException
- Throws:
java.io.IOException
-
consumePushPromiseFrame
private void consumePushPromiseFrame(RawFrame frame, java.nio.ByteBuffer payload, AbstractH2StreamMultiplexer.H2Stream promisedStream) throws HttpException, java.io.IOException
- Throws:
HttpException
java.io.IOException
-
decodeHeaders
java.util.List<Header> decodeHeaders(java.nio.ByteBuffer payload) throws HttpException
- Throws:
HttpException
-
consumeHeaderFrame
private void consumeHeaderFrame(RawFrame frame, AbstractH2StreamMultiplexer.H2Stream stream) throws HttpException, java.io.IOException
- Throws:
HttpException
java.io.IOException
-
consumeContinuationFrame
private void consumeContinuationFrame(RawFrame frame, AbstractH2StreamMultiplexer.H2Stream stream) throws HttpException, java.io.IOException
- Throws:
HttpException
java.io.IOException
-
consumeSettingsFrame
private void consumeSettingsFrame(java.nio.ByteBuffer payload) throws HttpException, java.io.IOException
- Throws:
HttpException
java.io.IOException
-
produceOutput
private void produceOutput() throws HttpException, java.io.IOException
- Throws:
HttpException
java.io.IOException
-
applyRemoteSettings
private void applyRemoteSettings(H2Config config) throws H2ConnectionException
- Throws:
H2ConnectionException
-
applyLocalSettings
private void applyLocalSettings() throws H2ConnectionException
- Throws:
H2ConnectionException
-
close
public void close() throws java.io.IOException
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 interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in interfaceHttpConnection
- Throws:
java.io.IOException
-
close
public void close(CloseMode closeMode)
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
public void setSocketTimeout(Timeout timeout)
Description copied from interface:SocketModalCloseable
Sets the socket timeout value.- Specified by:
setSocketTimeout
in interfaceSocketModalCloseable
- Parameters:
timeout
- timeout value
-
getSSLSession
public javax.net.ssl.SSLSession 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
public EndpointDetails getEndpointDetails()
Description copied from interface:HttpConnection
Returns this connection's endpoint details.- Specified by:
getEndpointDetails
in interfaceHttpConnection
- Returns:
- this connection's endpoint details.
-
getSocketTimeout
public Timeout getSocketTimeout()
Description copied from interface:SocketModalCloseable
Returns the socket timeout value.- Specified by:
getSocketTimeout
in interfaceSocketModalCloseable
- Returns:
- timeout value.
-
getProtocolVersion
public ProtocolVersion 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
public java.net.SocketAddress 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
public java.net.SocketAddress 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
void appendState(java.lang.StringBuilder buf)
-
-