akka.io
Class BackpressureBuffer
java.lang.Object
akka.io.PipelineStage<HasLogging,Tcp.Command,Tcp.Command,Tcp.Event,Tcp.Event>
akka.io.BackpressureBuffer
public class BackpressureBuffer
- extends PipelineStage<HasLogging,Tcp.Command,Tcp.Command,Tcp.Event,Tcp.Event>
This pipeline stage implements a configurable buffer for transforming the
per-write ACK/NACK-based backpressure model of a TCP connection actor into
an edge-triggered back-pressure model: the upper stages will receive
notification when the buffer runs full (BackpressureBuffer.HighWatermarkReached
) and when
it subsequently empties (BackpressureBuffer.LowWatermarkReached
). The upper layers should
respond by not generating more writes when the buffer is full. There is also
a hard limit upon which this buffer will abort the connection.
All limits are configurable and are given in number of bytes.
The highWatermark
should be set such that the
amount of data generated before reception of the asynchronous
BackpressureBuffer.HighWatermarkReached
notification does not lead to exceeding the
maxCapacity
hard limit; if the writes may arrive in bursts then the
difference between these two should allow for at least one burst to be sent
after the high watermark has been reached. The lowWatermark
must be less
than or equal to the highWatermark
, where the difference between these two
defines the hysteresis, i.e. how often these notifications are sent out (i.e.
if the difference is rather large then it will take some time for the buffer
to empty below the low watermark, and that room is then available for data
sent in response to the BackpressureBuffer.LowWatermarkReached
notification; if the
difference was small then the buffer would more quickly oscillate between
these two limits).
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
BackpressureBuffer
public BackpressureBuffer(long lowBytes,
long highBytes,
long maxBytes)
apply
public java.lang.Object apply(HasLogging ctx)