-
- All Known Implementing Classes:
UniformStreamByteDistributor
,WeightedFairQueueByteDistributor
@UnstableApi public interface StreamByteDistributor
An object (used by remote flow control) that is responsible for distributing the bytes to be written across the streams in the connection.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
StreamByteDistributor.StreamState
State information for the stream, indicating the number of bytes that are currently streamable.static interface
StreamByteDistributor.Writer
Object that performs the writing of the bytes that have been allocated for a stream.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
distribute(int maxBytes, StreamByteDistributor.Writer writer)
Distributes up tomaxBytes
to those streams containing streamable bytes and iterates across those streams to write the appropriate bytes.void
updateDependencyTree(int childStreamId, int parentStreamId, short weight, boolean exclusive)
Explicitly update the dependency tree.void
updateStreamableBytes(StreamByteDistributor.StreamState state)
Called when the streamable bytes for a stream has changed.
-
-
-
Method Detail
-
updateStreamableBytes
void updateStreamableBytes(StreamByteDistributor.StreamState state)
Called when the streamable bytes for a stream has changed. Until this method is called for the first time for a give stream, the stream is assumed to have no streamable bytes.
-
updateDependencyTree
void updateDependencyTree(int childStreamId, int parentStreamId, short weight, boolean exclusive)
Explicitly update the dependency tree. This method is called independently of stream state changes.- Parameters:
childStreamId
- The stream identifier associated with the child stream.parentStreamId
- The stream identifier associated with the parent stream. May be0
, to makechildStreamId
and immediate child of the connection.weight
- The weight which is used relative to other child streams forparentStreamId
. This value must be between 1 and 256 (inclusive).exclusive
- IfchildStreamId
should be the exclusive dependency ofparentStreamId
.
-
distribute
boolean distribute(int maxBytes, StreamByteDistributor.Writer writer) throws Http2Exception
Distributes up tomaxBytes
to those streams containing streamable bytes and iterates across those streams to write the appropriate bytes. Criteria for traversing streams is undefined and it is up to the implementation to determine when to stop at a given stream.The streamable bytes are not automatically updated by calling this method. It is up to the caller to indicate the number of bytes streamable after the write by calling
updateStreamableBytes(StreamState)
.- Parameters:
maxBytes
- the maximum number of bytes to write.- Returns:
true
if there are still streamable bytes that have not yet been written, otherwisefalse
.- Throws:
Http2Exception
- If an internal exception occurs and internal connection state would otherwise be corrupted.
-
-