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.EventLoop
eventLoop
private NettyClientHandler
handler
private io.netty.handler.codec.http2.Http2Stream
http2Stream
private int
id
private java.lang.String
methodName
private static int
NON_EXISTENT_ID
private io.perfmark.Tag
tag
-
Fields inherited from class io.grpc.internal.AbstractStream.TransportState
DEFAULT_ONREADY_THRESHOLD
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
TransportState(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 void
bytesRead(int processedBytes)
Called when the given number of bytes has been read from the input source of the deframer.void
deframeFailed(java.lang.Throwable cause)
Called when aMessageDeframer.deframe(ReadableBuffer)
operation failed.protected void
http2ProcessingFailed(Status status, boolean stopDelivery, Metadata trailers)
Called to process a failure in HTTP/2 processing.io.netty.handler.codec.http2.Http2Stream
http2Stream()
Gets the underlying NettyHttp2Stream
for this stream.int
id()
Returns the id.(package private) boolean
isNonExistent()
private void
onWriteFrameData(io.netty.channel.ChannelFuture future, int numMessages, int numBytes)
void
runOnTransportThread(java.lang.Runnable r)
void
setHttp2Stream(io.netty.handler.codec.http2.Http2Stream http2Stream)
Sets the underlying NettyHttp2Stream
for this stream.void
setId(int id)
(package private) void
setNonExistent()
Marks the stream state as if it had never existed.protected abstract Status
statusFromFailedFuture(io.netty.channel.ChannelFuture f)
Intended to be overridden by NettyClientTransport, which has more information about failures.io.perfmark.Tag
tag()
(package private) void
transportDataReceived(io.netty.buffer.ByteBuf frame, boolean endOfStream)
(package private) void
transportHeadersReceived(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:StreamIdHolder
Returns the id.- Specified by:
id
in 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 NettyHttp2Stream
for 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 NettyHttp2Stream
for 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:Http2ClientStreamTransportState
Called to process a failure in HTTP/2 processing. It should notify the transport to cancel the stream and calltransportReportStatus()
.- Specified by:
http2ProcessingFailed
in classHttp2ClientStreamTransportState
-
onWriteFrameData
private void onWriteFrameData(io.netty.channel.ChannelFuture future, int numMessages, int numBytes)
-
runOnTransportThread
public void runOnTransportThread(java.lang.Runnable r)
- Specified by:
runOnTransportThread
in interfaceApplicationThreadDeframerListener.TransportExecutor
-
bytesRead
public void bytesRead(int processedBytes)
Description copied from interface:MessageDeframer.Listener
Called 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:
bytesRead
in 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.Listener
Called when aMessageDeframer.deframe(ReadableBuffer)
operation failed.- Specified by:
deframeFailed
in 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:
tag
in interfaceStreamIdHolder
-
-