@UnstableApi public final class WeightedFairQueueByteDistributor extends java.lang.Object implements StreamByteDistributor
StreamByteDistributor ,并使用Weighted Fair Queueing方法分发字节。
这位经销商的启发来自Linux的Completely Fair Scheduler ,模拟字节分布以模拟“理想的多任务CPU”,但在这种情况下,我们正在模拟一个“理想的多任务NIC”。
每个写入操作将使用allocationQuantum(int)来知道相对于下一个要写入的数据流应该分配多少个字节。 这是为了平衡公平,同时也考虑到产出。
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)
设置将分配给每个流的字节数。
|
boolean |
distribute(int maxBytes, StreamByteDistributor.Writer writer)
将包含流传输字节的流分配到
maxBytes ,并遍历这些流以写入适当的字节。
|
void |
updateDependencyTree(int childStreamId, int parentStreamId, short weight, boolean exclusive)
显式更新依赖关系树。
|
void |
updateStreamableBytes(StreamByteDistributor.StreamState state)
当流的流传输字节已更改时调用。
|
public WeightedFairQueueByteDistributor(Http2Connection connection)
public WeightedFairQueueByteDistributor(Http2Connection connection, int maxStateOnlySize)
public void updateStreamableBytes(StreamByteDistributor.StreamState state)
StreamByteDistributor
updateStreamableBytes接口
StreamByteDistributor
public void updateDependencyTree(int childStreamId,
int parentStreamId,
short weight,
boolean exclusive)
StreamByteDistributor复制的描述
updateDependencyTree在界面
StreamByteDistributor
childStreamId - 与子流相关联的流标识符。
parentStreamId - 与父流关联的流标识符。
可能是0 ,使childStreamId和直接子连接。
weight - 用于parentStreamId相对于其他子流的parentStreamId 。
该值必须介于1和256(含)之间。
exclusive - 如果
childStreamId应该是
childStreamId的独占依赖
parentStreamId 。
public boolean distribute(int maxBytes,
StreamByteDistributor.Writer writer)
throws Http2Exception
StreamByteDistributor
maxBytes给那些包含流传输字节的流,并遍历这些流以写入适当的字节。
遍历流的标准是未定义的,并且由实现决定何时停止在给定的流。
流式字节不会通过调用此方法自动更新。 调用者可以通过调用StreamByteDistributor.updateStreamableBytes(StreamState)来指示写入之后流式传输的字节数。
distribute ,界面
StreamByteDistributor
maxBytes - 要写入的最大字节数。
true是否仍有尚未写入的流式字节,否则为
false 。
Http2Exception - 如果发生内部异常并且内部连接状态将被破坏。
public void allocationQuantum(int allocationQuantum)
allocationQuantum - 将分配给每个流的字节数。
必须> 0。
Copyright © 2008–2018 The Netty Project. All rights reserved.