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 boolean
endOfStream
private int
initialStreamWindowSize
This is what is used to determine how many bytes need to be returned relative toprocessedWindow
.private int
lowerBound
private int
processedWindow
A view ofwindow
that is used to determine when to sendWINDOW_UPDATE
frames.private Http2Stream
stream
private float
streamWindowUpdateRatio
This is used to determine whenprocessedWindow
is sufficiently far away frominitialStreamWindowSize
such that aWINDOW_UPDATE
should be sent.private int
window
The actual flow control window that is decremented as soon asDATA
arrives.
-
Constructor Summary
Constructors Constructor Description DefaultState(Http2Stream stream, int initialWindowSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
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
initialWindowSize()
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
unconsumedBytes()
void
window(int initialWindowSize)
int
windowSize()
float
windowUpdateRatio()
void
windowUpdateRatio(float ratio)
private void
writeWindowUpdate()
Called to perform a window update for this stream (or connection).boolean
writeWindowUpdateIfNeeded()
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 asDATA
arrives.
-
processedWindow
private int processedWindow
A 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 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 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 Detail
-
DefaultState
DefaultState(Http2Stream stream, int initialWindowSize)
-
-
Method Detail
-
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
public void incrementFlowControlWindows(int delta) throws Http2Exception
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
public void receiveFlowControlledFrame(int dataLength) throws Http2Exception
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
private void returnProcessedBytes(int delta) throws Http2Exception
- Throws:
Http2Exception
-
consumeBytes
public boolean consumeBytes(int numBytes) throws Http2Exception
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
public boolean writeWindowUpdateIfNeeded() throws Http2Exception
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
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.- Throws:
Http2Exception
-
-