jiajunwang commented on a change in pull request #642: Fix handleNewSession
creating ephemeral node with expired session
URL: https://github.com/apache/helix/pull/642#discussion_r361018418
##########
File path:
helix-core/src/main/java/org/apache/helix/manager/zk/zookeeper/ZkClient.java
##########
@@ -556,15 +644,55 @@ public String create(final String path, Object datat,
final List<ACL> acl, final
}
long startT = System.currentTimeMillis();
try {
- final byte[] data = datat == null ? null : serialize(datat, path);
- checkDataSizeLimit(data);
- String actualPath = retryUntilConnected(new Callable<String>() {
- @Override
- public String call() throws Exception {
- return getConnection().create(path, data, acl, mode);
+ final byte[] dataBytes = dataObject == null ? null :
serialize(dataObject, path);
+ checkDataSizeLimit(dataBytes);
+
+ /*
+ * We pass different implementation of callable.
+ * 1. If the session id is null, it means the operation is NOT session
aware.
+ * In this case, we will implement a regular callable to create a node.
+ * 2. Otherwise, the operation is session aware. We will use a to
+ * create a node which is guaranteed to be created in the expected
session.
+ */
+ final String actualPath = retryUntilConnected(() -> {
+ ZooKeeper zooKeeper = ((ZkConnection) getConnection()).getZookeeper();
+
+ /*
+ * 1. If the session id is NOT null and create mode is EPHEMERAL or
EPHEMERAL_SEQUENTIAL,
Review comment:
Please do meaningful comments instead of reading the code for me. The
conditions are very clear below.
----------------------------------------------------------------
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]