Package io.grpc.internal
Class AbstractStream.TransportState
java.lang.Object
io.grpc.internal.AbstractStream.TransportState
- All Implemented Interfaces:
io.grpc.internal.ApplicationThreadDeframerListener.TransportExecutor
,MessageDeframer.Listener
- Direct Known Subclasses:
AbstractClientStream.TransportState
,AbstractServerStream.TransportState
- Enclosing class:
AbstractStream
public abstract static class AbstractStream.TransportState
extends Object
implements MessageDeframer.Listener
Stream state as used by the transport. This should only be called from the transport thread
(except for private interactions with
AbstractStream
).-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
The default number of queued bytes for a given stream, below whichStreamListener.onReady()
will be called. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
TransportState
(int maxMessageSize, StatsTraceContext statsTraceCtx, TransportTracer transportTracer) -
Method Summary
Modifier and TypeMethodDescriptionprotected final void
closeDeframer
(boolean stopDelivery) Closes the deframer and frees any resources.protected final void
deframe
(ReadableBuffer frame) Called to parse a received frame and attempt delivery of any completed messages.final StatsTraceContext
protected TransportTracer
protected boolean
protected abstract StreamListener
listener()
Override this method to provide a stream listener.void
Called to deliver the next complete message.final void
onSentBytes
(int numBytes) Event handler to be called by the subclass when a number of bytes has been sent to the remote endpoint.protected void
Event handler to be called by the subclass when the stream's headers have passed any connection flow control (i.e., MAX_CONCURRENT_STREAMS).protected final void
Notify that the stream does not exist in a usable state any longer.final void
requestMessagesFromDeframerForTesting
(int numMessages) Very rarely used.protected final void
setDecompressor
(Decompressor decompressor) protected void
setFullStreamDecompressor
(io.grpc.internal.GzipInflatingBuffer fullStreamDecompressor) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.grpc.internal.ApplicationThreadDeframerListener.TransportExecutor
runOnTransportThread
Methods inherited from interface io.grpc.internal.MessageDeframer.Listener
bytesRead, deframeFailed, deframerClosed
-
Field Details
-
DEFAULT_ONREADY_THRESHOLD
public static final int DEFAULT_ONREADY_THRESHOLDThe default number of queued bytes for a given stream, below whichStreamListener.onReady()
will be called.- See Also:
-
-
Constructor Details
-
TransportState
protected TransportState(int maxMessageSize, StatsTraceContext statsTraceCtx, TransportTracer transportTracer)
-
-
Method Details
-
setFullStreamDecompressor
protected void setFullStreamDecompressor(io.grpc.internal.GzipInflatingBuffer fullStreamDecompressor) -
listener
Override this method to provide a stream listener. -
messagesAvailable
Description copied from interface:MessageDeframer.Listener
Called to deliver the next complete message.- Specified by:
messagesAvailable
in interfaceMessageDeframer.Listener
- Parameters:
producer
- single message producer wrapping the message.
-
closeDeframer
protected final void closeDeframer(boolean stopDelivery) Closes the deframer and frees any resources. After this method is called, additional calls will have no effect.When
stopDelivery
is false, the deframer will wait to close until any already queued messages have been delivered.The deframer will invoke
MessageDeframer.Listener.deframerClosed(boolean)
upon closing.- Parameters:
stopDelivery
- interrupt pending deliveries and close immediately
-
deframe
Called to parse a received frame and attempt delivery of any completed messages. Must be called from the transport thread. -
requestMessagesFromDeframerForTesting
public final void requestMessagesFromDeframerForTesting(int numMessages) Very rarely used. Prefer stream.request() instead of this; this method is only necessary if a stream is not available. -
getStatsTraceContext
-
setDecompressor
-
onStreamAllocated
protected void onStreamAllocated()Event 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. -
onStreamDeallocated
protected final void onStreamDeallocated()Notify that the stream does not exist in a usable state any longer. This causesAbstractStream.isReady()
to returnfalse
from this point forward.This does not generally need to be called explicitly by the transport, as it is handled implicitly by
AbstractClientStream
andAbstractServerStream
. -
isStreamDeallocated
protected boolean isStreamDeallocated() -
onSentBytes
public final void onSentBytes(int numBytes) Event handler to be called by the subclass when a number of bytes has been sent to the remote endpoint. May call back the listener'sStreamListener.onReady()
handler if appropriate. This must be called from the transport thread, since the listener may be called back directly.- Parameters:
numBytes
- the number of bytes that were sent.
-
getTransportTracer
-