@ThreadSafe
public abstract class Server
extends java.lang.Object
Constructor and Description |
---|
Server() |
Modifier and Type | Method and Description |
---|---|
abstract void |
awaitTermination()
Waits for the server to become terminated.
|
abstract boolean |
awaitTermination(long timeout,
java.util.concurrent.TimeUnit unit)
Waits for the server to become terminated, giving up if the timeout is reached.
|
java.util.List<ServerServiceDefinition> |
getImmutableServices()
Returns immutable services registered with the server, or an empty list if not supported by the
implementation.
|
java.util.List<? extends java.net.SocketAddress> |
getListenSockets()
Returns a list of listening sockets for this server.
|
java.util.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.
|
java.util.List<ServerServiceDefinition> |
getServices()
Returns all services registered with the server, or an empty list if not supported by the
implementation.
|
abstract boolean |
isShutdown()
Returns whether the server is shutdown.
|
abstract boolean |
isTerminated()
Returns whether the server is terminated.
|
abstract Server |
shutdown()
Initiates an orderly shutdown in which preexisting calls continue but new calls are rejected.
|
abstract Server |
shutdownNow()
Initiates a forceful shutdown in which preexisting and new calls are rejected.
|
abstract Server |
start()
Bind and start the server.
|
public abstract Server start() throws java.io.IOException
this
objectjava.lang.IllegalStateException
- if already started or shut downjava.io.IOException
- if unable to bindpublic int getPort()
java.lang.IllegalStateException
- if the server has not yet been started.getListenSockets()
@ExperimentalApi(value="https://github.com/grpc/grpc-java/issues/5332") public java.util.List<? extends java.net.SocketAddress> getListenSockets()
java.lang.IllegalStateException
- if the server has not yet been started.@ExperimentalApi(value="https://github.com/grpc/grpc-java/issues/2222") public java.util.List<ServerServiceDefinition> getServices()
@ExperimentalApi(value="https://github.com/grpc/grpc-java/issues/2222") public java.util.List<ServerServiceDefinition> getImmutableServices()
@ExperimentalApi(value="https://github.com/grpc/grpc-java/issues/2222") public java.util.List<ServerServiceDefinition> getMutableServices()
public abstract Server shutdown()
Note that this method will not wait for preexisting calls to finish before returning.
awaitTermination()
or awaitTermination(long, TimeUnit)
needs to be called to
wait for existing calls to finish.
Calling this method before start()
will shut down and terminate the server like
normal, but prevents starting the server in the future.
this
objectpublic abstract Server shutdownNow()
isTerminated()
will likely
return false
immediately after this method returns. After this call returns, this
server has released the listening socket(s) and may be reused by another server.
Calling this method before start()
will shut down and terminate the server like
normal, but prevents starting the server in the future.
this
objectpublic abstract boolean isShutdown()
shutdown()
,
isTerminated()
public abstract boolean isTerminated()
isShutdown()
public abstract boolean awaitTermination(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
Calling this method before start()
or shutdown()
is permitted and does not
change its behavior.
isTerminated()
.java.lang.InterruptedException
public abstract void awaitTermination() throws java.lang.InterruptedException
Calling this method before start()
or shutdown()
is permitted and does not
change its behavior.
java.lang.InterruptedException