Package io.grpc.inprocess
Class InProcessServer
- java.lang.Object
-
- io.grpc.inprocess.InProcessServer
-
- All Implemented Interfaces:
InternalServer
@ThreadSafe final class InProcessServer extends java.lang.Object implements InternalServer
-
-
Field Summary
Fields Modifier and Type Field Description private java.net.SocketAddress
listenAddress
private ServerListener
listener
private int
maxInboundMetadataSize
private static java.util.concurrent.ConcurrentMap<java.lang.String,InProcessServer>
registry
private java.util.concurrent.ScheduledExecutorService
scheduler
Only used to make sure the scheduler has at least one reference.private ObjectPool<java.util.concurrent.ScheduledExecutorService>
schedulerPool
Defaults to be a SharedResourcePool.private boolean
shutdown
private java.util.List<ServerStreamTracer.Factory>
streamTracerFactories
-
Constructor Summary
Constructors Constructor Description InProcessServer(InProcessServerBuilder builder, java.util.List<? extends ServerStreamTracer.Factory> streamTracerFactories)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static InProcessServer
findServer(java.net.SocketAddress addr)
java.net.SocketAddress
getListenSocketAddress()
Returns the first listening socket address.java.util.List<? extends 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.(package private) int
getMaxInboundMetadataSize()
(package private) ObjectPool<java.util.concurrent.ScheduledExecutorService>
getScheduledExecutorServicePool()
(package private) java.util.List<ServerStreamTracer.Factory>
getStreamTracerFactories()
(package private) ServerTransportListener
register(InProcessTransport transport)
private void
registerInstance()
void
shutdown()
Initiates an orderly shutdown of the server.void
start(ServerListener serverListener)
Starts transport.java.lang.String
toString()
private void
unregisterInstance()
-
-
-
Field Detail
-
registry
private static final java.util.concurrent.ConcurrentMap<java.lang.String,InProcessServer> registry
-
listenAddress
private final java.net.SocketAddress listenAddress
-
maxInboundMetadataSize
private final int maxInboundMetadataSize
-
streamTracerFactories
private final java.util.List<ServerStreamTracer.Factory> streamTracerFactories
-
listener
private ServerListener listener
-
shutdown
private boolean shutdown
-
schedulerPool
private final ObjectPool<java.util.concurrent.ScheduledExecutorService> schedulerPool
Defaults to be a SharedResourcePool.
-
scheduler
private java.util.concurrent.ScheduledExecutorService scheduler
Only used to make sure the scheduler has at least one reference. Since child transports can outlive this server, they must get their own reference.
-
-
Constructor Detail
-
InProcessServer
InProcessServer(InProcessServerBuilder builder, java.util.List<? extends ServerStreamTracer.Factory> streamTracerFactories)
-
-
Method Detail
-
findServer
static InProcessServer findServer(java.net.SocketAddress addr)
-
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
-
registerInstance
private void registerInstance() throws java.io.IOException
- Throws:
java.io.IOException
-
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<? extends 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
-
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
-
unregisterInstance
private void unregisterInstance()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
register
ServerTransportListener register(InProcessTransport transport)
-
getScheduledExecutorServicePool
ObjectPool<java.util.concurrent.ScheduledExecutorService> getScheduledExecutorServicePool()
-
getMaxInboundMetadataSize
int getMaxInboundMetadataSize()
-
getStreamTracerFactories
java.util.List<ServerStreamTracer.Factory> getStreamTracerFactories()
-
-