Package io.grpc.netty
Class NettyServerTransport
- java.lang.Object
-
- io.grpc.netty.NettyServerTransport
-
- All Implemented Interfaces:
ServerTransport
,InternalInstrumented<InternalChannelz.SocketStats>
,InternalWithLogId
class NettyServerTransport extends java.lang.Object implements ServerTransport
The Netty-based server transport.
-
-
Field Summary
-
Constructor Summary
Constructors Constructor Description NettyServerTransport(io.netty.channel.Channel channel, io.netty.channel.ChannelPromise channelUnused, ProtocolNegotiator protocolNegotiator, java.util.List<? extends ServerStreamTracer.Factory> streamTracerFactories, TransportTracer transportTracer, int maxStreams, boolean autoFlowControl, int flowControlWindow, int maxMessageSize, int maxHeaderListSize, long keepAliveTimeInNanos, long keepAliveTimeoutInNanos, long maxConnectionIdleInNanos, long maxConnectionAgeInNanos, long maxConnectionAgeGraceInNanos, boolean permitKeepAliveWithoutCalls, long permitKeepAliveTimeInNanos, int maxRstCount, long maxRstPeriodNanos, Attributes eagAttributes)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) io.netty.channel.Channel
channel()
For testing purposes only.private NettyServerHandler
createHandler(ServerTransportListener transportListener, io.netty.channel.ChannelPromise channelUnused)
Creates the Netty handler to be used in the channel pipeline.InternalLogId
getLogId()
Returns an ID that is primarily used in debug logs.(package private) static java.util.logging.Level
getLogLevel(java.lang.Throwable t)
Accepts a throwable and returns the appropriate logging level.java.util.concurrent.ScheduledExecutorService
getScheduledExecutorService()
Returns an executor for scheduling provided by the transport.com.google.common.util.concurrent.ListenableFuture<InternalChannelz.SocketStats>
getStats()
Returns the stats object.private InternalChannelz.SocketStats
getStatsHelper(io.netty.channel.Channel ch)
private void
notifyTerminated(java.lang.Throwable t)
void
shutdown()
Initiates an orderly shutdown of the transport.void
shutdownNow(Status reason)
Initiates a forceful shutdown in which preexisting and new calls are closed.void
start(ServerTransportListener listener)
java.lang.String
toString()
-
-
-
Field Detail
-
connectionLog
private static final java.util.logging.Logger connectionLog
-
QUIET_EXCEPTIONS
private static final com.google.common.collect.ImmutableList<java.lang.String> QUIET_EXCEPTIONS
-
logId
private final InternalLogId logId
-
channel
private final io.netty.channel.Channel channel
-
channelUnused
private final io.netty.channel.ChannelPromise channelUnused
-
protocolNegotiator
private final ProtocolNegotiator protocolNegotiator
-
maxStreams
private final int maxStreams
-
grpcHandler
private NettyServerHandler grpcHandler
-
listener
private ServerTransportListener listener
-
terminated
private boolean terminated
-
autoFlowControl
private final boolean autoFlowControl
-
flowControlWindow
private final int flowControlWindow
-
maxMessageSize
private final int maxMessageSize
-
maxHeaderListSize
private final int maxHeaderListSize
-
keepAliveTimeInNanos
private final long keepAliveTimeInNanos
-
keepAliveTimeoutInNanos
private final long keepAliveTimeoutInNanos
-
maxConnectionIdleInNanos
private final long maxConnectionIdleInNanos
-
maxConnectionAgeInNanos
private final long maxConnectionAgeInNanos
-
maxConnectionAgeGraceInNanos
private final long maxConnectionAgeGraceInNanos
-
permitKeepAliveWithoutCalls
private final boolean permitKeepAliveWithoutCalls
-
permitKeepAliveTimeInNanos
private final long permitKeepAliveTimeInNanos
-
maxRstCount
private final int maxRstCount
-
maxRstPeriodNanos
private final long maxRstPeriodNanos
-
eagAttributes
private final Attributes eagAttributes
-
streamTracerFactories
private final java.util.List<? extends ServerStreamTracer.Factory> streamTracerFactories
-
transportTracer
private final TransportTracer transportTracer
-
-
Constructor Detail
-
NettyServerTransport
NettyServerTransport(io.netty.channel.Channel channel, io.netty.channel.ChannelPromise channelUnused, ProtocolNegotiator protocolNegotiator, java.util.List<? extends ServerStreamTracer.Factory> streamTracerFactories, TransportTracer transportTracer, int maxStreams, boolean autoFlowControl, int flowControlWindow, int maxMessageSize, int maxHeaderListSize, long keepAliveTimeInNanos, long keepAliveTimeoutInNanos, long maxConnectionIdleInNanos, long maxConnectionAgeInNanos, long maxConnectionAgeGraceInNanos, boolean permitKeepAliveWithoutCalls, long permitKeepAliveTimeInNanos, int maxRstCount, long maxRstPeriodNanos, Attributes eagAttributes)
-
-
Method Detail
-
start
public void start(ServerTransportListener listener)
-
getScheduledExecutorService
public java.util.concurrent.ScheduledExecutorService getScheduledExecutorService()
Description copied from interface:ServerTransport
Returns an executor for scheduling provided by the transport. The service should be configured to allow cancelled scheduled runnables to be GCed.The executor may not be used after the transport terminates. The caller should ensure any outstanding tasks are cancelled when the transport terminates.
- Specified by:
getScheduledExecutorService
in interfaceServerTransport
-
shutdown
public void shutdown()
Description copied from interface:ServerTransport
Initiates an orderly shutdown of the transport. Existing streams continue, but new streams will eventually begin failing. New streams "eventually" begin failing because shutdown may need to be processed on a separate thread. May only be called once.- Specified by:
shutdown
in interfaceServerTransport
-
shutdownNow
public void shutdownNow(Status reason)
Description copied from interface:ServerTransport
Initiates a forceful shutdown in which preexisting and new calls are closed. Existing calls should be closed with the providedreason
.- Specified by:
shutdownNow
in interfaceServerTransport
-
getLogId
public InternalLogId getLogId()
Description copied from interface:InternalWithLogId
Returns an ID that is primarily used in debug logs. It usually contains the class name and a numeric ID that is unique among the instances.The subclasses of this interface usually want to include the log ID in their
Object.toString()
results.- Specified by:
getLogId
in interfaceInternalWithLogId
-
channel
io.netty.channel.Channel channel()
For testing purposes only.
-
getLogLevel
static java.util.logging.Level getLogLevel(java.lang.Throwable t)
Accepts a throwable and returns the appropriate logging level. Uninteresting exceptions should not clutter the log.
-
notifyTerminated
private void notifyTerminated(java.lang.Throwable t)
-
getStats
public com.google.common.util.concurrent.ListenableFuture<InternalChannelz.SocketStats> getStats()
Description copied from interface:InternalInstrumented
Returns the stats object.- Specified by:
getStats
in interfaceInternalInstrumented<InternalChannelz.SocketStats>
-
getStatsHelper
private InternalChannelz.SocketStats getStatsHelper(io.netty.channel.Channel ch)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
createHandler
private NettyServerHandler createHandler(ServerTransportListener transportListener, io.netty.channel.ChannelPromise channelUnused)
Creates the Netty handler to be used in the channel pipeline.
-
-