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 class
NettyServer.ListenSocket
A class that can answer channelz queries about the server listen sockets.(package private) class
NettyServer.SharedResourceReferenceCounter
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<? extends java.net.SocketAddress>
addresses
private boolean
autoFlowControl
private io.netty.channel.EventLoop
bossExecutor
private io.netty.channel.EventLoopGroup
bossGroup
private ObjectPool<? extends io.netty.channel.EventLoopGroup>
bossGroupPool
private io.netty.channel.ChannelFactory<? extends io.netty.channel.ServerChannel>
channelFactory
private io.netty.channel.group.ChannelGroup
channelGroup
private java.util.Map<io.netty.channel.ChannelOption<?>,?>
channelOptions
private InternalChannelz
channelz
private java.util.Map<io.netty.channel.ChannelOption<?>,?>
childChannelOptions
private Attributes
eagAttributes
private int
flowControlWindow
private boolean
forceHeapBuffer
private long
keepAliveTimeInNanos
private long
keepAliveTimeoutInNanos
private ServerListener
listener
private java.util.List<InternalInstrumented<InternalChannelz.SocketStats>>
listenSocketStatsList
private static java.util.logging.Logger
log
private InternalLogId
logId
private long
maxConnectionAgeGraceInNanos
private long
maxConnectionAgeInNanos
private long
maxConnectionIdleInNanos
private int
maxHeaderListSize
private int
maxMessageSize
private int
maxRstCount
private long
maxRstPeriodNanos
private int
maxStreamsPerConnection
private long
permitKeepAliveTimeInNanos
private boolean
permitKeepAliveWithoutCalls
private ProtocolNegotiator
protocolNegotiator
private io.netty.util.ReferenceCounted
sharedResourceReferenceCounter
private java.util.List<? extends ServerStreamTracer.Factory>
streamTracerFactories
private boolean
terminated
private TransportTracer.Factory
transportTracerFactory
private io.netty.channel.EventLoopGroup
workerGroup
private 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.SocketAddress
getListenSocketAddress()
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.InternalLogId
getLogId()
Returns an ID that is primarily used in debug logs.void
shutdown()
Initiates an orderly shutdown of the server.void
start(ServerListener serverListener)
Starts transport.java.lang.String
toString()
-
-
-
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:InternalServer
Returns the first listening socket address. May change afterInternalServer.start(ServerListener)
is called.- Specified by:
getListenSocketAddress
in interfaceInternalServer
-
getListenSocketAddresses
public java.util.List<java.net.SocketAddress> getListenSocketAddresses()
Description copied from interface:InternalServer
Returns a list of listening socket addresses. May change afterInternalServer.start(ServerListener)
is called.- Specified by:
getListenSocketAddresses
in interfaceInternalServer
-
getListenSocketStats
public InternalInstrumented<InternalChannelz.SocketStats> getListenSocketStats()
Description copied from interface:InternalServer
Returns the first listen socket stats of this server. May returnnull
.- Specified by:
getListenSocketStats
in interfaceInternalServer
-
getListenSocketStatsList
public java.util.List<InternalInstrumented<InternalChannelz.SocketStats>> getListenSocketStatsList()
Description copied from interface:InternalServer
Returns a list of listen socket stats of this server. May returnnull
.- Specified by:
getListenSocketStatsList
in interfaceInternalServer
-
start
public void start(ServerListener serverListener) throws java.io.IOException
Description copied from interface:InternalServer
Starts transport. Implementations must not calllistener
until 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:
start
in interfaceInternalServer
- Parameters:
serverListener
- non-null
listener of server events- Throws:
java.io.IOException
- if unable to bind
-
shutdown
public void shutdown()
Description copied from interface:InternalServer
Initiates 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:
shutdown
in interfaceInternalServer
-
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
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-