pkuwm 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_r361218190
##########
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:
Different readers/reviewers have different opinions/requirements for
comments. Some might not feel the way as you do. The comments might be helpful
for them, especially when they don't have a context about why this is done.
I've tried to provide clean comments to help understand the code and review the
PR.
Most comments could be achieved by reading the code. But why comments are
still needed? My understanding is, comments are to explain the code and help
readers understand.
Please kindly show me some examples of what "meaningful comments" are?
----------------------------------------------------------------
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]