public abstract class AbstractClientStream<IdT> extends AbstractStream<IdT> implements ClientStream
ClientStream
implementations.AbstractStream.Phase
DEFAULT_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, writeMessage
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
flush, isReady, request, writeMessage
protected AbstractClientStream(WritableBufferAllocator bufferAllocator, ClientStreamListener listener)
listener
- the listener to receive notificationsprotected final ClientStreamListener listener()
AbstractStream
listener
in class AbstractStream<IdT>
protected void receiveMessage(InputStream is)
AbstractStream
receiveMessage
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()
AbstractStream
inboundDeliveryPaused
in class AbstractStream<IdT>
protected final void deframeFailed(Throwable cause)
AbstractStream
AbstractStream.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()
AbstractStream
remoteEndClosed
in class AbstractStream<IdT>
protected final void internalSendFrame(WritableBuffer frame, boolean endOfStream, boolean flush)
AbstractStream
internalSendFrame
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()
ClientStream
halfClose
in interface ClientStream
public void cancel()
cancel
in interface ClientStream
protected abstract void sendCancel()
protected Objects.ToStringHelper toStringHelper()
toStringHelper
in class AbstractStream<IdT>
public boolean isClosed()
AbstractStream
inboundPhase
and outboundPhase
are mutated in different threads. Tests must account
for thread coordination when calling.isClosed
in class AbstractStream<IdT>