@UnstableApi public class StreamBufferingEncoder extends DecoratingHttp2ConnectionEncoder
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
StreamBufferingEncoder.Http2GoAwayException.
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 |
|---|---|
static class |
StreamBufferingEncoder.Http2ChannelClosedException
Thrown if buffered streams are terminated due to this encoder being closed.
|
static class |
StreamBufferingEncoder.Http2GoAwayException
Thrown by
StreamBufferingEncoder if buffered streams are terminated due to
receipt of a GOAWAY. |
Http2FrameWriter.Configuration| Constructor and Description |
|---|
StreamBufferingEncoder(Http2ConnectionEncoder delegate) |
StreamBufferingEncoder(Http2ConnectionEncoder delegate,
int initialMaxConcurrentStreams) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes this writer and frees any allocated resources.
|
int |
numBufferedStreams()
Indicates the number of streams that are currently buffered, awaiting creation.
|
void |
remoteSettings(Http2Settings settings)
Sets the settings for the remote endpoint of the HTTP/2 connection.
|
ChannelFuture |
writeData(ChannelHandlerContext ctx,
int streamId,
ByteBuf data,
int padding,
boolean endOfStream,
ChannelPromise promise)
Writes a
DATA frame to the remote endpoint. |
ChannelFuture |
writeHeaders(ChannelHandlerContext ctx,
int streamId,
Http2Headers headers,
int padding,
boolean endStream,
ChannelPromise promise)
Writes a HEADERS frame to the remote endpoint.
|
ChannelFuture |
writeHeaders(ChannelHandlerContext ctx,
int streamId,
Http2Headers headers,
int streamDependency,
short weight,
boolean exclusive,
int padding,
boolean endOfStream,
ChannelPromise promise)
Writes a HEADERS frame with priority specified to the remote endpoint.
|
ChannelFuture |
writeRstStream(ChannelHandlerContext ctx,
int streamId,
long errorCode,
ChannelPromise promise)
Writes a RST_STREAM frame to the remote endpoint.
|
connection, flowController, frameWriter, lifecycleManager, pollSentSettingsconfiguration, writeFrame, writeGoAway, writePing, writePriority, writePushPromise, writeSettings, writeSettingsAck, writeWindowUpdateclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitwriteFrameconfiguration, writeGoAway, writePing, writePriority, writePushPromise, writeSettings, writeSettingsAck, writeWindowUpdatepublic StreamBufferingEncoder(Http2ConnectionEncoder delegate)
public StreamBufferingEncoder(Http2ConnectionEncoder delegate, int initialMaxConcurrentStreams)
public int numBufferedStreams()
public ChannelFuture writeHeaders(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int padding, boolean endStream, ChannelPromise promise)
Http2FrameWriterwriteHeaders in interface Http2FrameWriterwriteHeaders in class DecoratingHttp2FrameWriterctx - the context to use for writing.streamId - the stream for which to send the frame.headers - the headers to be sent.padding - the amount of padding to be added to the end of the frameendStream - indicates if this is the last frame to be sent for the stream.promise - the promise for the write.public ChannelFuture writeHeaders(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int streamDependency, short weight, boolean exclusive, int padding, boolean endOfStream, ChannelPromise promise)
Http2FrameWriterwriteHeaders in interface Http2FrameWriterwriteHeaders in class DecoratingHttp2FrameWriterctx - the context to use for writing.streamId - the stream for which to send the frame.headers - the headers to be sent.streamDependency - the stream on which this stream should depend, or 0 if it should
depend on the connection.weight - the weight for this stream.exclusive - whether this stream should be the exclusive dependant of its parent.padding - the amount of padding to be added to the end of the frameendOfStream - indicates if this is the last frame to be sent for the stream.promise - the promise for the write.public ChannelFuture writeRstStream(ChannelHandlerContext ctx, int streamId, long errorCode, ChannelPromise promise)
Http2FrameWriterwriteRstStream in interface Http2FrameWriterwriteRstStream in class DecoratingHttp2FrameWriterctx - the context to use for writing.streamId - the stream for which to send the frame.errorCode - the error code indicating the nature of the failure.promise - the promise for the write.public ChannelFuture writeData(ChannelHandlerContext ctx, int streamId, ByteBuf data, int padding, boolean endOfStream, ChannelPromise promise)
Http2DataWriterDATA frame to the remote endpoint. This will result in one or more
frames being written to the context.writeData in interface Http2DataWriterwriteData in class DecoratingHttp2FrameWriterctx - the context to use for writing.streamId - the stream for which to send the frame.data - the payload of the frame. This will be released by this method.padding - the amount of padding to be added to the end of the frameendOfStream - indicates if this is the last frame to be sent for the stream.promise - the promise for the write.public void remoteSettings(Http2Settings settings) throws Http2Exception
Http2ConnectionEncoderremoteSettings in interface Http2ConnectionEncoderremoteSettings in class DecoratingHttp2ConnectionEncoderHttp2Exceptionpublic void close()
Http2FrameWriterclose in interface Http2FrameWriterclose in interface Closeableclose in interface AutoCloseableclose in class DecoratingHttp2FrameWriterCopyright © 2008–2016 The Netty Project. All rights reserved.