Class DelegatingDecompressorFrameListener.ConsumedBytesConverter
- java.lang.Object
-
- io.netty.handler.codec.http2.DelegatingDecompressorFrameListener.ConsumedBytesConverter
-
- All Implemented Interfaces:
Http2FlowController,Http2LocalFlowController
- Enclosing class:
- DelegatingDecompressorFrameListener
private final class DelegatingDecompressorFrameListener.ConsumedBytesConverter extends java.lang.Object implements Http2LocalFlowController
A decorator around the local flow controller that converts consumed bytes from uncompressed to compressed.
-
-
Field Summary
Fields Modifier and Type Field Description private Http2LocalFlowControllerflowController
-
Constructor Summary
Constructors Constructor Description ConsumedBytesConverter(Http2LocalFlowController flowController)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidchannelHandlerContext(ChannelHandlerContext ctx)Set theChannelHandlerContextfor which to apply flow control on.booleanconsumeBytes(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.Http2LocalFlowControllerframeWriter(Http2FrameWriter frameWriter)Sets the writer to be use for sendingWINDOW_UPDATEframes.voidincrementWindowSize(Http2Stream stream, int delta)Increments the size of the stream's flow control window by the given delta.intinitialWindowSize()Gets the connection-wide initial flow control window size that is used as the basis for new stream flow control windows.voidinitialWindowSize(int newWindowSize)Sets the connection-wide initial flow control window and updates all stream windows (but not the connection stream window) by the delta.intinitialWindowSize(Http2Stream stream)Get the initial flow control window size for the given stream.voidreceiveFlowControlledFrame(Http2Stream stream, ByteBuf data, int padding, boolean endOfStream)Receives an inboundDATAframe from the remote endpoint and applies flow control policies to it for both thestreamas well as the connection.intunconsumedBytes(Http2Stream stream)The number of bytes for the given stream that have been received but not yet consumed by the application.intwindowSize(Http2Stream stream)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.
-
-
-
Field Detail
-
flowController
private final Http2LocalFlowController flowController
-
-
Constructor Detail
-
ConsumedBytesConverter
ConsumedBytesConverter(Http2LocalFlowController flowController)
-
-
Method Detail
-
frameWriter
public Http2LocalFlowController frameWriter(Http2FrameWriter frameWriter)
Description copied from interface:Http2LocalFlowControllerSets the writer to be use for sendingWINDOW_UPDATEframes. This must be called before any flow controlled data is received.- Specified by:
frameWriterin interfaceHttp2LocalFlowController- Parameters:
frameWriter- the HTTP/2 frame writer.
-
channelHandlerContext
public void channelHandlerContext(ChannelHandlerContext ctx) throws Http2Exception
Description copied from interface:Http2FlowControllerSet theChannelHandlerContextfor which to apply flow control on.This must be called to properly initialize the
Http2FlowController. Not calling this is considered a programming error.- Specified by:
channelHandlerContextin interfaceHttp2FlowController- Parameters:
ctx- TheChannelHandlerContextfor which to apply flow control on.- Throws:
Http2Exception- if any protocol-related error occurred.
-
initialWindowSize
public void initialWindowSize(int newWindowSize) throws Http2ExceptionDescription copied from interface:Http2FlowControllerSets 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
SETTINGSframe.- Specified by:
initialWindowSizein interfaceHttp2FlowController- Parameters:
newWindowSize- the new initial window size.- Throws:
Http2Exception- thrown if any protocol-related error occurred.
-
initialWindowSize
public int initialWindowSize()
Description copied from interface:Http2FlowControllerGets 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
Http2CodecUtil.DEFAULT_WINDOW_SIZE.- Specified by:
initialWindowSizein interfaceHttp2FlowController
-
windowSize
public int windowSize(Http2Stream stream)
Description copied from interface:Http2FlowControllerGet 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.- Specified by:
windowSizein interfaceHttp2FlowController
-
incrementWindowSize
public void incrementWindowSize(Http2Stream stream, int delta) throws Http2Exception
Description copied from interface:Http2FlowControllerIncrements the size of the stream's flow control window by the given delta.In the case of a
Http2RemoteFlowControllerthis is called upon receipt of aWINDOW_UPDATEframe from the remote endpoint to mirror the changes to the window size.For a
Http2LocalFlowControllerthis 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 aWINDOW_UPDATEis actually sent.- Specified by:
incrementWindowSizein interfaceHttp2FlowController- Parameters:
stream- The subject stream. UseHttp2Connection.connectionStream()for requesting the size of the connection window.delta- the change in size of the flow control window.- Throws:
Http2Exception- thrown if a protocol-related error occurred.
-
receiveFlowControlledFrame
public void receiveFlowControlledFrame(Http2Stream stream, ByteBuf data, int padding, boolean endOfStream) throws Http2Exception
Description copied from interface:Http2LocalFlowControllerReceives an inboundDATAframe from the remote endpoint and applies flow control policies to it for both thestreamas 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. Ifstreamisnullor closed, flow control should only be applied to the connection window and the bytes are immediately consumed.- Specified by:
receiveFlowControlledFramein interfaceHttp2LocalFlowController- Parameters:
stream- the subject stream for the received frame. The connection stream object must not be used. Ifstreamisnullor closed, flow control should only be applied to the connection window and the bytes are immediately consumed.data- payload buffer for the frame.padding- additional bytes that should be added to obscure the true content size. Must be between 0 and 256 (inclusive).endOfStream- Indicates whether this is the last frame to be sent from the remote endpoint for this stream.- Throws:
Http2Exception- if any flow control errors are encountered.
-
consumeBytes
public boolean consumeBytes(Http2Stream stream, int numBytes) throws Http2Exception
Description copied from interface:Http2LocalFlowControllerIndicates 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 sendWINDOW_UPDATEto restore a portion of the flow control window for the stream. Ifstreamisnullor closed (i.e.Http2Stream.state()method returnsHttp2Stream.State.CLOSED), calling this method has no effect.- Specified by:
consumeBytesin interfaceHttp2LocalFlowController- Parameters:
stream- the stream for which window space should be freed. The connection stream object must not be used. Ifstreamisnullor closed (i.e.Http2Stream.state()method returnsHttp2Stream.State.CLOSED), calling this method has no effect.numBytes- the number of bytes to be returned to the flow control window.- Returns:
- true if a
WINDOW_UPDATEwas sent, false otherwise. - Throws:
Http2Exception- if the number of bytes returned exceeds theHttp2LocalFlowController.unconsumedBytes(Http2Stream)for the stream.
-
unconsumedBytes
public int unconsumedBytes(Http2Stream stream)
Description copied from interface:Http2LocalFlowControllerThe number of bytes for the given stream that have been received but not yet consumed by the application.- Specified by:
unconsumedBytesin interfaceHttp2LocalFlowController- Parameters:
stream- the stream for which window space should be freed.- Returns:
- the number of unconsumed bytes for the stream.
-
initialWindowSize
public int initialWindowSize(Http2Stream stream)
Description copied from interface:Http2LocalFlowControllerGet 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 byHttp2FlowController.initialWindowSize()-Http2FlowController.windowSize(Http2Stream).- Specified by:
initialWindowSizein interfaceHttp2LocalFlowController
-
-