mirror of https://github.com/grpc/grpc-java.git
core,netty: block server shutdown until the socket is unbound
This commit is contained in:
parent
9739e5b8b6
commit
74e945ceb4
|
|
@ -29,8 +29,10 @@ import javax.annotation.concurrent.ThreadSafe;
|
||||||
*/
|
*/
|
||||||
@ThreadSafe
|
@ThreadSafe
|
||||||
public abstract class Server {
|
public abstract class Server {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bind and start the server.
|
* Bind and start the server. After this call returns, clients may begin connecting to the
|
||||||
|
* listening socket(s).
|
||||||
*
|
*
|
||||||
* @return {@code this} object
|
* @return {@code this} object
|
||||||
* @throws IllegalStateException if already started
|
* @throws IllegalStateException if already started
|
||||||
|
|
@ -102,6 +104,8 @@ public abstract class Server {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initiates an orderly shutdown in which preexisting calls continue but new calls are rejected.
|
* Initiates an orderly shutdown in which preexisting calls continue but new calls are rejected.
|
||||||
|
* After this call returns, this server has released the listening socket(s) and may be reused by
|
||||||
|
* another server.
|
||||||
*
|
*
|
||||||
* @return {@code this} object
|
* @return {@code this} object
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
|
|
@ -111,7 +115,8 @@ public abstract class Server {
|
||||||
/**
|
/**
|
||||||
* Initiates a forceful shutdown in which preexisting and new calls are rejected. Although
|
* Initiates a forceful shutdown in which preexisting and new calls are rejected. Although
|
||||||
* forceful, the shutdown process is still not instantaneous; {@link #isTerminated()} will likely
|
* forceful, the shutdown process is still not instantaneous; {@link #isTerminated()} will likely
|
||||||
* return {@code false} immediately after this method returns.
|
* return {@code 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.
|
||||||
*
|
*
|
||||||
* @return {@code this} object
|
* @return {@code this} object
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,9 @@ public interface InternalServer {
|
||||||
/**
|
/**
|
||||||
* Initiates an orderly shutdown of the server. Existing transports continue, but new transports
|
* Initiates an orderly shutdown of the server. Existing transports continue, but new transports
|
||||||
* will not be created (once {@link ServerListener#serverShutdown()} callback is called). This
|
* will not be created (once {@link ServerListener#serverShutdown()} callback is called). This
|
||||||
* method may only be called once.
|
* method may only be called once. Blocks until the listening socket(s) have been closed. If
|
||||||
|
* interrupted, this method will not wait for the close to complete, but it will happen
|
||||||
|
* asynchronously.
|
||||||
*/
|
*/
|
||||||
void shutdown();
|
void shutdown();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -283,6 +283,12 @@ class NettyServer implements InternalServer, InternalWithLogId {
|
||||||
eventLoopReferenceCounter.release();
|
eventLoopReferenceCounter.release();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
try {
|
||||||
|
channel.closeFuture().sync();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
log.log(Level.FINE, "Interrupted while shutting down", e);
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue