Package io.deephaven.server.runner
Interface GrpcServer
- All Known Implementing Classes:
JettyBackedGrpcServer,JettyBackedGrpcServer
public interface GrpcServer
This interface handles the lifecycle of Netty and Jetty servers in a unified way, while still supporting the use
cases that Deephaven expects:
- Deephaven wants to initiate stop early in the shutdown process, and block on it after all services have begun to stop.
- gRPC+Netty supports a non-blocking stop, a "stop now", and a pair of await methods, one of which takes a timeout.
- gRPC+Jetty supports a blocking stop with a timeout, and a join() method.
-
Method Summary
Modifier and TypeMethodDescriptionvoidServer must stop accepting new streams, but let existing streams continue for now.intgetPort()After the server is started, this will return the port it is using.voidjoin()Blocks as long as the server is running, unless this thread is interrupted.static GrpcServerof(io.grpc.Server server) voidstart()Starts the server, if possible.voidstopWithTimeout(long timeout, TimeUnit unit) Stops the server, using the specified timeout as a deadline.
-
Method Details
-
start
Starts the server, if possible. Otherwise, throws an exception. If successful, returns.- Throws:
IOException- if there is an error on startup
-
join
Blocks as long as the server is running, unless this thread is interrupted. If stopWithTimeout has been called and the timeout has expired, this will return, and the server will be stopped.- Throws:
InterruptedException
-
beginShutdown
void beginShutdown()Server must stop accepting new streams, but let existing streams continue for now.
In theory the listening socket should be freed and available for another application to take it, but this is not rigorously tested.
To complete shutdown, call stopWithTimeout() after any remaining calls have been completed to the server's satisfaction, which will terminate the remaining calls. -
stopWithTimeout
Stops the server, using the specified timeout as a deadline. Returns immediately. Calljoin()to block until this is completed.
If pending calls do not matter, it is unnecessary to call beginShutdown() before this method.- Parameters:
timeout- time to allow for a graceful shutdown before giving up and haltingunit- unit to apply to the timeout
-
getPort
int getPort()After the server is started, this will return the port it is using.- Returns:
- the tcp port that the server is listening on after it has started
-
of
-