public final class ServerImpl extends Server implements InternalInstrumented<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.
|
InternalLogId |
getLogId()
Returns an ID that is primarily used in debug logs.
|
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.
|
com.google.common.util.concurrent.ListenableFuture<InternalChannelz.ServerStats> |
getStats()
Returns the stats object.
|
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
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 InternalLogId getLogId()
InternalWithLogId
The subclasses of this interface usually want to include the log ID in their #toString
results.
getLogId
in interface InternalWithLogId
public com.google.common.util.concurrent.ListenableFuture<InternalChannelz.ServerStats> getStats()
InternalInstrumented
getStats
in interface InternalInstrumented<InternalChannelz.ServerStats>
Copyright © 2018. All rights reserved.