pkuwm commented on a change in pull request #1066:
URL: https://github.com/apache/helix/pull/1066#discussion_r461127644



##########
File path: helix-core/src/main/java/org/apache/helix/HelixManager.java
##########
@@ -419,6 +420,17 @@ void 
addExternalViewChangeListener(org.apache.helix.ExternalViewChangeListener l
    */
   Long getSessionStartTime();
 
+  /**
+   * Checks whether the cluster manager is leader and returns the session ID 
associated to the
+   * connection of cluster data store, if and only if it is leader.
+   *
+   * @return {@code Optional<String>} session ID is present inside the {@code 
Optional} object
+   * if the cluster manager is leader. Otherwise, returns an empty {@code 
Optional} object.
+   */
+  default Optional<String> getSessionIdIfLead() {

Review comment:
       @kaisun2000 You are right. This is the core idea.

##########
File path: 
zookeeper-api/src/main/java/org/apache/helix/zookeeper/zkclient/SessionAwareZkWriteData.java
##########
@@ -0,0 +1,34 @@
+package org.apache.helix.zookeeper.zkclient;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+/**
+ * An interface representing data being written to ZK is session aware:
+ * data is supposed to be written by expected ZK session. If ZkClient's actual 
session
+ * doesn't match expected session, data is not written to ZK.
+ */
+public interface SessionAwareZkWriteData {

Review comment:
       Yep I actually also thought about `SessionAwareZkDataRecord`. But 
considering the data is only session-aware for write but not read, I made it 
`SessionAwareZkData` to indicate reading data may not use this one as session 
aware. We could think of a better name to make it clear.
   @jiajunwang What's your choice?




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



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

Reply via email to