pkuwm commented on a change in pull request #644: Customize IZkStateListener to 
add handleNewSession(sessionId)
URL: https://github.com/apache/helix/pull/644#discussion_r354645798
 
 

 ##########
 File path: 
helix-core/src/main/java/org/apache/helix/manager/zk/zookeeper/IZkStateListener.java
 ##########
 @@ -0,0 +1,69 @@
+/**
+ * Copyright 2010 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.helix.manager.zk.zookeeper;
+
+import org.apache.zookeeper.Watcher.Event.KeeperState;
+
+public interface IZkStateListener {
+
+  /**
+   * Called when the zookeeper connection state has changed.
+   *
+   * @param state
+   *            The new state.
+   * @throws Exception
+   *             On any error.
+   */
+  void handleStateChanged(KeeperState state) throws Exception;
+
+  /**
+   * Called after the zookeeper session has expired and a new session has been 
created.
+   * You would have to re-create any ephemeral nodes here.
+   *
+   * @deprecated
+   * This is deprecated, because it may cause session race condition when 
creating ephemeral nodes.
+   * Please use {@link #handleNewSession(String)} instead, which takes care of 
race condition.
+   *
+   * @throws Exception
+   *             On any error.
+   */
+  @Deprecated
+  void handleNewSession() throws Exception;
 
 Review comment:
   I understand your point.
   
   My understanding was, when users want to use `handleNewSession(sessionId)`, 
they import this new interface. And in any case that they would like to keep 
their original code using `handleNewSession()`, they don't have to change. If 
`handleNewSession(sessionId)` is forced to use when using IZkStateListener, we 
can remove this method.
   Let's have a bit more sync up about this.

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