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



##########
File path: helix-core/src/main/java/org/apache/helix/model/Message.java
##########
@@ -953,4 +970,35 @@ public boolean isValid() {
     }
     return true;
   }
+
+  // A class represents session aware ZNRecord for message. The message should 
be written to zk
+  // by the expected session.
+  // TODO: remove this class once public session-aware ZNRecord is available
+  private static class SessionAwareZNRecord extends ZNRecord implements 
SessionAwareZkWriteData {

Review comment:
       @lei-xia I've considered and tried to break the PR down to 2 smaller 
ones: fixing the issue without new interface and adding new interface. But the 
first one PR would look quite hacky and I don't feel comfortable merging the 
commit to code base. So I decided to keep this PR and make 
`SessionAwareZNRecord` public. Even in the future we need to add more APIs to 
the interface, we could also add API implementation to `SessionAwareZNRecord`. 
In this way, I feel it is cleaner to check in.

##########
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:
       One more thing for `why do we need this if we already have 
manager.getSessionId?`:
   `getSessionId` just directly returns the existing sessionId in manager. But 
`getSessionIdIfLeader()` does more thing by reading zk to check leadership. 
This is the main difference.




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