public abstract class AbstractClientStream<IdT> extends AbstractStream<IdT> implements ClientStream
ClientStream implementations.AbstractStream.PhaseDEFAULT_ONREADY_THRESHOLD| Modifier | Constructor and Description |
|---|---|
protected |
AbstractClientStream(WritableBufferAllocator bufferAllocator,
ClientStreamListener listener)
Constructor used by subclasses.
|
| Modifier and Type | Method and Description |
|---|---|
void |
cancel()
Cancel the stream.
|
protected void |
deframeFailed(Throwable cause)
Called when a
AbstractStream.deframe(ReadableBuffer, boolean) operation failed. |
void |
halfClose()
Closes the local side of this stream and flushes any remaining messages.
|
protected void |
inboundDataReceived(ReadableBuffer frame)
Processes the contents of a received data frame from the server.
|
protected void |
inboundDeliveryPaused()
Handles the event that the deframer has no pending deliveries.
|
protected void |
inboundHeadersReceived(Metadata.Headers headers)
Called by transport implementations when they receive headers.
|
protected void |
inboundTrailersReceived(Metadata.Trailers trailers,
Status status)
Processes the trailers and status from the server.
|
protected void |
inboundTransportError(Status errorStatus)
The transport implementation has detected a protocol error on the stream.
|
protected void |
internalSendFrame(WritableBuffer frame,
boolean endOfStream,
boolean flush)
Sends an outbound frame to the remote end point.
|
boolean |
isClosed()
Whether the stream is fully closed.
|
protected ClientStreamListener |
listener()
Gets the listener to this stream.
|
protected void |
receiveMessage(InputStream is)
Handles a message that was just deframed.
|
protected void |
remoteEndClosed()
Handles the event that the deframer has reached end of stream.
|
protected abstract void |
sendCancel()
Cancel the stream and send a stream cancellation message to the remote server, if necessary.
|
protected abstract void |
sendFrame(WritableBuffer frame,
boolean endOfStream,
boolean flush)
Sends an outbound frame to the remote end point.
|
protected Objects.ToStringHelper |
toStringHelper() |
void |
transportReportStatus(Status newStatus,
boolean stopDelivery,
Metadata.Trailers trailers)
Report stream closure with status to the application layer if not already reported.
|
canReceive, canSend, closeDeframer, deframe, dispose, flush, getOnReadyThreshold, id, isDeframerStalled, isReady, onSendingBytes, onSentBytes, onStreamAllocated, requestMessagesFromDeframer, returnProcessedBytes, setOnReadyThreshold, toString, writeMessageclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitflush, isReady, request, writeMessageprotected AbstractClientStream(WritableBufferAllocator bufferAllocator, ClientStreamListener listener)
listener - the listener to receive notificationsprotected final ClientStreamListener listener()
AbstractStreamlistener in class AbstractStream<IdT>protected void receiveMessage(InputStream is)
AbstractStreamreceiveMessage in class AbstractStream<IdT>is - the stream containing the messageprotected void inboundTransportError(Status errorStatus)
errorStatus - the error to reportprotected void inboundHeadersReceived(Metadata.Headers headers)
Status. If a transport reports an
Status.Code.INTERNAL errorheaders - the parsed headersprotected void inboundDataReceived(ReadableBuffer frame)
frame - the received data frame. Its ownership is transferred to this method.protected void inboundDeliveryPaused()
AbstractStreaminboundDeliveryPaused in class AbstractStream<IdT>protected final void deframeFailed(Throwable cause)
AbstractStreamAbstractStream.deframe(ReadableBuffer, boolean) operation failed.deframeFailed in class AbstractStream<IdT>cause - the actual failureprotected void inboundTrailersReceived(Metadata.Trailers trailers, Status status)
trailers - the received trailersstatus - the status extracted from the trailersprotected void remoteEndClosed()
AbstractStreamremoteEndClosed in class AbstractStream<IdT>protected final void internalSendFrame(WritableBuffer frame, boolean endOfStream, boolean flush)
AbstractStreaminternalSendFrame in class AbstractStream<IdT>frame - a buffer containing the chunk of data to be sent.endOfStream - if true indicates that no more data will be sent on the stream by
this endpoint.flush - true if more data may not be arriving soonprotected abstract void sendFrame(WritableBuffer frame, boolean endOfStream, boolean flush)
frame - a buffer containing the chunk of data to be sent or null if the framer is
closing and has no data to send.endOfStream - if true indicates that no more data will be sent on the stream by
this endpoint.flush - true if more data may not be arriving soonpublic void transportReportStatus(Status newStatus, boolean stopDelivery, Metadata.Trailers trailers)
newStatus - the new status to setstopDelivery - if true, interrupts any further delivery of inbound messages that
may already be queued up in the deframer. If false, the listener will be
notified immediately after all currently completed messages in the deframer have been
delivered to the application.trailers - new instance of Trailers, either empty or those returned by the serverpublic final void halfClose()
ClientStreamhalfClose in interface ClientStreampublic void cancel()
cancel in interface ClientStreamprotected abstract void sendCancel()
protected Objects.ToStringHelper toStringHelper()
toStringHelper in class AbstractStream<IdT>public boolean isClosed()
AbstractStreaminboundPhase and outboundPhase are mutated in different threads. Tests must account
for thread coordination when calling.isClosed in class AbstractStream<IdT>