public class DefaultHttp2LocalFlowController extends Object implements Http2LocalFlowController
Http2LocalFlowController
.Modifier and Type | Field and Description |
---|---|
static float |
DEFAULT_WINDOW_UPDATE_RATIO
The default ratio of window size to initial window size below which a
WINDOW_UPDATE
is sent to expand the window. |
Constructor and Description |
---|
DefaultHttp2LocalFlowController(Http2Connection connection,
Http2FrameWriter frameWriter) |
DefaultHttp2LocalFlowController(Http2Connection connection,
Http2FrameWriter frameWriter,
float windowUpdateRatio) |
Modifier and Type | Method and Description |
---|---|
void |
consumeBytes(ChannelHandlerContext ctx,
Http2Stream stream,
int numBytes)
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.
|
void |
incrementWindowSize(ChannelHandlerContext ctx,
Http2Stream stream,
int delta)
Increments the size of the stream's flow control window by the given delta.
|
int |
initialWindowSize()
Gets the initial flow control window size that is used as the basis for new stream flow
control windows.
|
void |
initialWindowSize(int newWindowSize)
Sets the initial flow control window and updates all stream windows (but not the connection
window) by the delta.
|
void |
receiveFlowControlledFrame(ChannelHandlerContext ctx,
Http2Stream stream,
ByteBuf data,
int padding,
boolean endOfStream)
Receives an inbound
DATA frame from the remote endpoint and applies flow control
policies to it for both the stream as well as the connection. |
int |
unconsumedBytes(Http2Stream stream)
The number of bytes for the given stream that have been received but not yet consumed by the
application.
|
int |
windowSize(Http2Stream stream)
Gets the number of bytes remaining in the flow control window size for the given stream.
|
float |
windowUpdateRatio()
The window update ratio is used to determine when a window update must be sent.
|
void |
windowUpdateRatio(ChannelHandlerContext ctx,
Http2Stream stream,
float ratio)
The window update ratio is used to determine when a window update must be sent.
|
void |
windowUpdateRatio(float ratio)
The window update ratio is used to determine when a window update must be sent.
|
float |
windowUpdateRatio(Http2Stream stream)
The window update ratio is used to determine when a window update must be sent.
|
public static final float DEFAULT_WINDOW_UPDATE_RATIO
WINDOW_UPDATE
is sent to expand the window.public DefaultHttp2LocalFlowController(Http2Connection connection, Http2FrameWriter frameWriter)
public DefaultHttp2LocalFlowController(Http2Connection connection, Http2FrameWriter frameWriter, float windowUpdateRatio)
public void initialWindowSize(int newWindowSize) throws Http2Exception
Http2FlowController
This method is used to apply the SETTINGS_INITIAL_WINDOW_SIZE
value for an
SETTINGS
frame.
initialWindowSize
in interface Http2FlowController
newWindowSize
- the new initial window size.Http2Exception
- thrown if any protocol-related error occurred.public int initialWindowSize()
Http2FlowController
initialWindowSize
in interface Http2FlowController
public int windowSize(Http2Stream stream)
Http2FlowController
windowSize
in interface Http2FlowController
stream
- The subject stream. Use Http2Connection.connectionStream()
for
requesting the size of the connection window.public void incrementWindowSize(ChannelHandlerContext ctx, Http2Stream stream, int delta) throws Http2Exception
Http2FlowController
In the case of a Http2RemoteFlowController
this is called upon receipt of a
WINDOW_UPDATE
frame from the remote endpoint to mirror the changes to the window
size.
For a Http2LocalFlowController
this can be called to request the expansion of the
window size published by this endpoint. It is up to the implementation, however, as to when a
WINDOW_UPDATE
is actually sent.
incrementWindowSize
in interface Http2FlowController
ctx
- The context for the calling handlerstream
- The subject stream. Use Http2Connection.connectionStream()
for
requesting the size of the connection window.delta
- the change in size of the flow control window.Http2Exception
- thrown if a protocol-related error occurred.public void consumeBytes(ChannelHandlerContext ctx, Http2Stream stream, int numBytes) throws Http2Exception
Http2LocalFlowController
WINDOW_UPDATE
to restore a portion of the flow control
window for the stream.consumeBytes
in interface Http2LocalFlowController
ctx
- the channel handler context to use when sending a WINDOW_UPDATE
if
appropriatestream
- the stream for which window space should be freed. The connection stream object
must not be used.numBytes
- the number of bytes to be returned to the flow control window.Http2Exception
- if the number of bytes returned exceeds the Http2LocalFlowController.unconsumedBytes(io.netty.handler.codec.http2.Http2Stream)
for the stream.public int unconsumedBytes(Http2Stream stream)
Http2LocalFlowController
unconsumedBytes
in interface Http2LocalFlowController
stream
- the stream for which window space should be freed.public void windowUpdateRatio(float ratio)
ratio
- the ratio to use when checking if a WINDOW_UPDATE
is determined necessary for new streams.IllegalArgumentException
- If the ratio is out of bounds (0, 1).public float windowUpdateRatio()
public void windowUpdateRatio(ChannelHandlerContext ctx, Http2Stream stream, float ratio) throws Http2Exception
streamId
.
Note it is the responsibly of the caller to ensure that the the
initial SETTINGS
frame is sent before this is called. It would
be considered a Http2Error.PROTOCOL_ERROR
if a WINDOW_UPDATE
was generated by this method before the initial SETTINGS
frame is sent.
ctx
- the context to use if a WINDOW_UPDATE
is determined necessary.stream
- the stream for which ratio
applies to.ratio
- the ratio to use when checking if a WINDOW_UPDATE
is determined necessary.Http2Exception
- If a protocol-error occurs while generating WINDOW_UPDATE
framespublic float windowUpdateRatio(Http2Stream stream) throws Http2Exception
streamId
.Http2Exception
- If no stream corresponding to stream
could be found.public void receiveFlowControlledFrame(ChannelHandlerContext ctx, Http2Stream stream, ByteBuf data, int padding, boolean endOfStream) throws Http2Exception
Http2LocalFlowController
DATA
frame from the remote endpoint and applies flow control
policies to it for both the stream
as well as the connection. If any flow control
policies have been violated, an exception is raised immediately, otherwise the frame is
considered to have "passed" flow control.receiveFlowControlledFrame
in interface Http2LocalFlowController
ctx
- the context from the handler where the frame was read.stream
- the subject stream for the received frame. The connection stream object must
not be used.data
- payload buffer for the frame.padding
- the number of padding bytes found at the end of the frame.endOfStream
- Indicates whether this is the last frame to be sent from the remote
endpoint for this stream.Http2Exception
- if any flow control errors are encountered.Copyright © 2008–2015 The Netty Project. All rights reserved.