public final class ServerImpl extends Server implements io.grpc.InternalInstrumented<io.grpc.InternalChannelz.ServerStats>
Server
, for creation by transports.
Expected usage (by a theoretical TCP transport):
public class TcpTransportServerFactory {
public static Server newServer(Executor executor, HandlerRegistry registry,
String configuration) {
return new ServerImpl(executor, registry, new TcpTransportServer(configuration));
}
}
Starting the server starts the underlying transport for servicing requests. Stopping the server stops servicing new requests and waits for all connections to terminate.
Modifier and Type | Method and Description |
---|---|
void |
awaitTermination()
Waits for the server to become terminated.
|
boolean |
awaitTermination(long timeout,
TimeUnit unit)
Waits for the server to become terminated, giving up if the timeout is reached.
|
List<ServerServiceDefinition> |
getImmutableServices()
Returns immutable services registered with the server, or an empty list if not supported by the
implementation.
|
List<SocketAddress> |
getListenSockets()
Returns a list of listening sockets for this server.
|
io.grpc.InternalLogId |
getLogId() |
List<ServerServiceDefinition> |
getMutableServices()
Returns mutable services registered with the server, or an empty list if not supported by the
implementation.
|
int |
getPort()
Returns the port number the server is listening on.
|
List<ServerServiceDefinition> |
getServices()
Returns all services registered with the server, or an empty list if not supported by the
implementation.
|
ListenableFuture<io.grpc.InternalChannelz.ServerStats> |
getStats() |
boolean |
isShutdown()
Returns whether the server is shutdown.
|
boolean |
isTerminated()
Returns whether the server is terminated.
|
ServerImpl |
shutdown()
Initiates an orderly shutdown in which preexisting calls continue but new calls are rejected.
|
ServerImpl |
shutdownNow()
Initiates a forceful shutdown in which preexisting and new calls are rejected.
|
ServerImpl |
start()
Bind and start the server.
|
String |
toString() |
public ServerImpl start() throws IOException
start
in class Server
this
objectIllegalStateException
- if already startedIOException
- if unable to bindpublic int getPort()
Server
getPort
in class Server
Server.getListenSockets()
public List<SocketAddress> getListenSockets()
Server
getListenSockets
in class Server
public List<ServerServiceDefinition> getServices()
Server
getServices
in class Server
public List<ServerServiceDefinition> getImmutableServices()
Server
getImmutableServices
in class Server
public List<ServerServiceDefinition> getMutableServices()
Server
getMutableServices
in class Server
public ServerImpl shutdown()
public ServerImpl shutdownNow()
Server
Server.isTerminated()
will likely
return false
immediately after this method returns.shutdownNow
in class Server
this
objectpublic boolean isShutdown()
Server
isShutdown
in class Server
Server.shutdown()
,
Server.isTerminated()
public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException
Server
awaitTermination
in class Server
Server.isTerminated()
.InterruptedException
public void awaitTermination() throws InterruptedException
Server
awaitTermination
in class Server
InterruptedException
public boolean isTerminated()
Server
isTerminated
in class Server
Server.isShutdown()
public io.grpc.InternalLogId getLogId()
getLogId
in interface io.grpc.InternalWithLogId
public ListenableFuture<io.grpc.InternalChannelz.ServerStats> getStats()
getStats
in interface io.grpc.InternalInstrumented<io.grpc.InternalChannelz.ServerStats>