public final class WeightedFairQueueByteDistributor extends Object implements StreamByteDistributor
StreamByteDistributor that is sensitive to stream priority and uses
 Weighted Fair Queueing approach for distributing
 bytes.
 Inspiration for this distributor was taken from Linux's Completely Fair Scheduler to model the distribution of bytes to simulate an "ideal multi-tasking CPU", but in this case we are simulating an "ideal multi-tasking NIC".
 Each write operation will use the allocationQuantum(int) to know how many more bytes should be allocated
 relative to the next stream which wants to write. This is to balance fairness while also considering goodput.
StreamByteDistributor.StreamState, StreamByteDistributor.Writer| Constructor and Description | 
|---|
| WeightedFairQueueByteDistributor(Http2Connection connection) | 
| WeightedFairQueueByteDistributor(Http2Connection connection,
                                int maxStateOnlySize) | 
| Modifier and Type | Method and Description | 
|---|---|
| void | allocationQuantum(int allocationQuantum)Sets the amount of bytes that will be allocated to each stream. | 
| boolean | distribute(int maxBytes,
          StreamByteDistributor.Writer writer)Distributes up to  maxBytesto 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. | 
public WeightedFairQueueByteDistributor(Http2Connection connection)
public WeightedFairQueueByteDistributor(Http2Connection connection, int maxStateOnlySize)
public void updateStreamableBytes(StreamByteDistributor.StreamState state)
StreamByteDistributorupdateStreamableBytes in interface StreamByteDistributorpublic void updateDependencyTree(int childStreamId,
                                 int parentStreamId,
                                 short weight,
                                 boolean exclusive)
StreamByteDistributorupdateDependencyTree in interface StreamByteDistributorchildStreamId - 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 boolean distribute(int maxBytes,
                          StreamByteDistributor.Writer writer)
                   throws Http2Exception
StreamByteDistributormaxBytes 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
 StreamByteDistributor.updateStreamableBytes(StreamState).
distribute in interface StreamByteDistributormaxBytes - the maximum number of bytes to write.true if there are still streamable bytes that have not yet been written,
 otherwise false.Http2Exception - If an internal exception occurs and internal connection state would otherwise be
 corrupted.public void allocationQuantum(int allocationQuantum)
allocationQuantum - the amount of bytes that will be allocated to each stream. Must be > 0.Copyright © 2008–2025 The Netty Project. All rights reserved.