Package io.deephaven.server.runner
Interface GrpcServer
- All Known Implementing Classes:
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 TypeMethodDescriptionvoid
Server must stop accepting new streams, but let existing streams continue for now.int
getPort()
After the server is started, this will return the port it is using.void
join()
Blocks as long as the server is running, unless this thread is interrupted.static GrpcServer
of
(io.grpc.Server server) void
start()
Starts the server, if possible.void
stopWithTimeout
(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. -
stopWithTimeout
Stops the server, using the specified timeout as a deadline. Returns immediately. Calljoin()
to block until this is completed.- 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
-