Class BackpressureBuffer

  extended by akka.io.PipelineStage<HasLogging,Tcp.Command,Tcp.Command,Tcp.Event,Tcp.Event>
      extended by 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).

Nested Class Summary
 class BackpressureBuffer.Ack
 class BackpressureBuffer.Ack$
static interface BackpressureBuffer.HighWatermarkReached
          Message type which is sent when the buffer’s high watermark has been reached, which means that further write requests should not be sent until the low watermark has been reached again.
static class BackpressureBuffer.HighWatermarkReached$
static interface BackpressureBuffer.LowWatermarkReached
          Message type which is sent when the buffer’s fill level falls below the low watermark, which means that writing can commence again.
static class BackpressureBuffer.LowWatermarkReached$
Constructor Summary
BackpressureBuffer(long lowBytes, long highBytes, long maxBytes)
Method Summary
 java.lang.Object apply(HasLogging ctx)
Methods inherited from class akka.io.PipelineStage
combine, sequence
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public BackpressureBuffer(long lowBytes,
                          long highBytes,
                          long maxBytes)
Method Detail


public java.lang.Object apply(HasLogging ctx)