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_r355716130
##########
File path:
helix-core/src/main/java/org/apache/helix/manager/zk/client/HelixZkClient.java
##########
@@ -148,6 +187,66 @@ void asyncSetData(final String path, Object datat, final
int version,
PathBasedZkSerializer getZkSerializer();
+ /**
+ * A class that wraps a default implementation of
+ * {@link org.apache.helix.manager.zk.zookeeper.IZkStateListener}, which
means this listener
+ * runs the methods of {@link
org.apache.helix.manager.zk.zookeeper.IZkStateListener}.
+ * This is for backward compatibility and to avoid breaking the original
implementation of
+ * {@link org.I0Itec.zkclient.IZkStateListener}.
+ */
+ class I0ItecIZkStateListenerHelixImpl implements
org.I0Itec.zkclient.IZkStateListener {
+ private IZkStateListener listener;
+
+ I0ItecIZkStateListenerHelixImpl(IZkStateListener listener) {
+ this.listener = listener;
+ }
+
+ @Override
+ public void handleStateChanged(KeeperState keeperState) throws Exception {
+ listener.handleStateChanged(keeperState);
+ }
+
+ @Override
+ public void handleNewSession() throws Exception {
+ /*
+ * org.apache.helix.manager.zk.zookeeper.IZkStateListener does not have
handleNewSession(),
+ * so null is passed into handleNewSession(sessionId).
+ */
+ listener.handleNewSession(null);
Review comment:
I considered this. My thought was, if we use SESSION_NOT_SET=null,
1. we are supposed to use it anywhere related to the session id.
2. Since it is a String type, we are supposed to use like
`sessionId.equals(SESSION_NOT_SET)`, which could not check sessionId nullable.
3. And `sessionId != SESSION_NOT_SET` just doesn't look that good to me, for
a String type..
So I decided to use null and add the comments.
----------------------------------------------------------------
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]