Processing is done by implementing the incoming(List, boolean) method
which supplies buffers from upstream. This method (or any other method)
can then call the outgoing() method to deliver processed buffers downstream.
Upstream error signals are delivered downstream directly. Cancellation from downstream is also propagated upstream immediately.
Each SubscriberWrapper has a java.<Void>
which propagates completion/errors from downstream to upstream. Normal completion
can only occur after onComplete() is called, but errors can be propagated upwards
at any time.
| Modifier and Type | Class and Description |
|---|---|
| pack-priv class | SubscriberWrapper.
Invoked whenever it 'may' be possible to push buffers downstream. |
| public static enum |
| Modifier and Type | Field and Description |
|---|---|
| private final CompletableFuture | |
| pack-priv volatile boolean | |
| pack-priv final Logger | |
| pack-priv volatile boolean | |
| private volatile Flow. | |
| pack-priv final SubscriptionBase | |
| private final AtomicReference | |
| private final ConcurrentLinkedQueue | |
| private final SequentialScheduler | |
| pack-priv volatile boolean | |
| pack-priv volatile Flow. | |
| pack-priv final AtomicLong |
| Access | Constructor and Description |
|---|---|
| public | |
| public | SubscriberWrapper(Flow.
downstream destination downstreamWrapperWraps the given downstream wrapper in this. |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| pack-priv void | |
| public void | close()
Implements java. Closes this stream and releases any system resources associated with it. |
| public void | |
| public boolean | Returns: true, may be overridden by subclasses.Sometime it might be necessary to complete the downstream subscriber before the upstream completes. |
| public CompletableFuture | |
| public String | |
| pack-priv void | |
| protected SubscriberWrapper. | enterScheduling()
Override this if anything needs to be done before checking for error and processing the input queue. |
| protected boolean | |
| pack-priv final boolean | |
| protected abstract void | incoming(List<ByteBuffer>
a List of ByteBuffers. buffers, boolean if true then no more data will be added to the list complete)Delivers data to be processed by this wrapper. |
| private void | |
| protected long | Returns: The initial demand to request from upstream.Initial demand that should be requested
from upstream when we get the upstream subscription
from |
| public void | onComplete()
Implements java. Method invoked when it is known that no additional Subscriber method invocations will occur for a Subscription that is not already terminated by error, after which no other Subscriber methods are invoked by the Subscription. |
| public void | onError(Throwable throwable)
Implements java. Method invoked upon an unrecoverable error encountered by a Publisher or Subscription, after which no other Subscriber methods are invoked by the Subscription. |
| public void | onNext(List<ByteBuffer> item)
Implements java. Method invoked with a Subscription's next item. |
| protected void | onSubscribe()
Override this if anything needs to be done after the upstream subscriber has subscribed |
| public void | onSubscribe(Flow.
Implements java. Method invoked prior to invoking any other Subscriber methods for the given Subscription. |
| public void | |
| public void | |
| pack-priv final int | |
| protected void | |
| public void | |
| protected boolean | |
| public final void | subscribe(Flow.
Implements java. Adds the given Subscriber if possible. |
| public String | |
| private void | |
| public long | |
| protected long | Returns: value to add to currentWindowthe current upstream subscription window currentWindow, long the current number of buffers waiting to be sent
downstream downstreamQsize)This method is called to determine the window size to use at any time. |
| pack-priv void |
| cf | back to summary |
|---|---|
| private final CompletableFuture<Void> cf | |
| completionAcknowledged | back to summary |
|---|---|
| pack-priv volatile boolean completionAcknowledged | |
| debug | back to summary |
|---|---|
| pack-priv final Logger debug | |
| downstreamCompleted | back to summary |
|---|---|
| pack-priv volatile boolean downstreamCompleted | |
| downstreamSubscriber | back to summary |
|---|---|
| private volatile Flow. | |
| downstreamSubscription | back to summary |
|---|---|
| pack-priv final SubscriptionBase downstreamSubscription | |
| errorRef | back to summary |
|---|---|
| private final AtomicReference<Throwable> errorRef | |
| outputQ | back to summary |
|---|---|
| private final ConcurrentLinkedQueue<List<ByteBuffer>> outputQ | |
| pushScheduler | back to summary |
|---|---|
| private final SequentialScheduler pushScheduler | |
| upstreamCompleted | back to summary |
|---|---|
| pack-priv volatile boolean upstreamCompleted | |
| upstreamSubscription | back to summary |
|---|---|
| pack-priv volatile Flow. | |
| upstreamWindow | back to summary |
|---|---|
| pack-priv final AtomicLong upstreamWindow | |
| SubscriberWrapper | back to summary |
|---|---|
| public SubscriberWrapper() Wraps the given downstream subscriber. For each call to | |
| SubscriberWrapper | back to summary |
|---|---|
| public SubscriberWrapper(Flow. Wraps the given downstream wrapper in this. For each call to
| |
| addData | back to summary |
|---|---|
| public void addData(ByteBuffer l) Adds the given data to the input queue. | |
| checkCompletion | back to summary |
|---|---|
| pack-priv void checkCompletion() | |
| close | back to summary |
|---|---|
| public void close() Implements java. Doc from java. Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect. As noted in
| |
| close | back to summary |
|---|---|
| public void close(Throwable t) | |
| closing | back to summary |
|---|---|
| public boolean closing() Sometime it might be necessary to complete the downstream subscriber before the upstream completes. For instance, when an SSL server sends a notify_close. In that case we should let the outgoing complete before upstream is completed.
| |
| completion | back to summary |
|---|---|
| public CompletableFuture Returns a CompletableFuture which completes when this wrapper completes. Normal completion happens with the following steps (in order): 1. onComplete() is called 2. incoming() called with complete = true 3. outgoing() may continue to be called normally 4. outgoing called with complete = true 5. downstream subscriber is called onComplete() If the subscription is canceled or onComplete() is invoked the CompletableFuture completes exceptionally. Exceptional completion also occurs if downstreamCF completes exceptionally. | |
| dbgString | back to summary |
|---|---|
| public String dbgString() | |
| downstreamCompletion | back to summary |
|---|---|
| pack-priv void downstreamCompletion() | |
| enterScheduling | back to summary |
|---|---|
| protected SubscriberWrapper. Override this if anything needs to be done before checking for error and processing the input queue. | |
| errorCommon | back to summary |
|---|---|
| protected boolean errorCommon(Throwable throwable) | |
| hasNoOutputData | back to summary |
|---|---|
| pack-priv final boolean hasNoOutputData() | |
| incoming | back to summary |
|---|---|
| protected abstract void incoming(List<ByteBuffer> buffers, boolean complete) Delivers data to be processed by this wrapper. Generated data to be sent
downstream, must be provided to the
| |
| incomingCaller | back to summary |
|---|---|
| private void incomingCaller(List<ByteBuffer> l, boolean complete) | |
| initialUpstreamDemand | back to summary |
|---|---|
| protected long initialUpstreamDemand() Initial demand that should be requested
from upstream when we get the upstream subscription
from
| |
| onComplete | back to summary |
|---|---|
| public void onComplete() Implements java. Doc from java. Method invoked when it is known that no additional Subscriber method invocations will occur for a Subscription that is not already terminated by error, after which no other Subscriber methods are invoked by the Subscription. If this method throws an exception, resulting behavior is undefined.
| |
| onError | back to summary |
|---|---|
| public void onError(Throwable throwable) Implements java. Doc from java. Method invoked upon an unrecoverable error encountered by a Publisher or Subscription, after which no other Subscriber methods are invoked by the Subscription. If this method itself throws an exception, resulting behavior is undefined.
| |
| onNext | back to summary |
|---|---|
| public void onNext(List<ByteBuffer> item) Implements java. Doc from java. Method invoked with a Subscription's next item. If this method throws an exception, resulting behavior is not guaranteed, but may cause the Subscription to be cancelled.
| |
| onSubscribe | back to summary |
|---|---|
| protected void onSubscribe() Override this if anything needs to be done after the upstream subscriber has subscribed | |
| onSubscribe | back to summary |
|---|---|
| public void onSubscribe(Flow. Implements java. Doc from java. Method invoked prior to invoking any other Subscriber methods for the given Subscription. If this method throws an exception, resulting behavior is not guaranteed, but may cause the Subscription not to be established or to be cancelled. Typically, implementations of this method invoke
| |
| outgoing | back to summary |
|---|---|
| public void outgoing(ByteBuffer buffer, boolean complete) Delivers buffers of data downstream. After incoming() has been called complete == true signifying completion of the upstream subscription, data may continue to be delivered, up to when outgoing() is called complete == true, after which, the downstream subscription is completed. It's an error to call outgoing() with complete = true if incoming() has not previously been called with it. | |
| outgoing | back to summary |
|---|---|
| public void outgoing(List<ByteBuffer> buffers, boolean complete) | |
| outputQueueSize | back to summary |
|---|---|
| pack-priv final int outputQueueSize() | |
| requestMore | back to summary |
|---|---|
| protected void requestMore() | |
| resetDownstreamDemand | back to summary |
|---|---|
| public void resetDownstreamDemand() | |
| signalScheduling | back to summary |
|---|---|
| protected boolean signalScheduling() | |
| subscribe | back to summary |
|---|---|
| public final void subscribe(Flow. Implements java. Doc from java. Adds the given Subscriber if possible. If already
subscribed, or the attempt to subscribe fails due to policy
violations or errors, the Subscriber's
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non-
| |
| upstreamRequest | back to summary |
|---|---|
| private void upstreamRequest(long n) | |
| upstreamWindow | back to summary |
|---|---|
| public long upstreamWindow() | |
| upstreamWindowUpdate | back to summary |
|---|---|
| protected long upstreamWindowUpdate(long currentWindow, long downstreamQsize) This method is called to determine the window size to use at any time. The
current window is supplied together with the current downstream queue size.
| |
| upstreamWindowUpdate | back to summary |
|---|---|
| pack-priv void upstreamWindowUpdate() | |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| private void |
| DownstreamPusher | back to summary |
|---|---|
| pack-priv DownstreamPusher() | |
| run | back to summary |
|---|---|
| public void run() Implements java. Doc from java. Runs this operation.
| |
| run1 | back to summary |
|---|---|
| private void run1() | |
| Modifier and Type | Field and Description |
|---|---|
| public static final SubscriberWrapper. | |
| public static final SubscriberWrapper. | |
| public static final SubscriberWrapper. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static SubscriberWrapper. | |
| public static SubscriberWrapper. |
| CONTINUE | back to summary |
|---|---|
| public static final SubscriberWrapper. | |
| RESCHEDULE | back to summary |
|---|---|
| public static final SubscriberWrapper. | |
| RETURN | back to summary |
|---|---|
| public static final SubscriberWrapper. | |
| SchedulingAction | back to summary |
|---|---|
| private SchedulingAction() | |
| valueOf | back to summary |
|---|---|
| public static SubscriberWrapper. | |
| values | back to summary |
|---|---|
| public static SubscriberWrapper. | |