Http2LocalFlowController.
This class is NOT thread safe. The assumption is all methods must be invoked from a single thread.
Typically this thread is the event loop thread for the ChannelHandlerContext managed by this class.
| Modifier and Type | Class and Description |
|---|---|
| private class | DefaultHttp2LocalFlowController.
Flow control state that does autorefill of the flow control window when the data is received. |
| private class | DefaultHttp2LocalFlowController.
Flow control window state for an individual stream. |
| private static interface | DefaultHttp2LocalFlowController.
An abstraction which provides specific extensions used by local flow control. |
| private class | DefaultHttp2LocalFlowController.
Provides a means to iterate over all active streams and increment the flow control windows. |
| Modifier and Type | Field and Description |
|---|---|
| private final Http2Connection | |
| private ChannelHandlerContext | |
| public static final float | DEFAULT_WINDOW_UPDATE_RATIO
The default ratio of window size to initial window size below which a |
| private Http2FrameWriter | |
| private int | |
| private static final DefaultHttp2LocalFlowController. | REDUCED_FLOW_STATE
The local flow control state for a single stream that is not in a state where flow controlled frames cannot be exchanged. |
| private final Http2Connection. | |
| private float |
| Access | Constructor and Description |
|---|---|
| public | |
| public | DefaultHttp2LocalFlowController(Http2Connection
the connection state. connection, float the window percentage below which to send a windowUpdateRatio, boolean WINDOW_UPDATE.if autoRefillConnectionWindow)true, effectively disables the connection window
in the flow control algorithm as they will always refill automatically without requiring the
application to consume the bytes. When enabled, the maximum bytes you must be prepared to
queue is proportional to maximum number of concurrent streams * the initial window
size per stream
(SETTINGS_MAX_CONCURRENT_STREAMS
SETTINGS_INITIAL_WINDOW_SIZE).Constructs a controller with the given settings. |
| Modifier and Type | Method and Description |
|---|---|
| public void | channelHandlerContext(ChannelHandlerContext
The ctx)ChannelHandlerContext for which to apply flow control on.Implements io. ChannelHandlerContext for which to apply flow control on.
|
| private static void | |
| private DefaultHttp2LocalFlowController. | |
| private boolean | |
| public boolean | consumeBytes(Http2Stream
the stream for which window space should be freed. The connection stream object must not be used.
If stream, int stream is null or closed (i.e. Http2Stream#state() method returns Http2Stream.), calling this method has no effect.the number of bytes to be returned to the flow control window. numBytes)Implements io. |
| public DefaultHttp2LocalFlowController | frameWriter(Http2FrameWriter
the HTTP/2 frame writer. frameWriter)Implements io. WINDOW_UPDATE frames.
|
| public void | incrementWindowSize(Http2Stream
The subject stream. Use stream, int Http2Connection#connectionStream() for
requesting the size of the connection window.the change in size of the flow control window. delta)Implements io. |
| public void | initialWindowSize(int
the new initial window size. newWindowSize)Implements io. |
| public int | initialWindowSize()
Implements io. |
| public int | initialWindowSize(Http2Stream stream)
Implements io. |
| private static boolean | |
| public void | receiveFlowControlledFrame(Http2Stream
the subject stream for the received frame. The connection stream object must not be used. If stream, ByteBuf stream is null or closed, flow control should only be applied to the connection window and the bytes are
immediately consumed.payload buffer for the frame. data, int additional bytes that should be added to obscure the true content size. Must be between 0 and
256 (inclusive). padding, boolean Indicates whether this is the last frame to be sent from the remote endpoint for this stream. endOfStream)Implements io. DATA frame from the remote endpoint and applies flow control policies to it for both
the stream as well as the connection.
|
| private DefaultHttp2LocalFlowController. | |
| public int | unconsumedBytes(Http2Stream
the stream for which window space should be freed. stream)Implements io. |
| public int | windowSize(Http2Stream stream)
Implements io. |
| public void | windowUpdateRatio(float
the ratio to use when checking if a ratio)WINDOW_UPDATE is determined necessary for new streams.The window update ratio is used to determine when a window update must be sent. |
| public float | |
| public void | windowUpdateRatio(Http2Stream
the stream for which stream, float ratio applies to.the ratio to use when checking if a ratio)WINDOW_UPDATE is determined necessary.The window update ratio is used to determine when a window update must be sent. |
| public float | windowUpdateRatio(Http2Stream stream)
The window update ratio is used to determine when a window update must be sent. |
| connection | back to summary |
|---|---|
| private final Http2Connection connection | |
| ctx | back to summary |
|---|---|
| private ChannelHandlerContext ctx | |
| DEFAULT_WINDOW_UPDATE_RATIO | back to summary |
|---|---|
| public static final float DEFAULT_WINDOW_UPDATE_RATIO The default ratio of window size to initial window size below which a | |
| frameWriter | back to summary |
|---|---|
| private Http2FrameWriter frameWriter | |
| initialWindowSize | back to summary |
|---|---|
| private int initialWindowSize | |
| REDUCED_FLOW_STATE | back to summary |
|---|---|
| private static final DefaultHttp2LocalFlowController. The local flow control state for a single stream that is not in a state where flow controlled frames cannot be exchanged. | |
| stateKey | back to summary |
|---|---|
| private final Http2Connection. | |
| windowUpdateRatio | back to summary |
|---|---|
| private float windowUpdateRatio | |
| DefaultHttp2LocalFlowController | back to summary |
|---|---|
| public DefaultHttp2LocalFlowController(Http2Connection connection) | |
| DefaultHttp2LocalFlowController | back to summary |
|---|---|
| public DefaultHttp2LocalFlowController(Http2Connection connection, float windowUpdateRatio, boolean autoRefillConnectionWindow) Constructs a controller with the given settings.
| |
| channelHandlerContext | back to summary |
|---|---|
| public void channelHandlerContext(ChannelHandlerContext ctx) Implements io. Doc from io. Set the
This must be called to properly initialize the
| |
| checkValidRatio | back to summary |
|---|---|
| private static void checkValidRatio(float ratio) | |
| connectionState | back to summary |
|---|---|
| private DefaultHttp2LocalFlowController. | |
| consumeAllBytes | back to summary |
|---|---|
| private boolean consumeAllBytes(DefaultHttp2LocalFlowController. | |
| consumeBytes | back to summary |
|---|---|
| public boolean consumeBytes(Http2Stream stream, int numBytes) throws Http2Exception Implements io. Doc from io. Indicates that the application has consumed a number of bytes for the given stream and is therefore ready to
receive more data from the remote endpoint. The application must consume any bytes that it receives or the flow
control window will collapse. Consuming bytes enables the flow controller to send
If
| |
| frameWriter | back to summary |
|---|---|
| public DefaultHttp2LocalFlowController frameWriter(Http2FrameWriter frameWriter) Implements io. Doc from io. Sets the writer to be use for sending
| |
| incrementWindowSize | back to summary |
|---|---|
| public void incrementWindowSize(Http2Stream stream, int delta) throws Http2Exception Implements io. Doc from io. Increments the size of the stream's flow control window by the given delta.
In the case of a
For a
| |
| initialWindowSize | back to summary |
|---|---|
| public void initialWindowSize(int newWindowSize) throws Http2Exception Implements io. Doc from io. Sets the connection-wide initial flow control window and updates all stream windows (but not the connection stream window) by the delta.
Represents the value for
SETTINGS_INITIAL_WINDOW_SIZE. This method should
only be called by Netty (not users) as a result of a receiving a
| |
| initialWindowSize | back to summary |
|---|---|
| public int initialWindowSize() Implements io. Doc from io. Gets the connection-wide initial flow control window size that is used as the basis for new stream flow control windows.
Represents the value for
SETTINGS_INITIAL_WINDOW_SIZE. The initial value
returned by this method must be
| |
| initialWindowSize | back to summary |
|---|---|
| public int initialWindowSize(Http2Stream stream) Implements io. Doc from io. Get the initial flow control window size for the given stream. This quantity is measured in number of bytes. Note
the unavailable window portion can be calculated by
| |
| isClosed | back to summary |
|---|---|
| private static boolean isClosed(Http2Stream stream) | |
| receiveFlowControlledFrame | back to summary |
|---|---|
| public void receiveFlowControlledFrame(Http2Stream stream, ByteBuf data, int padding, boolean endOfStream) throws Http2Exception Implements io. Doc from io. Receives an inbound
If
| |
| state | back to summary |
|---|---|
| private DefaultHttp2LocalFlowController. | |
| unconsumedBytes | back to summary |
|---|---|
| public int unconsumedBytes(Http2Stream stream) Implements io. Doc from io. The number of bytes for the given stream that have been received but not yet consumed by the application.
| |
| windowSize | back to summary |
|---|---|
| public int windowSize(Http2Stream stream) Implements io. Doc from io. Get the portion of the flow control window for the given stream that is currently available for sending/receiving frames which are subject to flow control. This quantity is measured in number of bytes.
| |
| windowUpdateRatio | back to summary |
|---|---|
| public void windowUpdateRatio(float ratio) The window update ratio is used to determine when a window update must be sent. If the ratio of bytes processed since the last update has meet or exceeded this ratio then a window update will be sent. This is the global window update ratio that will be used for new streams.
| |
| windowUpdateRatio | back to summary |
|---|---|
| public float windowUpdateRatio() The window update ratio is used to determine when a window update must be sent. If the ratio of bytes processed since the last update has meet or exceeded this ratio then a window update will be sent. This is the global window update ratio that will be used for new streams. | |
| windowUpdateRatio | back to summary |
|---|---|
| public void windowUpdateRatio(Http2Stream stream, float ratio) throws Http2Exception The window update ratio is used to determine when a window update must be sent. If the ratio
of bytes processed since the last update has meet or exceeded this ratio then a window update will
be sent. This window update ratio will only be applied to
Note it is the responsibly of the caller to ensure that the
initial
| |
| windowUpdateRatio | back to summary |
|---|---|
| public float windowUpdateRatio(Http2Stream stream) throws Http2Exception The window update ratio is used to determine when a window update must be sent. If the ratio
of bytes processed since the last update has meet or exceeded this ratio then a window update will
be sent. This window update ratio will only be applied to
| |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | consumeBytes(int
the number of bytes to be returned to the flow control window. numBytes)Overrides io. Implements io. numBytes from the connection or stream and is
ready to receive more data.
|
| public void | receiveFlowControlledFrame(int
The amount of data to for which this stream is no longer eligible to use for flow control. dataLength)Overrides io. Implements io. |
| AutoRefillState | back to summary |
|---|---|
| pack-priv AutoRefillState(Http2Stream stream, int initialWindowSize) | |
| consumeBytes | back to summary |
|---|---|
| public boolean consumeBytes(int numBytes) throws Http2Exception Overrides io. Implements io. Doc from io. Indicates that the application has consumed
| |
| receiveFlowControlledFrame | back to summary |
|---|---|
| public void receiveFlowControlledFrame(int dataLength) throws Http2Exception Overrides io. Implements io. Doc from io. A flow control event has occurred and we should decrement the amount of available bytes for this stream.
| |
| Modifier and Type | Field and Description |
|---|---|
| private boolean | |
| private int | initialStreamWindowSize
This is what is used to determine how many bytes need to be returned relative to |
| private int | |
| private int | processedWindow
A view of |
| private final Http2Stream | |
| private float | streamWindowUpdateRatio
This is used to determine when |
| private int | window
The actual flow control window that is decremented as soon as |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | consumeBytes(int
the number of bytes to be returned to the flow control window. numBytes)Implements io. numBytes from the connection or stream and is
ready to receive more data.
|
| public void | endOfStream(boolean endOfStream)
Implements io. |
| public void | incrementFlowControlWindows(int
The amount to increment the window by. delta)Implements io. |
| public void | incrementInitialStreamWindow(int
The amount to increase the initial window size by. delta)Implements io. |
| public int | |
| public void | receiveFlowControlledFrame(int
The amount of data to for which this stream is no longer eligible to use for flow control. dataLength)Implements io. |
| private void | |
| public int | |
| public void | window(int initialWindowSize)
Implements io. |
| public int | |
| public float | |
| public void | |
| private void | |
| public boolean | writeWindowUpdateIfNeeded()
Implements io. |
| endOfStream | back to summary |
|---|---|
| private boolean endOfStream | |
| initialStreamWindowSize | back to summary |
|---|---|
| private int initialStreamWindowSize This is what is used to determine how many bytes need to be returned relative to | |
| lowerBound | back to summary |
|---|---|
| private int lowerBound | |
| processedWindow | back to summary |
|---|---|
| private int processedWindow A view of | |
| stream | back to summary |
|---|---|
| private final Http2Stream stream | |
| streamWindowUpdateRatio | back to summary |
|---|---|
| private float streamWindowUpdateRatio This is used to determine when | |
| window | back to summary |
|---|---|
| private int window The actual flow control window that is decremented as soon as | |
| DefaultState | back to summary |
|---|---|
| pack-priv DefaultState(Http2Stream stream, int initialWindowSize) | |
| consumeBytes | back to summary |
|---|---|
| public boolean consumeBytes(int numBytes) throws Http2Exception Implements io. Doc from io. Indicates that the application has consumed
| |
| endOfStream | back to summary |
|---|---|
| public void endOfStream(boolean endOfStream) Implements io.
| |
| incrementFlowControlWindows | back to summary |
|---|---|
| public void incrementFlowControlWindows(int delta) throws Http2Exception Implements io. Doc from io. Increment the windows which are used to determine many bytes have been processed.
| |
| incrementInitialStreamWindow | back to summary |
|---|---|
| public void incrementInitialStreamWindow(int delta) Implements io. Doc from io. Increment the initial window size for this stream.
| |
| initialWindowSize | back to summary |
|---|---|
| public int initialWindowSize() Implements io.
| |
| receiveFlowControlledFrame | back to summary |
|---|---|
| public void receiveFlowControlledFrame(int dataLength) throws Http2Exception Implements io. Doc from io. A flow control event has occurred and we should decrement the amount of available bytes for this stream.
| |
| returnProcessedBytes | back to summary |
|---|---|
| private void returnProcessedBytes(int delta) throws Http2Exception | |
| unconsumedBytes | back to summary |
|---|---|
| public int unconsumedBytes() Implements io.
| |
| window | back to summary |
|---|---|
| public void window(int initialWindowSize) Implements io.
| |
| windowSize | back to summary |
|---|---|
| public int windowSize() Implements io.
| |
| windowUpdateRatio | back to summary |
|---|---|
| public float windowUpdateRatio() Implements io.
| |
| windowUpdateRatio | back to summary |
|---|---|
| public void windowUpdateRatio(float ratio) Implements io.
| |
| writeWindowUpdate | back to summary |
|---|---|
| private void writeWindowUpdate() throws Http2Exception Called to perform a window update for this stream (or connection). Updates the window size back to the size of the initial window and sends a window update frame to the remote endpoint. | |
| writeWindowUpdateIfNeeded | back to summary |
|---|---|
| public boolean writeWindowUpdateIfNeeded() throws Http2Exception Implements io. Doc from io. Updates the flow control window for this stream if it is appropriate.
| |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | Returns: true ifWINDOW_UPDATE was written, false otherwise.the number of bytes to be returned to the flow control window. numBytes)Indicates that the application has consumed |
| public void | |
| public void | incrementFlowControlWindows(int
The amount to increment the window by. delta)Increment the windows which are used to determine many bytes have been processed. |
| public void | incrementInitialStreamWindow(int
The amount to increase the initial window size by. delta)Increment the initial window size for this stream. |
| public int | |
| public void | receiveFlowControlledFrame(int
The amount of data to for which this stream is no longer eligible to use for flow control. dataLength)A flow control event has occurred and we should decrement the amount of available bytes for this stream. |
| public int | |
| public void | |
| public int | |
| public float | |
| public void | |
| public boolean | Returns: true ifWINDOW_UPDATE was written, false otherwise.Updates the flow control window for this stream if it is appropriate. |
| consumeBytes | back to summary |
|---|---|
| public boolean consumeBytes(int numBytes) throws Http2Exception Indicates that the application has consumed
| |
| endOfStream | back to summary |
|---|---|
| public void endOfStream(boolean endOfStream) | |
| incrementFlowControlWindows | back to summary |
|---|---|
| public void incrementFlowControlWindows(int delta) throws Http2Exception Increment the windows which are used to determine many bytes have been processed.
| |
| incrementInitialStreamWindow | back to summary |
|---|---|
| public void incrementInitialStreamWindow(int delta) Increment the initial window size for this stream.
| |
| initialWindowSize | back to summary |
|---|---|
| public int initialWindowSize() | |
| receiveFlowControlledFrame | back to summary |
|---|---|
| public void receiveFlowControlledFrame(int dataLength) throws Http2Exception A flow control event has occurred and we should decrement the amount of available bytes for this stream.
| |
| unconsumedBytes | back to summary |
|---|---|
| public int unconsumedBytes() | |
| window | back to summary |
|---|---|
| public void window(int initialWindowSize) | |
| windowSize | back to summary |
|---|---|
| public int windowSize() | |
| windowUpdateRatio | back to summary |
|---|---|
| public float windowUpdateRatio() | |
| windowUpdateRatio | back to summary |
|---|---|
| public void windowUpdateRatio(float ratio) | |
| writeWindowUpdateIfNeeded | back to summary |
|---|---|
| public boolean writeWindowUpdateIfNeeded() throws Http2Exception Updates the flow control window for this stream if it is appropriate.
| |
| Modifier and Type | Field and Description |
|---|---|
| private Http2Exception. | |
| private final int |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public boolean |
| compositeException | back to summary |
|---|---|
| private Http2Exception. | |
| delta | back to summary |
|---|---|
| private final int delta | |
| WindowUpdateVisitor | back to summary |
|---|---|
| pack-priv WindowUpdateVisitor(int delta) | |
| throwIfError | back to summary |
|---|---|
| public void throwIfError() throws CompositeStreamException | |
| visit | back to summary |
|---|---|
| public boolean visit(Http2Stream stream) throws Http2Exception Implements io.
| |