Package io.grpc.internal
Class AbstractServerStream.TransportState
java.lang.Object
io.grpc.internal.AbstractStream.TransportState
io.grpc.internal.AbstractServerStream.TransportState
- All Implemented Interfaces:
ApplicationThreadDeframer.TransportExecutor,ApplicationThreadDeframerListener.TransportExecutor,MessageDeframer.Listener
- Direct Known Subclasses:
NettyServerStream.TransportState,ServletServerStream.ServletTransportState,ServletServerStream.ServletTransportState
- Enclosing class:
AbstractServerStream
protected abstract static class AbstractServerStream.TransportState
extends AbstractStream.TransportState
This should only be called from the transport thread (except for private interactions with
AbstractServerStream).-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate StatusThe status that the application used to close this stream.private booleanprivate Runnableprivate booleanprivate booleanprivate ServerStreamListenerprivate booleanWhether listener.closed() has been called.private final StatsTraceContextFields inherited from class io.grpc.internal.AbstractStream.TransportState
DEFAULT_ONREADY_THRESHOLD -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedTransportState(int maxMessageSize, StatsTraceContext statsTraceCtx, TransportTracer transportTracer) -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcloseListener(Status newStatus) Closes the listener if not previously closed and frees resources.voidcomplete()Indicates the stream is considered completely closed and there is no further opportunity for error.voiddeframerClosed(boolean hasPartialMessage) Called when the deframer closes.voidinboundDataReceived(ReadableBuffer frame, boolean endOfStream) Called in the transport thread to process the content of an inbound DATA frame from the client.protected ServerStreamListenerlistener()Override this method to provide a stream listener.final voidEvent handler to be called by the subclass when the stream's headers have passed any connection flow control (i.e., MAX_CONCURRENT_STREAMS).private voidsetClosedStatus(Status closeStatus) Stores theStatusthat the application used to close this stream.final voidsetListener(ServerStreamListener listener) Sets the listener to receive notifications.final voidtransportReportStatus(Status status) Notifies failure to the listener of the stream.Methods inherited from class io.grpc.internal.AbstractStream.TransportState
closeDeframer, deframe, getStatsTraceContext, getTransportTracer, isStreamDeallocated, messagesAvailable, onSentBytes, 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
-
listenerClosed
private boolean listenerClosedWhether listener.closed() has been called. -
listener
-
statsTraceCtx
-
endOfStream
private boolean endOfStream -
deframerClosed
private boolean deframerClosed -
immediateCloseRequested
private boolean immediateCloseRequested -
deframerClosedTask
-
closedStatus
The status that the application used to close this stream.
-
-
Constructor Details
-
TransportState
protected TransportState(int maxMessageSize, StatsTraceContext statsTraceCtx, TransportTracer transportTracer)
-
-
Method Details
-
setListener
Sets the listener to receive notifications. Must be called in the context of the transport thread. -
onStreamAllocated
public final void onStreamAllocated()Description copied from class:AbstractStream.TransportStateEvent handler to be called by the subclass when the stream's headers have passed any connection flow control (i.e., MAX_CONCURRENT_STREAMS). It may call the listener'sStreamListener.onReady()handler if appropriate. This must be called from the transport thread, since the listener may be called back directly.- Overrides:
onStreamAllocatedin classAbstractStream.TransportState
-
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
-
inboundDataReceived
Called in the transport thread to process the content of an inbound DATA frame from the client.- Parameters:
frame- the inbound HTTP/2 DATA frame. If this buffer is not used immediately, it must be retained.endOfStream-trueif no more data will be received on the stream.
-
transportReportStatus
Notifies failure to the listener of the stream. The transport is responsible for notifying the client of the failure independent of this method.Unlike
AbstractServerStream.close(Status, Metadata), this method is only called from the transport. The transport should use this method instead ofclose(Status)for internal errors to prevent exposing unexpected states and exceptions to the application.- Parameters:
status- the error status. Must not beStatus.OK.
-
complete
public void complete()Indicates the stream is considered completely closed and there is no further opportunity for error. It calls the listener'sclosed()if it was not already done bytransportReportStatus(io.grpc.Status). -
closeListener
Closes the listener if not previously closed and frees resources.newStatusis a status generated by gRPC. It is not the status the stream closed with. -
setClosedStatus
Stores theStatusthat the application used to close this stream.
-