li4wang commented on code in PR #1961:
URL: https://github.com/apache/zookeeper/pull/1961#discussion_r1070184620


##########
zookeeper-server/src/main/java/org/apache/zookeeper/server/ZooKeeperServer.java:
##########
@@ -1151,6 +1213,9 @@ protected void setLocalSessionFlag(Request si) {
     }
 
     public void submitRequest(Request si) {
+        if (state == State.MAINTENANCE) {
+            throw new IllegalStateException("Zookeeper server is in 
maintenance state");
+        }

Review Comment:
   > Add MAINTENANCE as a running state to ZooKeeperServer.isRunning() method.
   
   Adding MAINTENANCE to ZooKeeperServer.isRunning() will change the semantics 
of "running" state and has bigger impact, we would want to avoid it if it's 
possible.
   
   > Do not alter the state of ZooKeeperServer, but use a separate volatile 
variable in this class to block requests temporarly.
   
   Good idea. Yes, we don't have to alter the state of ZooKeeper if we don't 
think we need a generic MAINTENANCE state. 
   
   Instead of using volatile variable,  We can add a `CountDownLatch` to more 
efficiently coordinate/sync between threads and utilize system resources. 
   
   The `restoreFromSnapshot()` API  will instantiate a `CountDownLatch` with 1 
count  when starting the restore and count it down when the restore is 
completed. The `submitRequest()` API  will check and wait on the 
`CountDownLatch`. 
   



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

To unsubscribe, e-mail: notifications-unsubscr...@zookeeper.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to