public final class ServerImpl
extends io.grpc.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() |
boolean |
awaitTermination(long timeout,
TimeUnit unit) |
List<io.grpc.ServerServiceDefinition> |
getImmutableServices() |
List<SocketAddress> |
getListenSockets() |
io.grpc.InternalLogId |
getLogId() |
List<io.grpc.ServerServiceDefinition> |
getMutableServices() |
int |
getPort() |
List<io.grpc.ServerServiceDefinition> |
getServices() |
com.google.common.util.concurrent.ListenableFuture<io.grpc.InternalChannelz.ServerStats> |
getStats() |
boolean |
isShutdown() |
boolean |
isTerminated() |
ServerImpl |
shutdown()
Initiates an orderly shutdown in which preexisting calls continue but new calls are rejected.
|
ServerImpl |
shutdownNow() |
ServerImpl |
start()
Bind and start the server.
|
String |
toString() |
public ServerImpl start() throws IOException
start in class io.grpc.Serverthis objectIllegalStateException - if already startedIOException - if unable to bindpublic int getPort()
getPort in class io.grpc.Serverpublic List<SocketAddress> getListenSockets()
getListenSockets in class io.grpc.Serverpublic List<io.grpc.ServerServiceDefinition> getServices()
getServices in class io.grpc.Serverpublic List<io.grpc.ServerServiceDefinition> getImmutableServices()
getImmutableServices in class io.grpc.Serverpublic List<io.grpc.ServerServiceDefinition> getMutableServices()
getMutableServices in class io.grpc.Serverpublic ServerImpl shutdown()
shutdown in class io.grpc.Serverpublic ServerImpl shutdownNow()
shutdownNow in class io.grpc.Serverpublic boolean isShutdown()
isShutdown in class io.grpc.Serverpublic boolean awaitTermination(long timeout,
TimeUnit unit)
throws InterruptedException
awaitTermination in class io.grpc.ServerInterruptedExceptionpublic void awaitTermination()
throws InterruptedException
awaitTermination in class io.grpc.ServerInterruptedExceptionpublic boolean isTerminated()
isTerminated in class io.grpc.Serverpublic io.grpc.InternalLogId getLogId()
getLogId in interface io.grpc.InternalWithLogIdpublic com.google.common.util.concurrent.ListenableFuture<io.grpc.InternalChannelz.ServerStats> getStats()
getStats in interface io.grpc.InternalInstrumented<io.grpc.InternalChannelz.ServerStats>