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 classAbstractH2StreamMultiplexer.ConnectionHandshakeprivate static classAbstractH2StreamMultiplexer.Continuation(package private) static classAbstractH2StreamMultiplexer.H2Streamprivate classAbstractH2StreamMultiplexer.H2StreamChannelImpl(package private) static classAbstractH2StreamMultiplexer.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 voidacceptHeaderFrame()(package private) abstract voidacceptPushFrame()(package private) abstract voidacceptPushRequest()(package private) voidappendState(java.lang.StringBuilder buf)private voidapplyLocalSettings()private voidapplyRemoteSettings(H2Config config)voidclose()Closes this connection gracefully.voidclose(CloseMode closeMode)Closes this process or endpoint and releases any system resources associated with it.private voidcommitFrame(RawFrame frame)private voidcommitFrameInternal(RawFrame frame)private voidcommitHeaders(int streamId, java.util.List<? extends Header> headers, boolean endStream)private voidcommitPushPromise(int streamId, int promisedStreamId, java.util.List<Header> headers)private voidconsumeContinuationFrame(RawFrame frame, AbstractH2StreamMultiplexer.H2Stream stream)private voidconsumeDataFrame(RawFrame frame, AbstractH2StreamMultiplexer.H2Stream stream)private voidconsumeFrame(RawFrame frame)private voidconsumeHeaderFrame(RawFrame frame, AbstractH2StreamMultiplexer.H2Stream stream)private voidconsumePushPromiseFrame(RawFrame frame, java.nio.ByteBuffer payload, AbstractH2StreamMultiplexer.H2Stream promisedStream)private voidconsumeSettingsFrame(java.nio.ByteBuffer payload)(package private) abstract H2StreamHandlercreateLocallyInitiatedStream(ExecutableCommand command, H2StreamChannel channel, HttpProcessor httpProcessor, BasicHttpConnectionMetrics connMetrics)(package private) abstract H2StreamHandlercreateRemotelyInitiatedStream(H2StreamChannel channel, HttpProcessor httpProcessor, BasicHttpConnectionMetrics connMetrics, HandlerFactory<AsyncPushConsumer> pushHandlerFactory)(package private) java.util.List<Header>decodeHeaders(java.nio.ByteBuffer payload)private intgenerateStreamId()EndpointDetailsgetEndpointDetails()Returns this connection's endpoint details.java.lang.StringgetId()java.net.SocketAddressgetLocalAddress()Returns this connection's local address ornullif it is not bound yet.ProtocolVersiongetProtocolVersion()Returns this connection's protocol version ornullif unknown.java.net.SocketAddressgetRemoteAddress()Returns this connection's remote address ornullif it is not connected yet or unconnected.TimeoutgetSocketTimeout()Returns the socket timeout value.javax.net.ssl.SSLSessiongetSSLSession()Returns this connection's SSL session ornullif TLS has not been activated.private AbstractH2StreamMultiplexer.H2StreamgetValidStream(int streamId)private voidincrementInputCapacity(int streamId, java.util.concurrent.atomic.AtomicInteger inputWindow, int inputCapacity)booleanisOpen()Checks if this connection is open.private voidmaximizeConnWindow(int connWinSize)voidonConnect()voidonDisconnect()voidonException(java.lang.Exception cause)voidonInput(java.nio.ByteBuffer src)voidonOutput()voidonTimeout(Timeout timeout)private voidprocessPendingCommands()private voidproduceOutput()private voidrequestSessionOutput()voidsetSocketTimeout(Timeout timeout)Sets the socket timeout value.private intstreamData(int streamId, java.util.concurrent.atomic.AtomicInteger streamOutputWindow, java.nio.ByteBuffer payload)private voidstreamDataFrame(int streamId, java.util.concurrent.atomic.AtomicInteger streamOutputWindow, java.nio.ByteBuffer payload, int chunk)private intupdateInputWindow(int streamId, java.util.concurrent.atomic.AtomicInteger window, int delta)private voidupdateLastStreamId(int streamId)private intupdateOutputWindow(int streamId, java.util.concurrent.atomic.AtomicInteger window, int delta)private intupdateWindow(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:
getIdin 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:
HttpExceptionjava.io.IOException
-
onInput
public final void onInput(java.nio.ByteBuffer src) throws HttpException, java.io.IOException- Throws:
HttpExceptionjava.io.IOException
-
onOutput
public final void onOutput() throws HttpException, java.io.IOException- Throws:
HttpExceptionjava.io.IOException
-
onTimeout
public final void onTimeout(Timeout timeout) throws HttpException, java.io.IOException
- Throws:
HttpExceptionjava.io.IOException
-
onDisconnect
public final void onDisconnect()
-
processPendingCommands
private void processPendingCommands() throws java.io.IOException, HttpException- Throws:
java.io.IOExceptionHttpException
-
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:
HttpExceptionjava.io.IOException
-
consumeDataFrame
private void consumeDataFrame(RawFrame frame, AbstractH2StreamMultiplexer.H2Stream stream) throws HttpException, java.io.IOException
- Throws:
HttpExceptionjava.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:
HttpExceptionjava.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:
HttpExceptionjava.io.IOException
-
consumeContinuationFrame
private void consumeContinuationFrame(RawFrame frame, AbstractH2StreamMultiplexer.H2Stream stream) throws HttpException, java.io.IOException
- Throws:
HttpExceptionjava.io.IOException
-
consumeSettingsFrame
private void consumeSettingsFrame(java.nio.ByteBuffer payload) throws HttpException, java.io.IOException- Throws:
HttpExceptionjava.io.IOException
-
produceOutput
private void produceOutput() throws HttpException, java.io.IOException- Throws:
HttpExceptionjava.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.IOExceptionDescription copied from interface:HttpConnectionCloses 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. Useshutdowninstead.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein interfaceHttpConnection- Throws:
java.io.IOException
-
close
public void close(CloseMode closeMode)
Description copied from interface:ModalCloseableCloses 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:
closein interfaceModalCloseable- Parameters:
closeMode- How to close the receiver.
-
isOpen
public boolean isOpen()
Description copied from interface:HttpConnectionChecks if this connection is open.- Specified by:
isOpenin interfaceHttpConnection- Returns:
- true if it is open, false if it is closed.
-
setSocketTimeout
public void setSocketTimeout(Timeout timeout)
Description copied from interface:SocketModalCloseableSets the socket timeout value.- Specified by:
setSocketTimeoutin interfaceSocketModalCloseable- Parameters:
timeout- timeout value
-
getSSLSession
public javax.net.ssl.SSLSession getSSLSession()
Description copied from interface:HttpConnectionReturns this connection's SSL session ornullif TLS has not been activated.- Specified by:
getSSLSessionin interfaceHttpConnection- Returns:
- this connection's SSL session or
nullif TLS has not been activated.
-
getEndpointDetails
public EndpointDetails getEndpointDetails()
Description copied from interface:HttpConnectionReturns this connection's endpoint details.- Specified by:
getEndpointDetailsin interfaceHttpConnection- Returns:
- this connection's endpoint details.
-
getSocketTimeout
public Timeout getSocketTimeout()
Description copied from interface:SocketModalCloseableReturns the socket timeout value.- Specified by:
getSocketTimeoutin interfaceSocketModalCloseable- Returns:
- timeout value.
-
getProtocolVersion
public ProtocolVersion getProtocolVersion()
Description copied from interface:HttpConnectionReturns this connection's protocol version ornullif unknown.- Specified by:
getProtocolVersionin interfaceHttpConnection- Returns:
- this connection's protocol version or
nullif unknown.
-
getRemoteAddress
public java.net.SocketAddress getRemoteAddress()
Description copied from interface:HttpConnectionReturns this connection's remote address ornullif it is not connected yet or unconnected.- Specified by:
getRemoteAddressin interfaceHttpConnection- Returns:
- this connection's remote address or
nullif it is not connected yet or unconnected.
-
getLocalAddress
public java.net.SocketAddress getLocalAddress()
Description copied from interface:HttpConnectionReturns this connection's local address ornullif it is not bound yet.- Specified by:
getLocalAddressin interfaceHttpConnection- Returns:
- this connection's local address or
nullif it is not bound yet.
-
appendState
void appendState(java.lang.StringBuilder buf)
-
-