@UnstableApi public class DefaultHttp2RemoteFlowController extends Object implements Http2RemoteFlowController
Http2RemoteFlowController
.
This class is NOT thread safe. The assumption is all methods must be invoked from a single thread.
Typically this thread is the event loop thread for the ChannelHandlerContext
managed by this class.
Http2RemoteFlowController.FlowControlled, Http2RemoteFlowController.Listener
Constructor and Description |
---|
DefaultHttp2RemoteFlowController(Http2Connection connection) |
DefaultHttp2RemoteFlowController(Http2Connection connection,
Http2RemoteFlowController.Listener listener) |
DefaultHttp2RemoteFlowController(Http2Connection connection,
StreamByteDistributor streamByteDistributor) |
DefaultHttp2RemoteFlowController(Http2Connection connection,
StreamByteDistributor streamByteDistributor,
Http2RemoteFlowController.Listener listener) |
Modifier and Type | Method and Description |
---|---|
void |
addFlowControlled(Http2Stream stream,
Http2RemoteFlowController.FlowControlled frame)
Queues a payload for transmission to the remote endpoint.
|
ChannelHandlerContext |
channelHandlerContext()
Get the
ChannelHandlerContext for which to apply flow control on. |
void |
channelHandlerContext(ChannelHandlerContext ctx)
Set the
ChannelHandlerContext for which to apply flow control on. |
void |
channelWritabilityChanged()
Notification that the writability of
Http2RemoteFlowController.channelHandlerContext() has changed. |
boolean |
hasFlowControlled(Http2Stream stream)
Determine if
stream has any Http2RemoteFlowController.FlowControlled frames currently queued. |
void |
incrementWindowSize(Http2Stream stream,
int delta)
Increments the size of the stream's flow control window by the given delta.
|
int |
initialWindowSize()
Gets the connection-wide initial flow control window size that is used as the basis for new stream flow
control windows.
|
void |
initialWindowSize(int newWindowSize)
Sets the connection-wide initial flow control window and updates all stream windows (but not the connection
stream window) by the delta.
|
boolean |
isWritable(Http2Stream stream)
Determine if the
stream has bytes remaining for use in the flow control window. |
void |
listener(Http2RemoteFlowController.Listener listener)
Set the active listener on the flow-controller.
|
void |
updateDependencyTree(int childStreamId,
int parentStreamId,
short weight,
boolean exclusive)
Explicitly update the dependency tree.
|
int |
windowSize(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.
|
void |
writePendingBytes()
Write all data pending in the flow controller up to the flow-control limits.
|
public DefaultHttp2RemoteFlowController(Http2Connection connection)
public DefaultHttp2RemoteFlowController(Http2Connection connection, StreamByteDistributor streamByteDistributor)
public DefaultHttp2RemoteFlowController(Http2Connection connection, Http2RemoteFlowController.Listener listener)
public DefaultHttp2RemoteFlowController(Http2Connection connection, StreamByteDistributor streamByteDistributor, Http2RemoteFlowController.Listener listener)
public void channelHandlerContext(ChannelHandlerContext ctx) throws Http2Exception
ChannelHandlerContext
for which to apply flow control on.
This must be called to properly initialize the Http2FlowController
.
Not calling this is considered a programming error.
Any queued FlowControlled
objects will be sent.
channelHandlerContext
in interface Http2FlowController
ctx
- The ChannelHandlerContext
for which to apply flow control on.Http2Exception
- if any protocol-related error occurred.public ChannelHandlerContext channelHandlerContext()
Http2RemoteFlowController
ChannelHandlerContext
for which to apply flow control on.
This is intended for us by Http2RemoteFlowController.FlowControlled
implementations only. Use with caution.
channelHandlerContext
in interface Http2RemoteFlowController
ChannelHandlerContext
for which to apply flow control on.public void initialWindowSize(int newWindowSize) throws Http2Exception
Http2FlowController
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 SETTINGS
frame.
initialWindowSize
in interface Http2FlowController
newWindowSize
- the new initial window size.Http2Exception
- thrown if any protocol-related error occurred.public int initialWindowSize()
Http2FlowController
Represents the value for
SETTINGS_INITIAL_WINDOW_SIZE. The initial value
returned by this method must be Http2CodecUtil.DEFAULT_WINDOW_SIZE
.
initialWindowSize
in interface Http2FlowController
public int windowSize(Http2Stream stream)
Http2FlowController
windowSize
in interface Http2FlowController
public boolean isWritable(Http2Stream stream)
Http2RemoteFlowController
stream
has bytes remaining for use in the flow control window.
Note that this only takes into account HTTP/2 flow control. It does not take into account
the underlying Channel.isWritable()
.
isWritable
in interface Http2RemoteFlowController
stream
- The stream to test.true
if if the stream
has bytes remaining for use in the flow control window.
false
otherwise.public void channelWritabilityChanged() throws Http2Exception
Http2RemoteFlowController
Http2RemoteFlowController.channelHandlerContext()
has changed.channelWritabilityChanged
in interface Http2RemoteFlowController
Http2Exception
- If any writes occur as a result of this call and encounter errors.public void updateDependencyTree(int childStreamId, int parentStreamId, short weight, boolean exclusive)
Http2RemoteFlowController
updateDependencyTree
in interface Http2RemoteFlowController
childStreamId
- The stream identifier associated with the child stream.parentStreamId
- The stream identifier associated with the parent stream. May be 0
,
to make childStreamId
and immediate child of the connection.weight
- The weight which is used relative to other child streams for parentStreamId
. This value
must be between 1 and 256 (inclusive).exclusive
- If childStreamId
should be the exclusive dependency of parentStreamId
.public void listener(Http2RemoteFlowController.Listener listener)
Http2RemoteFlowController
listener
in interface Http2RemoteFlowController
listener
- to notify when the a write occurs, can be null
.public void incrementWindowSize(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
stream
- 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 addFlowControlled(Http2Stream stream, Http2RemoteFlowController.FlowControlled frame)
Http2RemoteFlowController
Writes do not actually occur until Http2RemoteFlowController.writePendingBytes()
is called.
addFlowControlled
in interface Http2RemoteFlowController
stream
- the subject stream. Must not be the connection stream object.frame
- payload to write subject to flow-control accounting and ordering rules.public boolean hasFlowControlled(Http2Stream stream)
Http2RemoteFlowController
stream
has any Http2RemoteFlowController.FlowControlled
frames currently queued.hasFlowControlled
in interface Http2RemoteFlowController
stream
- the stream to check if it has flow controlled frames.true
if stream
has any Http2RemoteFlowController.FlowControlled
frames currently queued.public void writePendingBytes() throws Http2Exception
Http2RemoteFlowController
writePendingBytes
in interface Http2RemoteFlowController
Http2Exception
- throws if a protocol-related error occurred.Copyright © 2008–2017 The Netty Project. All rights reserved.