pkuwm commented on a change in pull request #644: Add new interface 
IZkStateListener to provide session aware handleNewSession for ZkHelixManager
URL: https://github.com/apache/helix/pull/644#discussion_r355300830
 
 

 ##########
 File path: 
helix-core/src/main/java/org/apache/helix/manager/zk/zookeeper/ZkClient.java
 ##########
 @@ -1754,4 +1784,64 @@ private void recordStateChange(boolean stateChanged, 
boolean dataChanged) {
       }
     }
   }
+
+  /**
+   * Creates a {@link org.apache.helix.manager.zk.zookeeper.IZkStateListener} 
that wraps a default
+   * implementation of {@link org.I0Itec.zkclient.IZkStateListener}, which 
means the returned
+   * listener runs the methods of {@link org.I0Itec.zkclient.IZkStateListener}.
+   * This is for backward compatibility with {@link 
org.I0Itec.zkclient.IZkStateListener}.
+   */
+  private static class IZkStateListenerI0ItecImpl implements IZkStateListener {
+    private org.I0Itec.zkclient.IZkStateListener listener;
+
+    IZkStateListenerI0ItecImpl(org.I0Itec.zkclient.IZkStateListener listener) {
+      this.listener = listener;
+    }
+
+    @Override
+    public void handleStateChanged(Watcher.Event.KeeperState keeperState) 
throws Exception {
+      listener.handleStateChanged(keeperState);
+    }
+
+    @Override
+    public void handleNewSession(final String sessionId) throws Exception {
+      /*
+       * org.I0Itec.zkclient.IZkStateListener does not have 
handleNewSession(sessionId),
+       * so just call handleNewSession() by default.
+       */
+      listener.handleNewSession();
+    }
+
+    @Override
+    public void handleSessionEstablishmentError(Throwable error) throws 
Exception {
+      listener.handleSessionEstablishmentError(error);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+      if (obj == this) {
+        return true;
+      }
+      if (!(obj instanceof IZkStateListener)) {
+        return false;
+      }
+      if (listener == null) {
+        return false;
+      }
+
+      IZkStateListenerI0ItecImpl defaultListener = 
(IZkStateListenerI0ItecImpl) obj;
 
 Review comment:
   Good catch. You are correct. Should be IZkStateListener.

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


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to