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 Serverthis objectIllegalStateException - if already startedIOException - if unable to bindpublic int getPort()
ServergetPort in class ServerServer.getListenSockets()public List<SocketAddress> getListenSockets()
ServergetListenSockets in class Serverpublic List<ServerServiceDefinition> getServices()
ServergetServices in class Serverpublic List<ServerServiceDefinition> getImmutableServices()
ServergetImmutableServices in class Serverpublic List<ServerServiceDefinition> getMutableServices()
ServergetMutableServices in class Serverpublic ServerImpl shutdown()
public ServerImpl shutdownNow()
ServerServer.isTerminated() will likely
return false immediately after this method returns.shutdownNow in class Serverthis objectpublic boolean isShutdown()
ServerisShutdown in class ServerServer.shutdown(),
Server.isTerminated()public boolean awaitTermination(long timeout,
TimeUnit unit)
throws InterruptedException
ServerawaitTermination in class ServerServer.isTerminated().InterruptedExceptionpublic void awaitTermination()
throws InterruptedException
ServerawaitTermination in class ServerInterruptedExceptionpublic boolean isTerminated()
ServerisTerminated in class ServerServer.isShutdown()public io.grpc.InternalLogId getLogId()
getLogId in interface io.grpc.InternalWithLogIdpublic ListenableFuture<io.grpc.InternalChannelz.ServerStats> getStats()
getStats in interface io.grpc.InternalInstrumented<io.grpc.InternalChannelz.ServerStats>