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 ofSubscriber
that storesByteBuffer
events it receives for retrieval.Stored bytes can be read via
transferTo(ByteBuffer)
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ByteBufferStoringSubscriber.TransferResult
The result oftransferTo(ByteBuffer)
.
-
Constructor Summary
Constructors Constructor Description ByteBufferStoringSubscriber(long minimumBytesBuffered)
Create a subscriber that stores at leastminimumBytesBuffered
in memory for retrieval.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ByteBufferStoringSubscriber.TransferResult
blockingTransferTo(ByteBuffer out)
LiketransferTo(ByteBuffer)
, but blocks until some data has been written.void
onComplete()
void
onError(Throwable t)
void
onNext(ByteBuffer byteBuffer)
void
onSubscribe(org.reactivestreams.Subscription s)
ByteBufferStoringSubscriber.TransferResult
transferTo(ByteBuffer out)
Transfer the data stored by this subscriber into the provided byte buffer.
-
-
-
Method Detail
-
transferTo
public ByteBufferStoringSubscriber.TransferResult transferTo(ByteBuffer out)
Transfer the data stored by this subscriber into the provided byte buffer.If the data stored by this subscriber exceeds
out
'slimit
, thenout
will be filled. If the data stored by this subscriber is less thanout
'slimit
, then all stored data will be written toout
.If
onError(Throwable)
was called on this subscriber, as much data as is available will be transferred intoout
before the provided exception is thrown (as aRuntimeException
).If
onComplete()
was called on this subscriber, as much data as is available will be transferred intoout
, and this will returnByteBufferStoringSubscriber.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 beforeonSubscribe(Subscription)
has returned.
-
blockingTransferTo
public ByteBufferStoringSubscriber.TransferResult blockingTransferTo(ByteBuffer out)
LiketransferTo(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 interfaceorg.reactivestreams.Subscriber<ByteBuffer>
-
onNext
public void onNext(ByteBuffer byteBuffer)
- Specified by:
onNext
in interfaceorg.reactivestreams.Subscriber<ByteBuffer>
-
onError
public void onError(Throwable t)
- Specified by:
onError
in interfaceorg.reactivestreams.Subscriber<ByteBuffer>
-
onComplete
public void onComplete()
- Specified by:
onComplete
in interfaceorg.reactivestreams.Subscriber<ByteBuffer>
-
-