You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@helix.apache.org by "junkaixue (via GitHub)" <gi...@apache.org> on 2023/04/13 21:57:57 UTC

[GitHub] [helix] junkaixue commented on a diff in pull request #2432: Use persist watcher for listener registration in ZkClient (when configured)

junkaixue commented on code in PR #2432:
URL: https://github.com/apache/helix/pull/2432#discussion_r1166067173


##########
zookeeper-api/src/main/java/org/apache/helix/zookeeper/zkclient/ZkClient.java:
##########
@@ -2921,10 +2988,47 @@ private void addChildListener(String path, IZkChildListener listener) {
     listeners.add(listener);
   }
 
+  private void addPersistListener(String path, Object listener) {
+    try {
+      _persistListenerMutex.lockInterruptibly();
+      if (listener instanceof IZkChildListener) {
+        addChildListener(path, (IZkChildListener) listener);
+      } else if (listener instanceof IZkDataListener) {
+        addDataListener(path, (IZkDataListener) listener);
+      }
+    } catch (InterruptedException ex) {
+      throw new ZkInterruptedException(ex);
+    } finally {
+      _persistListenerMutex.unlock();

Review Comment:
   Would it be possible to make these pieces of code generic?
   
   _mutx.lock();
   passedin method.invoke(xxxx)
   
   catch(e){}
   finally{
   _mutex.unlock();
   }
   



-- 
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: reviews-unsubscribe@helix.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org