Package io.grpc.netty
Class NettyServer
- java.lang.Object
-
- io.grpc.netty.NettyServer
-
- All Implemented Interfaces:
InternalServer,InternalWithLogId
class NettyServer extends java.lang.Object implements InternalServer, InternalWithLogId
Netty-based server implementation.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classNettyServer.ListenSocketA class that can answer channelz queries about the server listen sockets.(package private) classNettyServer.SharedResourceReferenceCounter
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<? extends java.net.SocketAddress>addressesprivate booleanautoFlowControlprivate io.netty.channel.EventLoopbossExecutorprivate io.netty.channel.EventLoopGroupbossGroupprivate ObjectPool<? extends io.netty.channel.EventLoopGroup>bossGroupPoolprivate io.netty.channel.ChannelFactory<? extends io.netty.channel.ServerChannel>channelFactoryprivate io.netty.channel.group.ChannelGroupchannelGroupprivate java.util.Map<io.netty.channel.ChannelOption<?>,?>channelOptionsprivate InternalChannelzchannelzprivate java.util.Map<io.netty.channel.ChannelOption<?>,?>childChannelOptionsprivate AttributeseagAttributesprivate intflowControlWindowprivate booleanforceHeapBufferprivate longkeepAliveTimeInNanosprivate longkeepAliveTimeoutInNanosprivate ServerListenerlistenerprivate java.util.List<InternalInstrumented<InternalChannelz.SocketStats>>listenSocketStatsListprivate static java.util.logging.Loggerlogprivate InternalLogIdlogIdprivate longmaxConnectionAgeGraceInNanosprivate longmaxConnectionAgeInNanosprivate longmaxConnectionIdleInNanosprivate intmaxHeaderListSizeprivate intmaxMessageSizeprivate intmaxRstCountprivate longmaxRstPeriodNanosprivate intmaxStreamsPerConnectionprivate longpermitKeepAliveTimeInNanosprivate booleanpermitKeepAliveWithoutCallsprivate ProtocolNegotiatorprotocolNegotiatorprivate io.netty.util.ReferenceCountedsharedResourceReferenceCounterprivate java.util.List<? extends ServerStreamTracer.Factory>streamTracerFactoriesprivate booleanterminatedprivate TransportTracer.FactorytransportTracerFactoryprivate io.netty.channel.EventLoopGroupworkerGroupprivate ObjectPool<? extends io.netty.channel.EventLoopGroup>workerGroupPool
-
Constructor Summary
Constructors Constructor Description NettyServer(java.util.List<? extends java.net.SocketAddress> addresses, io.netty.channel.ChannelFactory<? extends io.netty.channel.ServerChannel> channelFactory, java.util.Map<io.netty.channel.ChannelOption<?>,?> channelOptions, java.util.Map<io.netty.channel.ChannelOption<?>,?> childChannelOptions, ObjectPool<? extends io.netty.channel.EventLoopGroup> bossGroupPool, ObjectPool<? extends io.netty.channel.EventLoopGroup> workerGroupPool, boolean forceHeapBuffer, ProtocolNegotiator protocolNegotiator, java.util.List<? extends ServerStreamTracer.Factory> streamTracerFactories, TransportTracer.Factory transportTracerFactory, int maxStreamsPerConnection, 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, InternalChannelz channelz)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.net.SocketAddressgetListenSocketAddress()Returns the first listening socket address.java.util.List<java.net.SocketAddress>getListenSocketAddresses()Returns a list of listening socket addresses.InternalInstrumented<InternalChannelz.SocketStats>getListenSocketStats()Returns the first listen socket stats of this server.java.util.List<InternalInstrumented<InternalChannelz.SocketStats>>getListenSocketStatsList()Returns a list of listen socket stats of this server.InternalLogIdgetLogId()Returns an ID that is primarily used in debug logs.voidshutdown()Initiates an orderly shutdown of the server.voidstart(ServerListener serverListener)Starts transport.java.lang.StringtoString()
-
-
-
Field Detail
-
log
private static final java.util.logging.Logger log
-
logId
private final InternalLogId logId
-
addresses
private final java.util.List<? extends java.net.SocketAddress> addresses
-
channelFactory
private final io.netty.channel.ChannelFactory<? extends io.netty.channel.ServerChannel> channelFactory
-
channelOptions
private final java.util.Map<io.netty.channel.ChannelOption<?>,?> channelOptions
-
childChannelOptions
private final java.util.Map<io.netty.channel.ChannelOption<?>,?> childChannelOptions
-
protocolNegotiator
private final ProtocolNegotiator protocolNegotiator
-
maxStreamsPerConnection
private final int maxStreamsPerConnection
-
bossGroupPool
private final ObjectPool<? extends io.netty.channel.EventLoopGroup> bossGroupPool
-
workerGroupPool
private final ObjectPool<? extends io.netty.channel.EventLoopGroup> workerGroupPool
-
forceHeapBuffer
private final boolean forceHeapBuffer
-
bossGroup
private io.netty.channel.EventLoopGroup bossGroup
-
workerGroup
private io.netty.channel.EventLoopGroup workerGroup
-
listener
private ServerListener listener
-
channelGroup
private final io.netty.channel.group.ChannelGroup channelGroup
-
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
-
sharedResourceReferenceCounter
private final io.netty.util.ReferenceCounted sharedResourceReferenceCounter
-
streamTracerFactories
private final java.util.List<? extends ServerStreamTracer.Factory> streamTracerFactories
-
transportTracerFactory
private final TransportTracer.Factory transportTracerFactory
-
channelz
private final InternalChannelz channelz
-
listenSocketStatsList
private volatile java.util.List<InternalInstrumented<InternalChannelz.SocketStats>> listenSocketStatsList
-
terminated
private volatile boolean terminated
-
bossExecutor
private final io.netty.channel.EventLoop bossExecutor
-
-
Constructor Detail
-
NettyServer
NettyServer(java.util.List<? extends java.net.SocketAddress> addresses, io.netty.channel.ChannelFactory<? extends io.netty.channel.ServerChannel> channelFactory, java.util.Map<io.netty.channel.ChannelOption<?>,?> channelOptions, java.util.Map<io.netty.channel.ChannelOption<?>,?> childChannelOptions, ObjectPool<? extends io.netty.channel.EventLoopGroup> bossGroupPool, ObjectPool<? extends io.netty.channel.EventLoopGroup> workerGroupPool, boolean forceHeapBuffer, ProtocolNegotiator protocolNegotiator, java.util.List<? extends ServerStreamTracer.Factory> streamTracerFactories, TransportTracer.Factory transportTracerFactory, int maxStreamsPerConnection, 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, InternalChannelz channelz)
-
-
Method Detail
-
getListenSocketAddress
public java.net.SocketAddress getListenSocketAddress()
Description copied from interface:InternalServerReturns the first listening socket address. May change afterInternalServer.start(ServerListener)is called.- Specified by:
getListenSocketAddressin interfaceInternalServer
-
getListenSocketAddresses
public java.util.List<java.net.SocketAddress> getListenSocketAddresses()
Description copied from interface:InternalServerReturns a list of listening socket addresses. May change afterInternalServer.start(ServerListener)is called.- Specified by:
getListenSocketAddressesin interfaceInternalServer
-
getListenSocketStats
public InternalInstrumented<InternalChannelz.SocketStats> getListenSocketStats()
Description copied from interface:InternalServerReturns the first listen socket stats of this server. May returnnull.- Specified by:
getListenSocketStatsin interfaceInternalServer
-
getListenSocketStatsList
public java.util.List<InternalInstrumented<InternalChannelz.SocketStats>> getListenSocketStatsList()
Description copied from interface:InternalServerReturns a list of listen socket stats of this server. May returnnull.- Specified by:
getListenSocketStatsListin interfaceInternalServer
-
start
public void start(ServerListener serverListener) throws java.io.IOException
Description copied from interface:InternalServerStarts transport. Implementations must not calllisteneruntil afterstart()returns. The method only returns after it has done the equivalent of bind()ing, so it will be able to service any connections created after returning.- Specified by:
startin interfaceInternalServer- Parameters:
serverListener- non-nulllistener of server events- Throws:
java.io.IOException- if unable to bind
-
shutdown
public void shutdown()
Description copied from interface:InternalServerInitiates an orderly shutdown of the server. Existing transports continue, but new transports will not be created (onceServerListener.serverShutdown()callback is called). This method may only be called once. Blocks until the listening socket(s) have been closed. If interrupted, this method will not wait for the close to complete, but it will happen asynchronously.- Specified by:
shutdownin interfaceInternalServer
-
getLogId
public InternalLogId getLogId()
Description copied from interface:InternalWithLogIdReturns 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:
getLogIdin interfaceInternalWithLogId
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-