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 java.lang.Object implements DefaultHttp2LocalFlowController.FlowState
Flow control window state for an individual stream.
-
-
Field Summary
Fields Modifier and Type Field Description private booleanendOfStreamprivate intinitialStreamWindowSizeThis is what is used to determine how many bytes need to be returned relative toprocessedWindow.private intlowerBoundprivate intprocessedWindowA view ofwindowthat is used to determine when to sendWINDOW_UPDATEframes.private Http2Streamstreamprivate floatstreamWindowUpdateRatioThis is used to determine whenprocessedWindowis sufficiently far away frominitialStreamWindowSizesuch that aWINDOW_UPDATEshould be sent.private intwindowThe actual flow control window that is decremented as soon asDATAarrives.
-
Constructor Summary
Constructors Constructor Description DefaultState(Http2Stream stream, int initialWindowSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanconsumeBytes(int numBytes)Indicates that the application has consumednumBytesfrom the connection or stream and is ready to receive more data.voidendOfStream(boolean endOfStream)voidincrementFlowControlWindows(int delta)Increment the windows which are used to determine many bytes have been processed.voidincrementInitialStreamWindow(int delta)Increment the initial window size for this stream.intinitialWindowSize()voidreceiveFlowControlledFrame(int dataLength)A flow control event has occurred and we should decrement the amount of available bytes for this stream.private voidreturnProcessedBytes(int delta)intunconsumedBytes()voidwindow(int initialWindowSize)intwindowSize()floatwindowUpdateRatio()voidwindowUpdateRatio(float ratio)private voidwriteWindowUpdate()Called to perform a window update for this stream (or connection).booleanwriteWindowUpdateIfNeeded()Updates the flow control window for this stream if it is appropriate.
-
-
-
Field Detail
-
stream
private final Http2Stream stream
-
window
private int window
The actual flow control window that is decremented as soon asDATAarrives.
-
processedWindow
private int processedWindow
A view ofwindowthat is used to determine when to sendWINDOW_UPDATEframes. Decrementing this window for receivedDATAframes is delayed until the application has indicated that the data has been fully processed. This prevents sending aWINDOW_UPDATEuntil the number of processed bytes drops below the threshold.
-
initialStreamWindowSize
private int initialStreamWindowSize
This 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 streamWindowUpdateRatio
This is used to determine whenprocessedWindowis sufficiently far away frominitialStreamWindowSizesuch that aWINDOW_UPDATEshould be sent. Each stream has their own window update ratio.
-
lowerBound
private int lowerBound
-
endOfStream
private boolean endOfStream
-
-
Constructor Detail
-
DefaultState
DefaultState(Http2Stream stream, int initialWindowSize)
-
-
Method Detail
-
window
public void window(int initialWindowSize)
- Specified by:
windowin interfaceDefaultHttp2LocalFlowController.FlowState
-
windowSize
public int windowSize()
- Specified by:
windowSizein interfaceDefaultHttp2LocalFlowController.FlowState
-
initialWindowSize
public int initialWindowSize()
- Specified by:
initialWindowSizein interfaceDefaultHttp2LocalFlowController.FlowState
-
endOfStream
public void endOfStream(boolean endOfStream)
- Specified by:
endOfStreamin interfaceDefaultHttp2LocalFlowController.FlowState
-
windowUpdateRatio
public float windowUpdateRatio()
- Specified by:
windowUpdateRatioin interfaceDefaultHttp2LocalFlowController.FlowState
-
windowUpdateRatio
public void windowUpdateRatio(float ratio)
- Specified by:
windowUpdateRatioin interfaceDefaultHttp2LocalFlowController.FlowState
-
incrementInitialStreamWindow
public void incrementInitialStreamWindow(int delta)
Description copied from interface:DefaultHttp2LocalFlowController.FlowStateIncrement the initial window size for this stream.- Specified by:
incrementInitialStreamWindowin interfaceDefaultHttp2LocalFlowController.FlowState- Parameters:
delta- The amount to increase the initial window size by.
-
incrementFlowControlWindows
public void incrementFlowControlWindows(int delta) throws Http2ExceptionDescription copied from interface:DefaultHttp2LocalFlowController.FlowStateIncrement the windows which are used to determine many bytes have been processed.- Specified by:
incrementFlowControlWindowsin interfaceDefaultHttp2LocalFlowController.FlowState- Parameters:
delta- The amount to increment the window by.- Throws:
Http2Exception- if integer overflow occurs on the window.
-
receiveFlowControlledFrame
public void receiveFlowControlledFrame(int dataLength) throws Http2ExceptionDescription copied from interface:DefaultHttp2LocalFlowController.FlowStateA flow control event has occurred and we should decrement the amount of available bytes for this stream.- Specified by:
receiveFlowControlledFramein 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
private void returnProcessedBytes(int delta) throws Http2Exception- Throws:
Http2Exception
-
consumeBytes
public boolean consumeBytes(int numBytes) throws Http2ExceptionDescription copied from interface:DefaultHttp2LocalFlowController.FlowStateIndicates that the application has consumednumBytesfrom the connection or stream and is ready to receive more data.- Specified by:
consumeBytesin interfaceDefaultHttp2LocalFlowController.FlowState- Parameters:
numBytes- the number of bytes to be returned to the flow control window.- Returns:
- true if
WINDOW_UPDATEwas written, false otherwise. - Throws:
Http2Exception
-
unconsumedBytes
public int unconsumedBytes()
- Specified by:
unconsumedBytesin interfaceDefaultHttp2LocalFlowController.FlowState
-
writeWindowUpdateIfNeeded
public boolean writeWindowUpdateIfNeeded() throws Http2ExceptionDescription copied from interface:DefaultHttp2LocalFlowController.FlowStateUpdates the flow control window for this stream if it is appropriate.- Specified by:
writeWindowUpdateIfNeededin interfaceDefaultHttp2LocalFlowController.FlowState- Returns:
- true if
WINDOW_UPDATEwas written, false otherwise. - Throws:
Http2Exception
-
writeWindowUpdate
private void writeWindowUpdate() throws Http2ExceptionCalled 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
-
-