Http2ConnectionEncoder that dispatches all method call to another
Http2ConnectionEncoder, until SETTINGS_MAX_CONCURRENT_STREAMS is reached.
When this limit is hit, instead of rejecting any new streams this implementation buffers newly created streams and their corresponding frames. Once an active stream gets closed or the maximum number of concurrent streams is increased, this encoder will automatically try to empty its buffer and create as many new streams as possible.
If a GOAWAY frame is received from the remote endpoint, all buffered writes for streams
with an ID less than the specified lastStreamId will immediately fail with a
Http2GoAwayException.
If the channel/encoder gets closed, all new and buffered writes will immediately fail with a
Http2ChannelClosedException.
This implementation makes the buffering mostly transparent and is expected to be used as a
drop-in decorator of DefaultHttp2ConnectionEncoder.
| Modifier and Type | Class and Description |
|---|---|
| private class | |
| private abstract static class | |
| private static class | |
| private class | |
| public static class | StreamBufferingEncoder.Http2ChannelClosedException
Thrown if buffered streams are terminated due to this encoder being closed. |
| public static class | StreamBufferingEncoder.Http2GoAwayException
Thrown by |
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private boolean | |
| private StreamBufferingEncoder. | |
| private int | |
| private final TreeMap | pendingStreams
Buffer for any streams and corresponding frames that could not be created due to the maximum concurrent stream limit being hit. |
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| private boolean | |
| public void | close()
Overrides io. Implements io. |
| private boolean | |
| public int | |
| public void | remoteSettings(Http2Settings settings)
Overrides io. Implements io. |
| private void | |
| public ChannelFuture | writeData(ChannelHandlerContext
the context to use for writing. ctx, int the stream for which to send the frame. streamId, ByteBuf the payload of the frame. This will be released by this method. data, int additional bytes that should be added to obscure the true content size. Must be between 0 and
256 (inclusive). A 1 byte padding is encoded as just the pad length field with value 0.
A 256 byte padding is encoded as the pad length field with value 255 and 255 padding bytes
appended to the end of the frame. padding, boolean indicates if this is the last frame to be sent for the stream. endOfStream, ChannelPromise the promise for the write. promise)Overrides io. Implements io. DATA frame to the remote endpoint.
|
| public ChannelFuture | writeHeaders(ChannelHandlerContext
the context to use for writing. ctx, int the stream for which to send the frame. streamId, Http2Headers the headers to be sent. headers, int additional bytes that should be added to obscure the true content size. Must be between 0 and
256 (inclusive). padding, boolean indicates if this is the last frame to be sent for the stream. endStream, ChannelPromise the promise for the write. promise)Overrides io. Implements io. |
| public ChannelFuture | writeHeaders(ChannelHandlerContext
the context to use for writing. ctx, int the stream for which to send the frame. streamId, Http2Headers the headers to be sent. headers, int the stream on which this stream should depend, or 0 if it should
depend on the connection. streamDependency, short the weight for this stream. weight, boolean whether this stream should be the exclusive dependant of its parent. exclusive, int additional bytes that should be added to obscure the true content size. Must be between 0 and
256 (inclusive). padding, boolean indicates if this is the last frame to be sent for the stream. endOfStream, ChannelPromise the promise for the write. promise)Overrides io. Implements io. |
| public ChannelFuture | writeRstStream(ChannelHandlerContext
the context to use for writing. ctx, int the stream for which to send the frame. streamId, long the error code indicating the nature of the failure. errorCode, ChannelPromise the promise for the write. promise)Overrides io. Implements io. |
| closed | back to summary |
|---|---|
| private boolean closed | |
| goAwayDetail | back to summary |
|---|---|
| private StreamBufferingEncoder. | |
| maxConcurrentStreams | back to summary |
|---|---|
| private int maxConcurrentStreams | |
| pendingStreams | back to summary |
|---|---|
| private final TreeMap<Integer, StreamBufferingEncoder. Buffer for any streams and corresponding frames that could not be created due to the maximum concurrent stream limit being hit. | |
| StreamBufferingEncoder | back to summary |
|---|---|
| public StreamBufferingEncoder(Http2ConnectionEncoder delegate) | |
| StreamBufferingEncoder | back to summary |
|---|---|
| public StreamBufferingEncoder(Http2ConnectionEncoder delegate, int initialMaxConcurrentStreams) | |
| cancelGoAwayStreams | back to summary |
|---|---|
| private void cancelGoAwayStreams(StreamBufferingEncoder. | |
| canCreateStream | back to summary |
|---|---|
| private boolean canCreateStream() Determines whether or not we're allowed to create a new stream right now. | |
| close | back to summary |
|---|---|
| public void close() Overrides io. Implements io. Doc from io. Closes this writer and frees any allocated resources.
| |
| isExistingStream | back to summary |
|---|---|
| private boolean isExistingStream(int streamId) | |
| numBufferedStreams | back to summary |
|---|---|
| public int numBufferedStreams() Indicates the number of streams that are currently buffered, awaiting creation. | |
| remoteSettings | back to summary |
|---|---|
| public void remoteSettings(Http2Settings settings) throws Http2Exception Overrides io. Implements io. Doc from io. Sets the settings for the remote endpoint of the HTTP/2 connection.
| |
| tryCreatePendingStreams | back to summary |
|---|---|
| private void tryCreatePendingStreams() | |
| writeData | back to summary |
|---|---|
| public ChannelFuture writeData(ChannelHandlerContext ctx, int streamId, ByteBuf data, int padding, boolean endOfStream, ChannelPromise promise) Overrides io. Implements io. Doc from io. Writes a
| |
| writeHeaders | back to summary |
|---|---|
| public ChannelFuture writeHeaders(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int padding, boolean endStream, ChannelPromise promise) Overrides io. Implements io. Doc from io. Writes a HEADERS frame to the remote endpoint.
| |
| writeHeaders | back to summary |
|---|---|
| public ChannelFuture writeHeaders(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int streamDependency, short weight, boolean exclusive, int padding, boolean endOfStream, ChannelPromise promise) Overrides io. Implements io. Doc from io. Writes a HEADERS frame with priority specified to the remote endpoint.
| |
| writeRstStream | back to summary |
|---|---|
| public ChannelFuture writeRstStream(ChannelHandlerContext ctx, int streamId, long errorCode, ChannelPromise promise) Overrides io. Implements io. Doc from io. Writes a RST_STREAM frame to the remote endpoint.
| |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv final ByteBuf | |
| pack-priv final boolean | |
| pack-priv final int |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv void | release(Throwable t)
Overrides io. |
| pack-priv void | send(ChannelHandlerContext ctx, int streamId)
Implements abstract io. |
| data | back to summary |
|---|---|
| pack-priv final ByteBuf data | |
| endOfStream | back to summary |
|---|---|
| pack-priv final boolean endOfStream | |
| padding | back to summary |
|---|---|
| pack-priv final int padding | |
| DataFrame | back to summary |
|---|---|
| pack-priv DataFrame(ByteBuf data, int padding, boolean endOfStream, ChannelPromise promise) | |
| release | back to summary |
|---|---|
| pack-priv void release(Throwable t) Overrides io. Doc from io. Release any resources (features, buffers, ...) associated with the frame.
| |
| send | back to summary |
|---|---|
| pack-priv void send(ChannelHandlerContext ctx, int streamId) Implements abstract io.
| |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv final ChannelPromise |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv void | |
| pack-priv abstract void |
| promise | back to summary |
|---|---|
| pack-priv final ChannelPromise promise | |
| Frame | back to summary |
|---|---|
| pack-priv Frame(ChannelPromise promise) | |
| release | back to summary |
|---|---|
| pack-priv void release(Throwable t) Release any resources (features, buffers, ...) associated with the frame. | |
| send | back to summary |
|---|---|
| pack-priv abstract void send(ChannelHandlerContext ctx, int streamId) | |
| Modifier and Type | Field and Description |
|---|---|
| private final byte[] | |
| private final long | |
| private final int |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| debugData | back to summary |
|---|---|
| private final byte[] debugData | |
| errorCode | back to summary |
|---|---|
| private final long errorCode | |
| lastStreamId | back to summary |
|---|---|
| private final int lastStreamId | |
| GoAwayDetail | back to summary |
|---|---|
| pack-priv GoAwayDetail(int lastStreamId, long errorCode, byte[] debugData) | |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv final boolean | |
| pack-priv final boolean | |
| pack-priv final Http2Headers | |
| pack-priv final int | |
| pack-priv final int | |
| pack-priv final short |
| Access | Constructor and Description |
|---|---|
| pack-priv | HeadersFrame(Http2Headers headers, int streamDependency, short weight, boolean exclusive, int padding, boolean endOfStream, ChannelPromise promise)
|
| Modifier and Type | Method and Description |
|---|---|
| pack-priv void | send(ChannelHandlerContext ctx, int streamId)
Implements abstract io. |
| endOfStream | back to summary |
|---|---|
| pack-priv final boolean endOfStream | |
| exclusive | back to summary |
|---|---|
| pack-priv final boolean exclusive | |
| headers | back to summary |
|---|---|
| pack-priv final Http2Headers headers | |
| padding | back to summary |
|---|---|
| pack-priv final int padding | |
| streamDependency | back to summary |
|---|---|
| pack-priv final int streamDependency | |
| weight | back to summary |
|---|---|
| pack-priv final short weight | |
| HeadersFrame | back to summary |
|---|---|
| pack-priv HeadersFrame(Http2Headers headers, int streamDependency, short weight, boolean exclusive, int padding, boolean endOfStream, ChannelPromise promise) | |
| send | back to summary |
|---|---|
| pack-priv void send(ChannelHandlerContext ctx, int streamId) Implements abstract io.
| |
| Modifier and Type | Field and Description |
|---|---|
| private static final long |
| Access | Constructor and Description |
|---|---|
| public |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Hides io. | |
| Http2ChannelClosedException | back to summary |
|---|---|
| public Http2ChannelClosedException() | |
StreamBufferingEncoder if buffered streams are terminated due to
receipt of a GOAWAY.
| Modifier and Type | Field and Description |
|---|---|
| private final StreamBufferingEncoder. | |
| private static final long |
| Access | Constructor and Description |
|---|---|
| public | |
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public byte[] | |
| public long | |
| public int |
| goAwayDetail | back to summary |
|---|---|
| private final StreamBufferingEncoder. | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Hides io. | |
| Http2GoAwayException | back to summary |
|---|---|
| public Http2GoAwayException(int lastStreamId, long errorCode, byte[] debugData) | |
| Http2GoAwayException | back to summary |
|---|---|
| pack-priv Http2GoAwayException(StreamBufferingEncoder. | |
| debugData | back to summary |
|---|---|
| public byte[] debugData() | |
| errorCode | back to summary |
|---|---|
| public long errorCode() | |
| lastStreamId | back to summary |
|---|---|
| public int lastStreamId() | |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv final ChannelHandlerContext | |
| pack-priv final Queue | |
| pack-priv final int |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv void | |
| pack-priv void |
| ctx | back to summary |
|---|---|
| pack-priv final ChannelHandlerContext ctx | |
| frames | back to summary |
|---|---|
| pack-priv final Queue<StreamBufferingEncoder. | |
| streamId | back to summary |
|---|---|
| pack-priv final int streamId | |
| PendingStream | back to summary |
|---|---|
| pack-priv PendingStream(ChannelHandlerContext ctx, int streamId) | |
| close | back to summary |
|---|---|
| pack-priv void close(Throwable t) | |
| sendFrames | back to summary |
|---|---|
| pack-priv void sendFrames() | |