Top Description Fields Constructors Methods
org.apache.hc.core5.reactive

pack-priv final Class ReactiveDataProducer

extends Object
implements AsyncDataProducer, Subscriber<ByteBuffer>
Class Inheritance
All Implemented Interfaces
org.reactivestreams.Subscriber, org.apache.hc.core5.http.nio.AsyncDataProducer, org.apache.hc.core5.http.nio.ResourceHolder
Annotations
@Contract
threading:SAFE
Imports
java.io.IOException, java.nio.ByteBuffer, java.util.ArrayDeque, java.util.concurrent.atomic.AtomicBoolean, .AtomicReference, org.apache.hc.core5.annotation.Contract, .ThreadingBehavior, org.apache.hc.core5.http.HttpStreamResetException, org.apache.hc.core5.http.nio.AsyncDataProducer, .DataStreamChannel, org.apache.hc.core5.util.Args, org.reactivestreams.Publisher, .Subscriber, .Subscription

An asynchronous data producer that supports Reactive Streams.
Since
5.0

Field Summary

Modifier and TypeField and Description
private static final int
private final ArrayDeque<ByteBuffer>
private final AtomicBoolean
private final AtomicReference<Throwable>
private final Publisher<ByteBuffer>
private final AtomicReference<DataStreamChannel>
private final AtomicReference<Subscription>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public int
available()

Implements org.apache.hc.core5.http.nio.AsyncDataProducer.available.

Returns the number of bytes immediately available for output.
public void
onComplete()

Implements org.reactivestreams.Subscriber.onComplete.

Successful terminal state.
public void
onError(final Throwable
the throwable signaled
throwable
)

Implements org.reactivestreams.Subscriber.onError.

Failed terminal state.
public void
onNext(final ByteBuffer
the element signaled
byteBuffer
)

Implements org.reactivestreams.Subscriber.onNext.

Data notification sent by the Publisher in response to requests to Subscription#request(long).
public void
onSubscribe(final Subscription
the Subscription that allows requesting data via Subscription#request(long)
subscription
)

Implements org.reactivestreams.Subscriber.onSubscribe.

Invoked after calling Publisher#subscribe(Subscriber).
public void
produce(final DataStreamChannel
the data channel capable to accepting more data.
channel
)

Implements org.apache.hc.core5.http.nio.AsyncDataProducer.produce.

Triggered to signal the ability of the underlying data channel to accept more data.
public void
pack-priv void
private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BUFFER_WINDOW_SIZEback to summary
private static final int BUFFER_WINDOW_SIZE
buffersback to summary
private final ArrayDeque<ByteBuffer> buffers
completeback to summary
private final AtomicBoolean complete
exceptionback to summary
private final AtomicReference<Throwable> exception
publisherback to summary
private final Publisher<ByteBuffer> publisher
requestChannelback to summary
private final AtomicReference<DataStreamChannel> requestChannel
subscriptionback to summary
private final AtomicReference<Subscription> subscription

Constructor Detail

ReactiveDataProducerback to summary
public ReactiveDataProducer(final Publisher<ByteBuffer> publisher)

Method Detail

availableback to summary
public int available()

Implements org.apache.hc.core5.http.nio.AsyncDataProducer.available.

Doc from org.apache.hc.core5.http.nio.AsyncDataProducer.available.

Returns the number of bytes immediately available for output. This method can be used as a hint to control output events of the underlying I/O session.

Returns:int

the number of bytes immediately available for output

Annotations
@Override
onCompleteback to summary
public void onComplete()

Implements org.reactivestreams.Subscriber.onComplete.

Doc from org.reactivestreams.Subscriber.onComplete.

Successful terminal state.

No further events will be sent even if Subscription#request(long) is invoked again.

Annotations
@Override
onErrorback to summary
public void onError(final Throwable throwable)

Implements org.reactivestreams.Subscriber.onError.

Doc from org.reactivestreams.Subscriber.onError.

Failed terminal state.

No further events will be sent even if Subscription#request(long) is invoked again.

Parameters
throwable:Throwable

the throwable signaled

Annotations
@Override
onNextback to summary
public void onNext(final ByteBuffer byteBuffer)

Implements org.reactivestreams.Subscriber.onNext.

Doc from org.reactivestreams.Subscriber.onNext.

Data notification sent by the Publisher in response to requests to Subscription#request(long).

Parameters
byteBuffer:ByteBuffer

the element signaled

Annotations
@Override
onSubscribeback to summary
public void onSubscribe(final Subscription subscription)

Implements org.reactivestreams.Subscriber.onSubscribe.

Doc from org.reactivestreams.Subscriber.onSubscribe.

Invoked after calling Publisher#subscribe(Subscriber).

No data will start flowing until Subscription#request(long) is invoked.

It is the responsibility of this Subscriber instance to call Subscription#request(long) whenever more data is wanted.

The Publisher will send notifications only in response to Subscription#request(long).

Parameters
subscription:Subscription

the Subscription that allows requesting data via Subscription#request(long)

Annotations
@Override
produceback to summary
public void produce(final DataStreamChannel channel) throws IOException

Implements org.apache.hc.core5.http.nio.AsyncDataProducer.produce.

Doc from org.apache.hc.core5.http.nio.AsyncDataProducer.produce.

Triggered to signal the ability of the underlying data channel to accept more data. The data producer can choose to write data immediately inside the call or asynchronously at some later point.

Parameters
channel:DataStreamChannel

the data channel capable to accepting more data.

Annotations
@Override
releaseResourcesback to summary
public void releaseResources()

Implements org.apache.hc.core5.http.nio.ResourceHolder.releaseResources.

Annotations
@Override
setChannelback to summary
pack-priv void setChannel(final DataStreamChannel channel)
signalReadinessback to summary
private void signalReadiness()