narendly commented on a change in pull request #644: Customize IZkStateListener to add handleNewSession(sessionId) URL: https://github.com/apache/helix/pull/644#discussion_r354694657
########## 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 think not adding this interface has the benefit of "forcing" the user to use `handleNewSession(sessionId)`. Isn't that what we want to achieve? Another way to put this is, do we ever have cases where a user wouldn't care whether `sessionIds` match or not? (I can't think of any - people would assume that sessionIds match?). ---------------------------------------------------------------- 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]
