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) 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) abstract booleanallowGracefulAbort(H2Stream stream)(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, H2Stream stream)private voidconsumeDataFrame(RawFrame frame, H2Stream stream)private voidconsumeFrame(RawFrame frame)private voidconsumeHeaderFrame(RawFrame frame, H2Stream stream)private voidconsumePushPromiseFrame(RawFrame frame, java.nio.ByteBuffer payload, H2Stream promisedStream)private voidconsumeSettingsFrame(java.nio.ByteBuffer payload)(package private) H2StreamChannelcreateChannel(int streamId)(package private) H2StreamcreateStream(H2StreamChannel channel, H2StreamHandler streamHandler)(package private) java.util.List<Header>decodeHeaders(java.nio.ByteBuffer payload)private voidexecutePing(PingCommand pingCommand)private voidexecutePush(PushResponseCommand pushResponseCommand)private voidexecuteRequest(RequestExecutionCommand requestExecutionCommand)private voidexecuteShutdown(ShutdownCommand shutdownCommand)private voidexecuteStaleCheck(StaleCheckCommand staleCheckCommand)(package private) abstract H2Setting[]generateSettings(H2Config localConfig)(package private) BasicHttpConnectionMetricsgetConnMetrics()EndpointDetailsgetEndpointDetails()Returns this connection's endpoint details.(package private) HttpProcessorgetHttpProcessor()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.(package private) abstract H2StreamHandlerincomingPushPromise(H2StreamChannel channel, HandlerFactory<AsyncPushConsumer> pushHandlerFactory)(package private) abstract H2StreamHandlerincomingRequest(H2StreamChannel channel)private voidincrementInputCapacity(int streamId, java.util.concurrent.atomic.AtomicInteger inputWindow, int inputCapacity)booleanisOpen()Checks if this connection is open.private voidmaximizeWindow(int streamId, java.util.concurrent.atomic.AtomicInteger window)voidonConnect()voidonDisconnect()voidonException(java.lang.Exception cause)voidonInput(java.nio.ByteBuffer src)voidonOutput()voidonTimeout(Timeout timeout)(package private) abstract H2StreamHandleroutgoingPushPromise(H2StreamChannel channel, AsyncPushProducer pushProducer)(package private) abstract H2StreamHandleroutgoingRequest(H2StreamChannel channel, AsyncClientExchangeHandler exchangeHandler, HandlerFactory<AsyncPushConsumer> pushHandlerFactory, HttpContext context)private PriorityValueparsePriorityValue(java.lang.String field)private PriorityValueparsePriorityValue(Header header)private voidproduceOutput()private voidrecordPriorityFromHeaders(H2Stream stream, java.util.List<? extends Header> headers)(package 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)(package private) voidsubmitCommand(Command command)private intupdateInputWindow(int streamId, java.util.concurrent.atomic.AtomicInteger window, int delta)private intupdateOutputWindow(int streamId, java.util.concurrent.atomic.AtomicInteger window, int delta)private intupdateWindow(java.util.concurrent.atomic.AtomicInteger window, int delta)private intupdateWindowMax(java.util.concurrent.atomic.AtomicInteger window)(package private) abstract voidvalidateSetting(H2Param param, int value)
-
-
-
Field Detail
-
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
-
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
-
streams
private final H2Streams streams
-
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
-
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
-
endpointDetails
private EndpointDetails endpointDetails
-
goAwayReceived
private boolean goAwayReceived
-
peerNoRfc7540Priorities
private volatile boolean peerNoRfc7540Priorities
-
-
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
-
getConnMetrics
BasicHttpConnectionMetrics getConnMetrics()
-
getHttpProcessor
HttpProcessor getHttpProcessor()
-
submitCommand
void submitCommand(Command command)
-
validateSetting
abstract void validateSetting(H2Param param, int value) throws H2ConnectionException
- Throws:
H2ConnectionException
-
acceptHeaderFrame
abstract void acceptHeaderFrame() throws H2ConnectionException- Throws:
H2ConnectionException
-
acceptPushRequest
abstract void acceptPushRequest() throws H2ConnectionException- Throws:
H2ConnectionException
-
acceptPushFrame
abstract void acceptPushFrame() throws H2ConnectionException- Throws:
H2ConnectionException
-
incomingRequest
abstract H2StreamHandler incomingRequest(H2StreamChannel channel) throws java.io.IOException
- Throws:
java.io.IOException
-
incomingPushPromise
abstract H2StreamHandler incomingPushPromise(H2StreamChannel channel, HandlerFactory<AsyncPushConsumer> pushHandlerFactory) throws java.io.IOException
- Throws:
java.io.IOException
-
outgoingRequest
abstract H2StreamHandler outgoingRequest(H2StreamChannel channel, AsyncClientExchangeHandler exchangeHandler, HandlerFactory<AsyncPushConsumer> pushHandlerFactory, HttpContext context) throws java.io.IOException
- Throws:
java.io.IOException
-
outgoingPushPromise
abstract H2StreamHandler outgoingPushPromise(H2StreamChannel channel, AsyncPushProducer pushProducer) throws java.io.IOException
- Throws:
java.io.IOException
-
allowGracefulAbort
abstract boolean allowGracefulAbort(H2Stream stream)
-
updateWindow
private int updateWindow(java.util.concurrent.atomic.AtomicInteger window, int delta) throws java.lang.ArithmeticException- Throws:
java.lang.ArithmeticException
-
updateWindowMax
private int updateWindowMax(java.util.concurrent.atomic.AtomicInteger window) 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
void requestSessionOutput()
-
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()
-
executeShutdown
private void executeShutdown(ShutdownCommand shutdownCommand) throws java.io.IOException
- Throws:
java.io.IOException
-
executePing
private void executePing(PingCommand pingCommand) throws java.io.IOException
- Throws:
java.io.IOException
-
executeStaleCheck
private void executeStaleCheck(StaleCheckCommand staleCheckCommand)
-
executeRequest
private void executeRequest(RequestExecutionCommand requestExecutionCommand) throws java.io.IOException, HttpException
- Throws:
java.io.IOExceptionHttpException
-
executePush
private void executePush(PushResponseCommand pushResponseCommand) throws java.io.IOException, HttpException
- Throws:
java.io.IOExceptionHttpException
-
onException
public final void onException(java.lang.Exception cause)
-
consumeFrame
private void consumeFrame(RawFrame frame) throws HttpException, java.io.IOException
- Throws:
HttpExceptionjava.io.IOException
-
consumeDataFrame
private void consumeDataFrame(RawFrame frame, H2Stream stream) throws HttpException, java.io.IOException
- Throws:
HttpExceptionjava.io.IOException
-
maximizeWindow
private void maximizeWindow(int streamId, java.util.concurrent.atomic.AtomicInteger window) throws java.io.IOException- Throws:
java.io.IOException
-
consumePushPromiseFrame
private void consumePushPromiseFrame(RawFrame frame, java.nio.ByteBuffer payload, 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, H2Stream stream) throws HttpException, java.io.IOException
- Throws:
HttpExceptionjava.io.IOException
-
consumeContinuationFrame
private void consumeContinuationFrame(RawFrame frame, H2Stream stream) throws HttpException, java.io.IOException
- Throws:
HttpExceptionjava.io.IOException
-
consumeSettingsFrame
private void consumeSettingsFrame(java.nio.ByteBuffer payload) throws java.io.IOException- Throws:
java.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. Useclose(CloseMode.IMMEDIATE)instead.- 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)
-
createChannel
H2StreamChannel createChannel(int streamId)
-
createStream
H2Stream createStream(H2StreamChannel channel, H2StreamHandler streamHandler) throws H2ConnectionException
- Throws:
H2ConnectionException
-
recordPriorityFromHeaders
private void recordPriorityFromHeaders(H2Stream stream, java.util.List<? extends Header> headers)
-
parsePriorityValue
private PriorityValue parsePriorityValue(Header header)
-
parsePriorityValue
private PriorityValue parsePriorityValue(java.lang.String field)
-
-