eolivelli commented on a change in pull request #1526:
URL: https://github.com/apache/zookeeper/pull/1526#discussion_r520337639



##########
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:
       ZooKeeperServerShutdownHandler contains a CountDownLatch, that is 
keeping alive the server itself.
   We have to trigger that latch




----------------------------------------------------------------
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]


Reply via email to