T - the type of results this implementation buffersR - the type of message used for flow control in this bufferpublic abstract class FlowControlledBuffer<T,R> extends FlowControlledStream<T,R>
FlowControlledStream, adding buffering logic to the flow controlled stream.| Constructor and Description |
|---|
FlowControlledBuffer(String clientId,
int bufferSize,
int refillBatch)
Constructs a
FlowControlledBuffer. |
| Modifier and Type | Method and Description |
|---|---|
void |
beforeStart(io.grpc.stub.ClientCallStreamObserver<R> requestStream) |
void |
close() |
Throwable |
getErrorResult()
Returns the error result, if any was recorded.
|
protected boolean |
isClosed()
Check whether this buffer has been closed off
|
void |
onCompleted() |
void |
onError(Throwable t) |
void |
onNext(T value) |
protected T |
peek()
Retrieves, but does not remove, the first entry of this buffer, or returns
null if the buffer is empty. |
protected T |
take()
Take an entry of type
T from the buffer, waiting indefinitely. |
protected abstract T |
terminalMessage()
Builds a terminal message of type
T specifying when the this stream is closed. |
protected T |
tryTake()
Try to retrieve an entry of type
T from the buffer, waiting indefinitely. |
protected T |
tryTake(long timeout,
TimeUnit timeUnit)
Try to retrieve an entry of type
T from the buffer, waiting for the duration of timeout in the
given timeUnit. |
protected T |
tryTake(long timeout,
TimeUnit timeUnit,
boolean exceptionOnTimeout)
Try to retrieve an entry of type
T from the buffer, waiting for the duration of timeout in the
given timeUnit. |
protected T |
tryTakeNow()
Try to retrieve an entry of type
T from the buffer immediately. |
buildFlowControlMessage, buildInitialFlowControlMessage, enableFlowControl, markConsumed, outboundStreampublic FlowControlledBuffer(String clientId, int bufferSize, int refillBatch)
FlowControlledBuffer.clientId - the client identifier which initiated this bufferbufferSize - the number of entries this buffer should holdrefillBatch - the number of entries to be consumed prior to requesting new onceprotected abstract T terminalMessage()
T specifying when the this stream is closed.T specifying when the this stream is closedpublic void onNext(T value)
public void onError(Throwable t)
public void onCompleted()
public void close()
public Throwable getErrorResult()
nullpublic void beforeStart(io.grpc.stub.ClientCallStreamObserver<R> requestStream)
beforeStart in interface io.grpc.stub.ClientResponseObserver<R,T>beforeStart in class FlowControlledStream<T,R>protected T tryTakeNow()
T from the buffer immediately. If none is present, null will be
returned.T from this buffer if present, otherwise nullprotected T tryTake(long timeout, TimeUnit timeUnit) throws InterruptedException
T from the buffer, waiting for the duration of timeout in the
given timeUnit. If none is present, null will be returned.timeout - the duration to wait for an entry to become available in the buffertimeUnit - the TimeUnit used to specify the duration together with the timeoutT from this buffer if present, otherwise null. Timeouts will result in
null as well.InterruptedException - while waiting for an entry to be takenprotected T tryTake(long timeout, TimeUnit timeUnit, boolean exceptionOnTimeout) throws InterruptedException
T from the buffer, waiting for the duration of timeout in the
given timeUnit. If none is present, null will be returned.timeout - the duration to wait for an entry to become available in the buffertimeUnit - the TimeUnit used to specify the duration together with the timeoutexceptionOnTimeout - Whether a TimeoutException should be thrown when the operation times outT from this buffer if present, otherwise nullInterruptedException - while waiting for an entry to be takenStreamTimeoutException - If there is no message available after waiting the allotted periodprotected T tryTake() throws InterruptedException
T from the buffer, waiting indefinitely. If none is present because the
buffer is closed, null will be returned.T from this buffer if present, otherwise nullInterruptedException - while waiting for an entry to be takenprotected T take() throws InterruptedException
T from the buffer, waiting indefinitely.T from this bufferInterruptedException - while waiting for an entry to be takenprotected T peek()
null if the buffer is empty.null if it is emptyprotected boolean isClosed()
true if this buffer is closed, false otherwiseCopyright © 2020–2023 AxonIQ BV. All rights reserved.