public class BufferingFlowControlStrategy extends AbstractFlowControlStrategy
A flow control strategy that accumulates updates and emits window control frames when the accumulated value reaches a threshold.
The sender flow control window is represented in the receiver as two buckets: a bigger bucket, initially full, that is drained when data is received, and a smaller bucket, initially empty, that is filled when data is consumed. Only the smaller bucket can refill the bigger bucket.
The smaller bucket is defined as a fraction of the bigger bucket.
For a more visual representation, see the rocking bamboo fountain.
The algorithm works in this way.
The initial bigger bucket (BB) capacity is 100, and let's imagine the smaller bucket (SB) being 40% of the bigger bucket: 40.
The receiver receives a data frame of 60, so now BB=40; the data frame is passed to the application that consumes 25, so now SB=25. Since SB is not full, no window control frames are emitted.
The application consumes other 20, so now SB=45. Since SB is full, its 45 are transferred to BB, which is now BB=85, and a window control frame is sent with delta=45.
The application consumes the remaining 15, so now SB=15, and no window control frame is emitted.
logDEFAULT_WINDOW_SIZE| 构造器和说明 |
|---|
BufferingFlowControlStrategy(float bufferRatio) |
BufferingFlowControlStrategy(int initialStreamSendWindow,
float bufferRatio) |
| 限定符和类型 | 方法和说明 |
|---|---|
float |
getBufferRatio() |
void |
onDataConsumed(SessionSPI session,
StreamSPI stream,
int length) |
void |
onStreamCreated(StreamSPI stream) |
void |
onStreamDestroyed(StreamSPI stream) |
void |
setBufferRatio(float bufferRatio) |
String |
toString() |
void |
windowUpdate(SessionSPI session,
StreamSPI stream,
WindowUpdateFrame frame) |
getInitialStreamRecvWindow, getInitialStreamSendWindow, getSessionStallTime, getStreamsStallTime, onDataReceived, onDataSending, onDataSent, onSessionStalled, onSessionUnstalled, onStreamStalled, onStreamUnstalled, onWindowUpdate, reset, updateInitialStreamWindowpublic BufferingFlowControlStrategy(float bufferRatio)
public BufferingFlowControlStrategy(int initialStreamSendWindow,
float bufferRatio)
public float getBufferRatio()
public void setBufferRatio(float bufferRatio)
public void onStreamCreated(StreamSPI stream)
onStreamCreated 在接口中 FlowControlStrategyonStreamCreated 在类中 AbstractFlowControlStrategypublic void onStreamDestroyed(StreamSPI stream)
onStreamDestroyed 在接口中 FlowControlStrategyonStreamDestroyed 在类中 AbstractFlowControlStrategypublic void onDataConsumed(SessionSPI session, StreamSPI stream, int length)
public void windowUpdate(SessionSPI session, StreamSPI stream, WindowUpdateFrame frame)
windowUpdate 在接口中 FlowControlStrategywindowUpdate 在类中 AbstractFlowControlStrategyCopyright © 2017. All rights reserved.