Package io.netty.handler.codec.http2
Class DefaultHttp2LocalFlowController.DefaultState
java.lang.Object
io.netty.handler.codec.http2.DefaultHttp2LocalFlowController.DefaultState
- All Implemented Interfaces:
DefaultHttp2LocalFlowController.FlowState
- Direct Known Subclasses:
DefaultHttp2LocalFlowController.AutoRefillState
- Enclosing class:
DefaultHttp2LocalFlowController
private class DefaultHttp2LocalFlowController.DefaultState
extends Object
implements DefaultHttp2LocalFlowController.FlowState
Flow control window state for an individual stream.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
private int
This is what is used to determine how many bytes need to be returned relative toprocessedWindow
.private int
private int
A view ofwindow
that is used to determine when to sendWINDOW_UPDATE
frames.private final Http2Stream
private float
This is used to determine whenprocessedWindow
is sufficiently far away frominitialStreamWindowSize
such that aWINDOW_UPDATE
should be sent.private int
The actual flow control window that is decremented as soon asDATA
arrives. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
consumeBytes
(int numBytes) Indicates that the application has consumednumBytes
from the connection or stream and is ready to receive more data.void
endOfStream
(boolean endOfStream) void
incrementFlowControlWindows
(int delta) Increment the windows which are used to determine many bytes have been processed.void
incrementInitialStreamWindow
(int delta) Increment the initial window size for this stream.int
void
receiveFlowControlledFrame
(int dataLength) A flow control event has occurred and we should decrement the amount of available bytes for this stream.private void
returnProcessedBytes
(int delta) int
void
window
(int initialWindowSize) int
float
void
windowUpdateRatio
(float ratio) private void
Called to perform a window update for this stream (or connection).boolean
Updates the flow control window for this stream if it is appropriate.
-
Field Details
-
stream
-
window
private int windowThe actual flow control window that is decremented as soon asDATA
arrives. -
processedWindow
private int processedWindowA view ofwindow
that is used to determine when to sendWINDOW_UPDATE
frames. Decrementing this window for receivedDATA
frames is delayed until the application has indicated that the data has been fully processed. This prevents sending aWINDOW_UPDATE
until the number of processed bytes drops below the threshold. -
initialStreamWindowSize
private int initialStreamWindowSizeThis is what is used to determine how many bytes need to be returned relative toprocessedWindow
. Each stream has their own initial window size. -
streamWindowUpdateRatio
private float streamWindowUpdateRatioThis is used to determine whenprocessedWindow
is sufficiently far away frominitialStreamWindowSize
such that aWINDOW_UPDATE
should be sent. Each stream has their own window update ratio. -
lowerBound
private int lowerBound -
endOfStream
private boolean endOfStream
-
-
Constructor Details
-
DefaultState
DefaultState(Http2Stream stream, int initialWindowSize)
-
-
Method Details
-
window
public void window(int initialWindowSize) - Specified by:
window
in interfaceDefaultHttp2LocalFlowController.FlowState
-
windowSize
public int windowSize()- Specified by:
windowSize
in interfaceDefaultHttp2LocalFlowController.FlowState
-
initialWindowSize
public int initialWindowSize()- Specified by:
initialWindowSize
in interfaceDefaultHttp2LocalFlowController.FlowState
-
endOfStream
public void endOfStream(boolean endOfStream) - Specified by:
endOfStream
in interfaceDefaultHttp2LocalFlowController.FlowState
-
windowUpdateRatio
public float windowUpdateRatio()- Specified by:
windowUpdateRatio
in interfaceDefaultHttp2LocalFlowController.FlowState
-
windowUpdateRatio
public void windowUpdateRatio(float ratio) - Specified by:
windowUpdateRatio
in interfaceDefaultHttp2LocalFlowController.FlowState
-
incrementInitialStreamWindow
public void incrementInitialStreamWindow(int delta) Description copied from interface:DefaultHttp2LocalFlowController.FlowState
Increment the initial window size for this stream.- Specified by:
incrementInitialStreamWindow
in interfaceDefaultHttp2LocalFlowController.FlowState
- Parameters:
delta
- The amount to increase the initial window size by.
-
incrementFlowControlWindows
Description copied from interface:DefaultHttp2LocalFlowController.FlowState
Increment the windows which are used to determine many bytes have been processed.- Specified by:
incrementFlowControlWindows
in interfaceDefaultHttp2LocalFlowController.FlowState
- Parameters:
delta
- The amount to increment the window by.- Throws:
Http2Exception
- if integer overflow occurs on the window.
-
receiveFlowControlledFrame
Description copied from interface:DefaultHttp2LocalFlowController.FlowState
A flow control event has occurred and we should decrement the amount of available bytes for this stream.- Specified by:
receiveFlowControlledFrame
in interfaceDefaultHttp2LocalFlowController.FlowState
- Parameters:
dataLength
- The amount of data to for which this stream is no longer eligible to use for flow control.- Throws:
Http2Exception
- If too much data is used relative to how much is available.
-
returnProcessedBytes
- Throws:
Http2Exception
-
consumeBytes
Description copied from interface:DefaultHttp2LocalFlowController.FlowState
Indicates that the application has consumednumBytes
from the connection or stream and is ready to receive more data.- Specified by:
consumeBytes
in interfaceDefaultHttp2LocalFlowController.FlowState
- Parameters:
numBytes
- the number of bytes to be returned to the flow control window.- Returns:
- true if
WINDOW_UPDATE
was written, false otherwise. - Throws:
Http2Exception
-
unconsumedBytes
public int unconsumedBytes()- Specified by:
unconsumedBytes
in interfaceDefaultHttp2LocalFlowController.FlowState
-
writeWindowUpdateIfNeeded
Description copied from interface:DefaultHttp2LocalFlowController.FlowState
Updates the flow control window for this stream if it is appropriate.- Specified by:
writeWindowUpdateIfNeeded
in interfaceDefaultHttp2LocalFlowController.FlowState
- Returns:
- true if
WINDOW_UPDATE
was written, false otherwise. - Throws:
Http2Exception
-
writeWindowUpdate
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.- Throws:
Http2Exception
-