ztzg commented on a change in pull request #1526:
URL: https://github.com/apache/zookeeper/pull/1526#discussion_r521259723
##########
File path:
zookeeper-server/src/main/java/org/apache/zookeeper/server/ZooKeeperServerMain.java
##########
@@ -237,4 +237,26 @@ ServerCnxnFactory getCnxnFactory() {
return cnxnFactory;
}
+ /**
+ * Shutdowns properly the service, this method is not a public API.
+ */
+ public void close() {
+ ServerCnxnFactory primaryCnxnFactory = this.cnxnFactory;
+ if (primaryCnxnFactory == null) {
+ // in case of pure TLS we can hook into secureCnxnFactory
+ primaryCnxnFactory = secureCnxnFactory;
+ }
+ if (primaryCnxnFactory == null ||
primaryCnxnFactory.getZooKeeperServer() == null) {
+ return;
+ }
+ ZooKeeperServerShutdownHandler zkShutdownHandler =
primaryCnxnFactory.getZooKeeperServer().getZkShutdownHandler();
+ zkShutdownHandler.handle(ZooKeeperServer.State.SHUTDOWN);
Review comment:
Interesting. My initial point was that `ZooKeeperServer.setState`
invokes `zkShutdownHandler`'s `handle` method—which itself decrements the
latch—but I now see that `QuorumZooKeeperServer` and `ReadOnlyZooKeeperServer`
override that method, and do not delegate to the superclass. (Part of the
backstory is at
[ZOOKEEPER-2247](https://issues.apache.org/jira/browse/ZOOKEEPER-2247), but
that's quite a long thread and I haven't deciphered it fully.)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]