pkuwm commented on a change in pull request #1066:
URL: https://github.com/apache/helix/pull/1066#discussion_r438500967
##########
File path:
zookeeper-api/src/main/java/org/apache/helix/zookeeper/zkclient/ZkClient.java
##########
@@ -2119,8 +2126,41 @@ private String getHexSessionId() {
* 2. create mode is EPHEMERAL or EPHEMERAL_SEQUENTIAL
*/
private boolean isSessionAwareOperation(String expectedSessionId, CreateMode
mode) {
- return expectedSessionId != null && !expectedSessionId.isEmpty() && (
- mode == CreateMode.EPHEMERAL || mode ==
CreateMode.EPHEMERAL_SEQUENTIAL);
+ return expectedSessionId != null && !expectedSessionId.isEmpty() &&
mode.isEphemeral();
+ }
+
+ private ZooKeeper getExpectedZookeeper(final String expectedSessionId) {
Review comment:
I actually also tried to use this API in `create()` that we previous
added. But inside `create()` there is a `isSessionAwareOperation()` check. If
we don't need this check, we could just use the this method
`getExpectedZookeeper`. And I actually don't think we need the check
"isSessionAwareOperation()" since we only expose `createEphemeral()` to have
expectedSession. We should be good.
##########
File path: helix-core/src/main/java/org/apache/helix/BaseDataAccessor.java
##########
@@ -95,6 +95,24 @@
*/
boolean[] createChildren(List<String> paths, List<T> records, int options);
+ /**
+ * Use it when creating children under a parent node with an expected ZK
session.
+ * <p>
+ * This will use async api for better performance. If the children already
exist it will return
+ * false.
+ *
+ * @param paths the paths to the children ZNodes
+ * @param records List of data to write to each of the path
+ * @param options Set the type of ZNode see the valid values in {@link
AccessOption}
+ * @param expectedSession The expected ZK session to create children
+ * @return For each child: true if creation succeeded, false otherwise (e.g.
if the child exists)
+ */
+ default boolean[] createChildren(List<String> paths, List<T> records, int
options,
Review comment:
Yes. The logic is: sendMessages() -> HelixDataAccessor.createChildren()
-> BaseDataAccessor.createChildren() -> ZkClient.asyncCreate().
So we need the expectedSession to be passed all way down to zkclient from
sendMessages().
----------------------------------------------------------------
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]