Package io.grpc.internal
Class AbstractClientStream.TransportState
java.lang.Object
io.grpc.internal.AbstractStream.TransportState
io.grpc.internal.AbstractClientStream.TransportState
- All Implemented Interfaces:
ApplicationThreadDeframer.TransportExecutor,ApplicationThreadDeframerListener.TransportExecutor,MessageDeframer.Listener
- Direct Known Subclasses:
Http2ClientStreamTransportState
- Enclosing class:
AbstractClientStream
protected abstract static class AbstractClientStream.TransportState
extends AbstractStream.TransportState
This should only be called from the transport thread.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate DecompressorRegistryprivate booleanprivate Runnableprivate booleanprivate ClientStreamListenerprivate booleanprivate booleanWhether the client has half-closed the stream.private final StatsTraceContextWhether listener.closed() has been called.private booleanWhether the stream is closed from the transport's perspective.private booleanTrue if the status reported (set viatransportReportStatus(io.grpc.Status, boolean, io.grpc.Metadata)) is OK.Fields inherited from class io.grpc.internal.AbstractStream.TransportState
DEFAULT_ONREADY_THRESHOLD -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedTransportState(int maxMessageSize, StatsTraceContext statsTraceCtx, TransportTracer transportTracer, CallOptions options) -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcloseListener(Status status, ClientStreamListener.RpcProgress rpcProgress, Metadata trailers) Closes the listener if not previously closed.voiddeframerClosed(boolean hasPartialMessage) Called when the deframer closes.protected voidProcesses the contents of a received data frame from the server.protected voidinboundHeadersReceived(Metadata headers) Called by transport implementations when they receive headers.protected voidinboundTrailersReceived(Metadata trailers, Status status) Processes the trailers and status from the server.protected final booleanprotected final ClientStreamListenerlistener()Override this method to provide a stream listener.private voidsetDecompressorRegistry(DecompressorRegistry decompressorRegistry) private voidsetFullStreamDecompression(boolean fullStreamDecompression) final voidsetListener(ClientStreamListener listener) private final voidfinal voidtransportReportStatus(Status status, boolean stopDelivery, Metadata trailers) Report stream closure with status to the application layer if not already reported.final voidtransportReportStatus(Status status, ClientStreamListener.RpcProgress rpcProgress, boolean stopDelivery, Metadata trailers) Report stream closure with status to the application layer if not already reported.Methods inherited from class io.grpc.internal.AbstractStream.TransportState
closeDeframer, deframe, getStatsTraceContext, getTransportTracer, isStreamDeallocated, messagesAvailable, onSentBytes, onStreamAllocated, onStreamDeallocated, optimizeForDirectExecutor, requestMessagesFromDeframerForTesting, setDecompressor, setFullStreamDecompressor, setMaxInboundMessageSize, setOnReadyThresholdMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.grpc.internal.ApplicationThreadDeframerListener.TransportExecutor
runOnTransportThreadMethods inherited from interface io.grpc.internal.MessageDeframer.Listener
bytesRead, deframeFailed
-
Field Details
-
statsTraceCtx
Whether listener.closed() has been called. -
listenerClosed
private boolean listenerClosed -
listener
-
fullStreamDecompression
private boolean fullStreamDecompression -
decompressorRegistry
-
deframerClosed
private boolean deframerClosed -
deframerClosedTask
-
outboundClosed
private volatile boolean outboundClosedWhether the client has half-closed the stream. -
statusReported
private boolean statusReportedWhether the stream is closed from the transport's perspective. This can differ fromlistenerClosedbecause there may still be messages buffered to deliver to the application. -
statusReportedIsOk
private boolean statusReportedIsOkTrue if the status reported (set viatransportReportStatus(io.grpc.Status, boolean, io.grpc.Metadata)) is OK.
-
-
Constructor Details
-
TransportState
protected TransportState(int maxMessageSize, StatsTraceContext statsTraceCtx, TransportTracer transportTracer, CallOptions options)
-
-
Method Details
-
setFullStreamDecompression
private void setFullStreamDecompression(boolean fullStreamDecompression) -
setDecompressorRegistry
-
setListener
-
deframerClosed
public void deframerClosed(boolean hasPartialMessage) Description copied from interface:MessageDeframer.ListenerCalled when the deframer closes.- Parameters:
hasPartialMessage- whether the deframer contained an incomplete message at closing.
-
listener
Description copied from class:AbstractStream.TransportStateOverride this method to provide a stream listener.- Specified by:
listenerin classAbstractStream.TransportState
-
setOutboundClosed
private final void setOutboundClosed() -
isOutboundClosed
protected final boolean isOutboundClosed() -
inboundHeadersReceived
Called by transport implementations when they receive headers.- Parameters:
headers- the parsed headers
-
inboundDataReceived
Processes the contents of a received data frame from the server.- Parameters:
frame- the received data frame. Its ownership is transferred to this method.
-
inboundTrailersReceived
Processes the trailers and status from the server.- Parameters:
trailers- the received trailersstatus- the status extracted from the trailers
-
transportReportStatus
Report stream closure with status to the application layer if not already reported. This method must be called from the transport thread.- Parameters:
status- the new status to setstopDelivery- iftrue, interrupts any further delivery of inbound messages that may already be queued up in the deframer. Iffalse, the listener will be notified immediately after all currently completed messages in the deframer have been delivered to the application.trailers- new instance ofTrailers, either empty or those returned by the server
-
transportReportStatus
public final void transportReportStatus(Status status, ClientStreamListener.RpcProgress rpcProgress, boolean stopDelivery, Metadata trailers) Report stream closure with status to the application layer if not already reported. This method must be called from the transport thread.- Parameters:
status- the new status to setrpcProgress- RPC progress that theClientStreamListener.closed(Status, RpcProgress, Metadata)will receivestopDelivery- iftrue, interrupts any further delivery of inbound messages that may already be queued up in the deframer and overrides any previously queued status. Iffalse, the listener will be notified immediately after all currently completed messages in the deframer have been delivered to the application.trailers- new instance ofTrailers, either empty or those returned by the server
-
closeListener
private void closeListener(Status status, ClientStreamListener.RpcProgress rpcProgress, Metadata trailers) Closes the listener if not previously closed.- Throws:
IllegalStateException- if the call has not yet been started.
-