Top Description Fields Constructors Methods
org.eclipse.jetty.http2

public Class BufferingFlowControlStrategy

extends AbstractFlowControlStrategy
Class Inheritance
Annotations
@ManagedObject
Imports
java.util.List, .Map, java.util.concurrent.ConcurrentHashMap, java.util.concurrent.atomic.AtomicInteger, org.eclipse.jetty.http2.api.Session, .Stream, org.eclipse.jetty.http2.frames.WindowUpdateFrame, org.eclipse.jetty.util.Atomics, org.eclipse.jetty.util.annotation.ManagedAttribute, .ManagedObject, org.slf4j.Logger, .LoggerFactory

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, where the bamboo is the smaller bucket and the pool is the bigger bucket.

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.

The bufferRatio controls how often the window control frame is emitted.

A bufferRatio=0.0 means that a window control frame is emitted every time the application consumes a data frame. This may result in too many window control frames be emitted, but may allow the sender to avoid stalling.

A bufferRatio=1.0 means that a window control frame is emitted only when the application has consumed a whole window. This minimizes the number of window control frames emitted, but may cause the sender to stall, waiting for the window control frame.

The default value is bufferRatio=0.5.

Field Summary

Modifier and TypeField and Description
private float
private static final Logger
private final AtomicInteger
private final AtomicInteger
private final Map<Stream, AtomicInteger>

Constructor Summary

AccessConstructor and Description
public
BufferingFlowControlStrategy(float bufferRatio)

public
BufferingFlowControlStrategy(int initialStreamSendWindow, float bufferRatio)

Method Summary

Modifier and TypeMethod and Description
public float
public void
public void
public void
public void
setBufferRatio(float bufferRatio)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public void
Inherited from org.eclipse.jetty.http2.AbstractFlowControlStrategy:
dumpdumpgetInitialStreamRecvWindowgetInitialStreamSendWindowgetSessionStallTimegetStreamsStallTimeonDataReceivedonDataSendingonDataSentonSessionStalledonSessionUnstalledonStreamStalledonStreamUnstalledonWindowUpdateresetsendWindowUpdateupdateInitialStreamWindowupdateRecvWindowupdateRecvWindowupdateSendWindowupdateSendWindowupdateWindow

Field Detail

bufferRatioback to summary
private float bufferRatio
LOGback to summary
private static final Logger LOG

Hides org.eclipse.jetty.http2.AbstractFlowControlStrategy.LOG.

maxSessionRecvWindowback to summary
private final AtomicInteger maxSessionRecvWindow
sessionLevelback to summary
private final AtomicInteger sessionLevel
streamLevelsback to summary
private final Map<Stream, AtomicInteger> streamLevels

Constructor Detail

BufferingFlowControlStrategyback to summary
public BufferingFlowControlStrategy(float bufferRatio)
BufferingFlowControlStrategyback to summary
public BufferingFlowControlStrategy(int initialStreamSendWindow, float bufferRatio)

Method Detail

getBufferRatioback to summary
public float getBufferRatio()
Annotations
@ManagedAttribute:The ratio between the receive buffer and the consume buffer
onDataConsumedback to summary
public void onDataConsumed(Session session, Stream stream, int length)

Implements org.eclipse.jetty.http2.FlowControlStrategy.onDataConsumed.

Annotations
@Override
onStreamCreatedback to summary
public void onStreamCreated(Stream stream)

Overrides org.eclipse.jetty.http2.AbstractFlowControlStrategy.onStreamCreated.

Implements org.eclipse.jetty.http2.FlowControlStrategy.onStreamCreated.

Annotations
@Override
onStreamDestroyedback to summary
public void onStreamDestroyed(Stream stream)

Overrides org.eclipse.jetty.http2.AbstractFlowControlStrategy.onStreamDestroyed.

Implements org.eclipse.jetty.http2.FlowControlStrategy.onStreamDestroyed.

Annotations
@Override
setBufferRatioback to summary
public void setBufferRatio(float bufferRatio)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
windowUpdateback to summary
public void windowUpdate(Session session, Stream stream, WindowUpdateFrame frame)

Overrides org.eclipse.jetty.http2.AbstractFlowControlStrategy.windowUpdate.

Implements org.eclipse.jetty.http2.FlowControlStrategy.windowUpdate.

Annotations
@Override