Package io.grpc.netty
Class NettyClientStream.TransportState
- java.lang.Object
-
- io.grpc.internal.AbstractStream.TransportState
-
- io.grpc.internal.AbstractClientStream.TransportState
-
- io.grpc.internal.Http2ClientStreamTransportState
-
- io.grpc.netty.NettyClientStream.TransportState
-
- All Implemented Interfaces:
ApplicationThreadDeframer.TransportExecutor,ApplicationThreadDeframerListener.TransportExecutor,MessageDeframer.Listener,StreamIdHolder
- Enclosing class:
- NettyClientStream
public abstract static class NettyClientStream.TransportState extends Http2ClientStreamTransportState implements StreamIdHolder
This should only be called from the transport thread.
-
-
Field Summary
Fields Modifier and Type Field Description private io.netty.channel.EventLoopeventLoopprivate NettyClientHandlerhandlerprivate io.netty.handler.codec.http2.Http2Streamhttp2Streamprivate intidprivate java.lang.StringmethodNameprivate static intNON_EXISTENT_IDprivate io.perfmark.Tagtag-
Fields inherited from class io.grpc.internal.AbstractStream.TransportState
DEFAULT_ONREADY_THRESHOLD
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedTransportState(NettyClientHandler handler, io.netty.channel.EventLoop eventLoop, int maxMessageSize, StatsTraceContext statsTraceCtx, TransportTracer transportTracer, java.lang.String methodName, CallOptions options)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidbytesRead(int processedBytes)Called when the given number of bytes has been read from the input source of the deframer.voiddeframeFailed(java.lang.Throwable cause)Called when aMessageDeframer.deframe(ReadableBuffer)operation failed.protected voidhttp2ProcessingFailed(Status status, boolean stopDelivery, Metadata trailers)Called to process a failure in HTTP/2 processing.io.netty.handler.codec.http2.Http2Streamhttp2Stream()Gets the underlying NettyHttp2Streamfor this stream.intid()Returns the id.(package private) booleanisNonExistent()private voidonWriteFrameData(io.netty.channel.ChannelFuture future, int numMessages, int numBytes)voidrunOnTransportThread(java.lang.Runnable r)voidsetHttp2Stream(io.netty.handler.codec.http2.Http2Stream http2Stream)Sets the underlying NettyHttp2Streamfor this stream.voidsetId(int id)(package private) voidsetNonExistent()Marks the stream state as if it had never existed.protected abstract StatusstatusFromFailedFuture(io.netty.channel.ChannelFuture f)Intended to be overridden by NettyClientTransport, which has more information about failures.io.perfmark.Tagtag()(package private) voidtransportDataReceived(io.netty.buffer.ByteBuf frame, boolean endOfStream)(package private) voidtransportHeadersReceived(io.netty.handler.codec.http2.Http2Headers headers, boolean endOfStream)-
Methods inherited from class io.grpc.internal.Http2ClientStreamTransportState
transportDataReceived, transportHeadersReceived, transportTrailersReceived
-
Methods inherited from class io.grpc.internal.AbstractClientStream.TransportState
deframerClosed, inboundDataReceived, inboundHeadersReceived, inboundTrailersReceived, isOutboundClosed, listener, setListener, transportReportStatus, transportReportStatus
-
Methods inherited from class io.grpc.internal.AbstractStream.TransportState
closeDeframer, deframe, getStatsTraceContext, getTransportTracer, isStreamDeallocated, messagesAvailable, onSentBytes, onStreamAllocated, onStreamDeallocated, requestMessagesFromDeframerForTesting, setDecompressor, setFullStreamDecompressor
-
-
-
-
Field Detail
-
NON_EXISTENT_ID
private static final int NON_EXISTENT_ID
- See Also:
- Constant Field Values
-
methodName
private final java.lang.String methodName
-
handler
private final NettyClientHandler handler
-
eventLoop
private final io.netty.channel.EventLoop eventLoop
-
id
private int id
-
http2Stream
private io.netty.handler.codec.http2.Http2Stream http2Stream
-
tag
private io.perfmark.Tag tag
-
-
Constructor Detail
-
TransportState
protected TransportState(NettyClientHandler handler, io.netty.channel.EventLoop eventLoop, int maxMessageSize, StatsTraceContext statsTraceCtx, TransportTracer transportTracer, java.lang.String methodName, CallOptions options)
-
-
Method Detail
-
id
public int id()
Description copied from interface:StreamIdHolderReturns the id.- Specified by:
idin interfaceStreamIdHolder
-
setId
public void setId(int id)
-
setNonExistent
void setNonExistent()
Marks the stream state as if it had never existed. This can happen if the stream is cancelled after it is created, but before it has been started.
-
isNonExistent
boolean isNonExistent()
-
setHttp2Stream
public void setHttp2Stream(io.netty.handler.codec.http2.Http2Stream http2Stream)
Sets the underlying NettyHttp2Streamfor this stream. This must be called in the context of the transport thread.
-
http2Stream
@Nullable public io.netty.handler.codec.http2.Http2Stream http2Stream()
Gets the underlying NettyHttp2Streamfor this stream.
-
statusFromFailedFuture
protected abstract Status statusFromFailedFuture(io.netty.channel.ChannelFuture f)
Intended to be overridden by NettyClientTransport, which has more information about failures. May only be called from event loop.
-
http2ProcessingFailed
protected void http2ProcessingFailed(Status status, boolean stopDelivery, Metadata trailers)
Description copied from class:Http2ClientStreamTransportStateCalled to process a failure in HTTP/2 processing. It should notify the transport to cancel the stream and calltransportReportStatus().- Specified by:
http2ProcessingFailedin classHttp2ClientStreamTransportState
-
onWriteFrameData
private void onWriteFrameData(io.netty.channel.ChannelFuture future, int numMessages, int numBytes)
-
runOnTransportThread
public void runOnTransportThread(java.lang.Runnable r)
- Specified by:
runOnTransportThreadin interfaceApplicationThreadDeframerListener.TransportExecutor
-
bytesRead
public void bytesRead(int processedBytes)
Description copied from interface:MessageDeframer.ListenerCalled when the given number of bytes has been read from the input source of the deframer. This is typically used to indicate to the underlying transport that more data can be accepted.- Specified by:
bytesReadin interfaceMessageDeframer.Listener- Parameters:
processedBytes- the number of bytes read from the deframer's input source.
-
deframeFailed
public void deframeFailed(java.lang.Throwable cause)
Description copied from interface:MessageDeframer.ListenerCalled when aMessageDeframer.deframe(ReadableBuffer)operation failed.- Specified by:
deframeFailedin interfaceMessageDeframer.Listener- Parameters:
cause- the actual failure
-
transportHeadersReceived
void transportHeadersReceived(io.netty.handler.codec.http2.Http2Headers headers, boolean endOfStream)
-
transportDataReceived
void transportDataReceived(io.netty.buffer.ByteBuf frame, boolean endOfStream)
-
tag
public final io.perfmark.Tag tag()
- Specified by:
tagin interfaceStreamIdHolder
-
-