Class ByteBufferStoringSubscriber

java.lang.Object
software.amazon.awssdk.utils.async.ByteBufferStoringSubscriber
All Implemented Interfaces:
org.reactivestreams.Subscriber<ByteBuffer>

public class ByteBufferStoringSubscriber extends Object implements org.reactivestreams.Subscriber<ByteBuffer>
An implementation of Subscriber that stores ByteBuffer events it receives for retrieval.

Stored bytes can be read via transferTo(ByteBuffer).

  • Constructor Details

    • ByteBufferStoringSubscriber

      public ByteBufferStoringSubscriber(long minimumBytesBuffered)
      Create a subscriber that stores at least minimumBytesBuffered in memory for retrieval.
  • Method Details

    • transferTo

      Transfer the data stored by this subscriber into the provided byte buffer.

      If the data stored by this subscriber exceeds out's limit, then out will be filled. If the data stored by this subscriber is less than out's limit, then all stored data will be written to out.

      If onError(Throwable) was called on this subscriber, as much data as is available will be transferred into out before the provided exception is thrown (as a RuntimeException).

      If onComplete() was called on this subscriber, as much data as is available will be transferred into out, and this will return ByteBufferStoringSubscriber.TransferResult.END_OF_STREAM.

      Note: This method MUST NOT be called concurrently with itself or blockingTransferTo(ByteBuffer). Other methods on this class may be called concurrently with this one. This MUST NOT be called before onSubscribe(Subscription) has returned.

    • blockingTransferTo

      public ByteBufferStoringSubscriber.TransferResult blockingTransferTo(ByteBuffer out)
      Like transferTo(ByteBuffer), but blocks until some data has been written.

      Note: This method MUST NOT be called concurrently with itself or transferTo(ByteBuffer). Other methods on this class may be called concurrently with this one.

    • onSubscribe

      public void onSubscribe(org.reactivestreams.Subscription s)
      Specified by:
      onSubscribe in interface org.reactivestreams.Subscriber<ByteBuffer>
    • onNext

      public void onNext(ByteBuffer byteBuffer)
      Specified by:
      onNext in interface org.reactivestreams.Subscriber<ByteBuffer>
    • onError

      public void onError(Throwable t)
      Specified by:
      onError in interface org.reactivestreams.Subscriber<ByteBuffer>
    • onComplete

      public void onComplete()
      Specified by:
      onComplete in interface org.reactivestreams.Subscriber<ByteBuffer>