You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@helix.apache.org by GitBox <gi...@apache.org> on 2022/05/11 22:21:42 UTC

[GitHub] [helix] rabashizade opened a new pull request, #2090: Add TTL and Container modes to sync create API in ZkClient and ZkConnection

rabashizade opened a new pull request, #2090:
URL: https://github.com/apache/helix/pull/2090

   ### Issues
   
   - [x] My PR addresses the following Helix issues and references them in the PR description:
   
   Fixes #2081 
   
   ### Description
   
   - [x] Here are some details about my PR, including screenshots of any UI changes:
   
   This PR adds methods that support creating persistent nodes with Container and TTL modes synchronously to ZkClient and ZkConnection classes.
   
   ### Tests
   
   - [ ] The following tests are written for this issue:
   
   The changes have been tested locally, but since Zookeeper server makes no guarantee on exactly when the Container and TTL nodes are deleted (see [here](https://zookeeper.apache.org/doc/r3.5.9/zookeeperProgrammers.html#TTL+Nodes)), the tests become flaky and as a result, are not added to this PR.
   
   - The following is the result of the "mvn test" command on the appropriate module:
   
   (If CI test fails due to known issue, please specify the issue and test PR locally. Then copy & paste the result of "mvn test" to here.)
   
   ### Changes that Break Backward Compatibility (Optional)
   
   - My PR contains changes that break backward compatibility or previous assumptions for certain methods or API. They include:
   
   (Consider including all behavior changes for public methods or API. Also include these changes in merge description so that other developers are aware of these changes. This allows them to make relevant code changes in feature branches accounting for the new method/API behavior.)
   
   ### Documentation (Optional)
   
   - In case of new functionality, my PR adds documentation in the following wiki page:
   
   (Link the GitHub wiki you added)
   
   ### Commits
   
   - My commits all reference appropriate Apache Helix GitHub issues in their subject lines. In addition, my commits follow the guidelines from "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)":
     1. Subject is separated from body by a blank line
     1. Subject is limited to 50 characters (not including Jira issue reference)
     1. Subject does not end with a period
     1. Subject uses the imperative mood ("add", not "adding")
     1. Body wraps at 72 characters
     1. Body explains "what" and "why", not "how"
   
   ### Code Quality
   
   - My diff has been formatted using helix-style.xml 
   (helix-style-intellij.xml if IntelliJ IDE is used)
   


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

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] NealSun96 commented on a diff in pull request #2090: Add TTL and Container modes to sync create API in ZkClient and ZkConnection

Posted by GitBox <gi...@apache.org>.
NealSun96 commented on code in PR #2090:
URL: https://github.com/apache/helix/pull/2090#discussion_r875107770


##########
zookeeper-api/src/test/java/org/apache/helix/zookeeper/impl/client/TestRawZkClient.java:
##########
@@ -89,6 +89,65 @@ public void afterClass() {
     _zkClient.close();
   }
 
+  @Test
+  void testUnimplementedTypes() {
+    System.clearProperty("zookeeper.extendedTypesEnabled");

Review Comment:
   Question: how is this property involved? Didn't see it in the code change. 



##########
zookeeper-api/src/test/java/org/apache/helix/zookeeper/impl/client/TestRawZkClient.java:
##########
@@ -89,6 +89,65 @@ public void afterClass() {
     _zkClient.close();
   }
 
+  @Test
+  void testUnimplementedTypes() {
+    System.clearProperty("zookeeper.extendedTypesEnabled");
+    String parentPath = "/tmp";
+    String path = "/tmp/unimplemented";
+    long ttl = 1L;
+    _zkClient.deleteRecursively(parentPath);
+    try {
+      _zkClient.createPersistentWithTTL(path, true, ttl);
+    } catch (ZkException e) {
+      AssertJUnit.assertTrue(e.getCause() instanceof KeeperException.UnimplementedException);
+      return;
+    }
+    _zkClient.deleteRecursively(parentPath);
+    AssertJUnit.fail();
+  }
+
+  @Test
+  void testCreatePersistentWithTTL() {
+    System.setProperty("zookeeper.extendedTypesEnabled", "true");
+    String parentPath = "/tmp";
+    String path = "/tmp/createTTL";
+    _zkClient.deleteRecursively(parentPath);
+    AssertJUnit.assertFalse(_zkClient.exists(path));
+    long ttl = 1L;
+    _zkClient.createPersistentWithTTL(path, true, ttl);
+    AssertJUnit.assertTrue(_zkClient.exists(path));
+    _zkClient.deleteRecursively(parentPath);
+    System.clearProperty("zookeeper.extendedTypesEnabled");
+  }
+
+  @Test
+  void testCreatePersistentSequentialWithTTL() {
+    System.setProperty("zookeeper.extendedTypesEnabled", "true");
+    String parentPath = "/tmp";
+    String path = "/tmp/createSequentialTTL";
+    _zkClient.deleteRecursively(parentPath);
+    AssertJUnit.assertFalse(_zkClient.exists(path + "0000000000"));
+    long ttl = 1L;
+    _zkClient.createPersistent(parentPath);
+    _zkClient.createPersistentSequentialWithTTL(path, null, ttl);
+    AssertJUnit.assertTrue(_zkClient.exists(path + "0000000000"));
+    _zkClient.deleteRecursively(parentPath);
+    System.clearProperty("zookeeper.extendedTypesEnabled");
+  }
+
+  @Test
+  void testCreateContainer() {
+    System.setProperty("zookeeper.extendedTypesEnabled", "true");
+    String parentPath = "/tmp";
+    String path = "/tmp/createContainer";
+    _zkClient.deleteRecursively(parentPath);
+    AssertJUnit.assertFalse(_zkClient.exists(path));
+    _zkClient.createContainer(path, true);

Review Comment:
   Would it be better to test more entry functions, with different parameter requirements? 



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

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] rabashizade commented on a diff in pull request #2090: Add TTL and Container modes to sync create API in ZkClient and ZkConnection

Posted by GitBox <gi...@apache.org>.
rabashizade commented on code in PR #2090:
URL: https://github.com/apache/helix/pull/2090#discussion_r875251089


##########
zookeeper-api/src/test/java/org/apache/helix/zookeeper/impl/client/TestRawZkClient.java:
##########
@@ -89,6 +89,65 @@ public void afterClass() {
     _zkClient.close();
   }
 
+  @Test
+  void testUnimplementedTypes() {
+    System.clearProperty("zookeeper.extendedTypesEnabled");
+    String parentPath = "/tmp";
+    String path = "/tmp/unimplemented";
+    long ttl = 1L;
+    _zkClient.deleteRecursively(parentPath);
+    try {
+      _zkClient.createPersistentWithTTL(path, true, ttl);
+    } catch (ZkException e) {
+      AssertJUnit.assertTrue(e.getCause() instanceof KeeperException.UnimplementedException);
+      return;
+    }
+    _zkClient.deleteRecursively(parentPath);
+    AssertJUnit.fail();
+  }
+
+  @Test
+  void testCreatePersistentWithTTL() {
+    System.setProperty("zookeeper.extendedTypesEnabled", "true");
+    String parentPath = "/tmp";
+    String path = "/tmp/createTTL";
+    _zkClient.deleteRecursively(parentPath);
+    AssertJUnit.assertFalse(_zkClient.exists(path));
+    long ttl = 1L;
+    _zkClient.createPersistentWithTTL(path, true, ttl);
+    AssertJUnit.assertTrue(_zkClient.exists(path));
+    _zkClient.deleteRecursively(parentPath);
+    System.clearProperty("zookeeper.extendedTypesEnabled");
+  }
+
+  @Test
+  void testCreatePersistentSequentialWithTTL() {
+    System.setProperty("zookeeper.extendedTypesEnabled", "true");
+    String parentPath = "/tmp";
+    String path = "/tmp/createSequentialTTL";
+    _zkClient.deleteRecursively(parentPath);
+    AssertJUnit.assertFalse(_zkClient.exists(path + "0000000000"));
+    long ttl = 1L;
+    _zkClient.createPersistent(parentPath);
+    _zkClient.createPersistentSequentialWithTTL(path, null, ttl);
+    AssertJUnit.assertTrue(_zkClient.exists(path + "0000000000"));
+    _zkClient.deleteRecursively(parentPath);
+    System.clearProperty("zookeeper.extendedTypesEnabled");
+  }
+
+  @Test
+  void testCreateContainer() {
+    System.setProperty("zookeeper.extendedTypesEnabled", "true");
+    String parentPath = "/tmp";
+    String path = "/tmp/createContainer";
+    _zkClient.deleteRecursively(parentPath);
+    AssertJUnit.assertFalse(_zkClient.exists(path));
+    _zkClient.createContainer(path, true);

Review Comment:
   I added calls with the API that writes data to ZK as well. I think the rest of the new methods get called internally by calling these higher-level API. If this doesn't satisfy your concern, please let me know so I call them explicitly.



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

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] narendly merged pull request #2090: Add TTL and Container modes to sync create API in ZkClient and ZkConnection

Posted by GitBox <gi...@apache.org>.
narendly merged PR #2090:
URL: https://github.com/apache/helix/pull/2090


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

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] rabashizade commented on a diff in pull request #2090: Add TTL and Container modes to sync create API in ZkClient and ZkConnection

Posted by GitBox <gi...@apache.org>.
rabashizade commented on code in PR #2090:
URL: https://github.com/apache/helix/pull/2090#discussion_r875269063


##########
zookeeper-api/src/main/java/org/apache/helix/zookeeper/zkclient/ZkClient.java:
##########
@@ -438,6 +438,41 @@ public void createPersistent(String path)
     createPersistent(path, false);
   }
 
+  /**
+   * Create a persistent node with TTL.
+   * @param path the path where you want the node to be created
+   * @param ttl TTL of the node in milliseconds
+   * @throws ZkInterruptedException
+   *           if operation was interrupted, or a required reconnection got interrupted
+   * @throws IllegalArgumentException
+   *           if called from anything except the ZooKeeper event thread
+   * @throws ZkException
+   *           if any ZooKeeper exception occurred
+   * @throws RuntimeException
+   *           if any other exception occurs
+   */
+  public void createPersistentWithTTL(String path, long ttl)

Review Comment:
   I created them because the version without TTL existed, and the version with TTL is now supported in Zookeeper. If you think of a specific reason to not have them, please let me know and I can remove them.



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

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] rabashizade commented on a diff in pull request #2090: Add TTL and Container modes to sync create API in ZkClient and ZkConnection

Posted by GitBox <gi...@apache.org>.
rabashizade commented on code in PR #2090:
URL: https://github.com/apache/helix/pull/2090#discussion_r871959132


##########
zookeeper-api/src/main/java/org/apache/helix/zookeeper/zkclient/IZkConnection.java:
##########
@@ -40,6 +40,8 @@ public interface IZkConnection {
 
     public String create(String path, byte[] data, List<ACL> acl, CreateMode mode) throws KeeperException, InterruptedException;
 
+    public String create(String path, byte[] data, List<ACL> acl, CreateMode mode, long ttl) throws KeeperException, InterruptedException;

Review Comment:
   Thank you for the suggestion. I added some tests to the `TestRawZkClient` class for verifying node creation with the new modes.



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

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] rabashizade commented on a diff in pull request #2090: Add TTL and Container modes to sync create API in ZkClient and ZkConnection

Posted by GitBox <gi...@apache.org>.
rabashizade commented on code in PR #2090:
URL: https://github.com/apache/helix/pull/2090#discussion_r875161224


##########
zookeeper-api/src/test/java/org/apache/helix/zookeeper/impl/client/TestRawZkClient.java:
##########
@@ -89,6 +89,65 @@ public void afterClass() {
     _zkClient.close();
   }
 
+  @Test
+  void testUnimplementedTypes() {
+    System.clearProperty("zookeeper.extendedTypesEnabled");

Review Comment:
   This is a system property that should be set for Zookeeper server to support extended types (i.e.,g TTL and container). If it is not set, a KeeperException.UnimlementedException will be thrown. You can find more about it [here](https://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_configuration) and looking for the property name.



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

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] narendly commented on a diff in pull request #2090: Add TTL and Container modes to sync create API in ZkClient and ZkConnection

Posted by GitBox <gi...@apache.org>.
narendly commented on code in PR #2090:
URL: https://github.com/apache/helix/pull/2090#discussion_r871420659


##########
zookeeper-api/src/main/java/org/apache/helix/zookeeper/zkclient/IZkConnection.java:
##########
@@ -40,6 +40,8 @@ public interface IZkConnection {
 
     public String create(String path, byte[] data, List<ACL> acl, CreateMode mode) throws KeeperException, InterruptedException;
 
+    public String create(String path, byte[] data, List<ACL> acl, CreateMode mode, long ttl) throws KeeperException, InterruptedException;

Review Comment:
   This is a general comment. Now with this PR, I think it would be beneficial to add some basic tests such as creating using the newly added modes (TTL, container). Since ZK doesn't guarantee how long it would take to delete and there is no good way to tell whether the znode is created on TTL post-creation, I think read/write, checking that creation and deletion went through, would be beneficial. What do you think?



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

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] rabashizade commented on a diff in pull request #2090: Add TTL and Container modes to sync create API in ZkClient and ZkConnection

Posted by GitBox <gi...@apache.org>.
rabashizade commented on code in PR #2090:
URL: https://github.com/apache/helix/pull/2090#discussion_r875283556


##########
zookeeper-api/src/main/java/org/apache/helix/zookeeper/zkclient/ZkClient.java:
##########
@@ -438,6 +438,41 @@ public void createPersistent(String path)
     createPersistent(path, false);
   }
 
+  /**
+   * Create a persistent node with TTL.
+   * @param path the path where you want the node to be created
+   * @param ttl TTL of the node in milliseconds
+   * @throws ZkInterruptedException
+   *           if operation was interrupted, or a required reconnection got interrupted
+   * @throws IllegalArgumentException
+   *           if called from anything except the ZooKeeper event thread
+   * @throws ZkException
+   *           if any ZooKeeper exception occurred
+   * @throws RuntimeException
+   *           if any other exception occurs
+   */
+  public void createPersistentWithTTL(String path, long ttl)

Review Comment:
   I see your point now. for the createParents version, I think it doesn't make sense for sequential mode because the path is altered, and wouldn't be clear what the complete path of the ZNode will be at the end. For the other API you asked about, I think the data argument can be set to null to achieve the same behavior. I tried to be consistent with the existing API, so I only added new methods that correspond to existing ones.



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

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] rabashizade commented on a diff in pull request #2090: Add TTL and Container modes to sync create API in ZkClient and ZkConnection

Posted by GitBox <gi...@apache.org>.
rabashizade commented on code in PR #2090:
URL: https://github.com/apache/helix/pull/2090#discussion_r870836582


##########
zookeeper-api/src/main/java/org/apache/helix/zookeeper/zkclient/ZkClient.java:
##########
@@ -728,8 +1031,14 @@ private String create(final String path, final Object dataObject, final List<ACL
       final byte[] dataBytes = dataObject == null ? null : serialize(dataObject, path);
       checkDataSizeLimit(path, dataBytes);
 
-      final String actualPath = retryUntilConnected(
-          () -> getExpectedZookeeper(expectedSessionId).create(path, dataBytes, acl, mode));
+      final String actualPath;
+      if (mode.isTTL()) {
+        actualPath = retryUntilConnected(() -> getExpectedZookeeper(expectedSessionId)
+            .create(path, dataBytes, acl, mode, new Stat(), ttl));

Review Comment:
   Yes, that makes sense. I changed it to `null`.



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

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] rabashizade commented on a diff in pull request #2090: Add TTL and Container modes to sync create API in ZkClient and ZkConnection

Posted by GitBox <gi...@apache.org>.
rabashizade commented on code in PR #2090:
URL: https://github.com/apache/helix/pull/2090#discussion_r875269821


##########
zookeeper-api/src/test/java/org/apache/helix/zookeeper/impl/client/TestRawZkClient.java:
##########
@@ -89,6 +89,65 @@ public void afterClass() {
     _zkClient.close();
   }
 
+  @Test
+  void testUnimplementedTypes() {
+    System.clearProperty("zookeeper.extendedTypesEnabled");
+    String parentPath = "/tmp";
+    String path = "/tmp/unimplemented";
+    long ttl = 1L;
+    _zkClient.deleteRecursively(parentPath);
+    try {
+      _zkClient.createPersistentWithTTL(path, true, ttl);
+    } catch (ZkException e) {
+      AssertJUnit.assertTrue(e.getCause() instanceof KeeperException.UnimplementedException);
+      return;
+    }
+    _zkClient.deleteRecursively(parentPath);
+    AssertJUnit.fail();
+  }
+
+  @Test
+  void testCreatePersistentWithTTL() {
+    System.setProperty("zookeeper.extendedTypesEnabled", "true");
+    String parentPath = "/tmp";
+    String path = "/tmp/createTTL";
+    _zkClient.deleteRecursively(parentPath);
+    AssertJUnit.assertFalse(_zkClient.exists(path));
+    long ttl = 1L;
+    _zkClient.createPersistentWithTTL(path, true, ttl);
+    AssertJUnit.assertTrue(_zkClient.exists(path));
+    _zkClient.deleteRecursively(parentPath);
+    System.clearProperty("zookeeper.extendedTypesEnabled");
+  }
+
+  @Test
+  void testCreatePersistentSequentialWithTTL() {
+    System.setProperty("zookeeper.extendedTypesEnabled", "true");
+    String parentPath = "/tmp";
+    String path = "/tmp/createSequentialTTL";
+    _zkClient.deleteRecursively(parentPath);
+    AssertJUnit.assertFalse(_zkClient.exists(path + "0000000000"));
+    long ttl = 1L;
+    _zkClient.createPersistent(parentPath);
+    _zkClient.createPersistentSequentialWithTTL(path, null, ttl);
+    AssertJUnit.assertTrue(_zkClient.exists(path + "0000000000"));
+    _zkClient.deleteRecursively(parentPath);
+    System.clearProperty("zookeeper.extendedTypesEnabled");
+  }
+
+  @Test
+  void testCreateContainer() {
+    System.setProperty("zookeeper.extendedTypesEnabled", "true");
+    String parentPath = "/tmp";
+    String path = "/tmp/createContainer";
+    _zkClient.deleteRecursively(parentPath);
+    AssertJUnit.assertFalse(_zkClient.exists(path));
+    _zkClient.createContainer(path, true);

Review Comment:
   @mgao0 I had just added some more tests before your comment, is your comment considering those tests as well?



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

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] rabashizade commented on pull request #2090: Add TTL and Container modes to sync create API in ZkClient and ZkConnection

Posted by GitBox <gi...@apache.org>.
rabashizade commented on PR #2090:
URL: https://github.com/apache/helix/pull/2090#issuecomment-1129408524

   This PR is ready to be merged, approved by @narendly and @NealSun96.


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

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] mgao0 commented on a diff in pull request #2090: Add TTL and Container modes to sync create API in ZkClient and ZkConnection

Posted by GitBox <gi...@apache.org>.
mgao0 commented on code in PR #2090:
URL: https://github.com/apache/helix/pull/2090#discussion_r875250187


##########
zookeeper-api/src/main/java/org/apache/helix/zookeeper/zkclient/ZkClient.java:
##########
@@ -438,6 +438,41 @@ public void createPersistent(String path)
     createPersistent(path, false);
   }
 
+  /**
+   * Create a persistent node with TTL.
+   * @param path the path where you want the node to be created
+   * @param ttl TTL of the node in milliseconds
+   * @throws ZkInterruptedException
+   *           if operation was interrupted, or a required reconnection got interrupted
+   * @throws IllegalArgumentException
+   *           if called from anything except the ZooKeeper event thread
+   * @throws ZkException
+   *           if any ZooKeeper exception occurred
+   * @throws RuntimeException
+   *           if any other exception occurs
+   */
+  public void createPersistentWithTTL(String path, long ttl)

Review Comment:
   Do we need `public void createPersistentSequentialWithTTL(String path, long ttl)` and `public void createPersistentSequentialWithTTL(String path, boolean createParents, long ttl)`?



##########
zookeeper-api/src/test/java/org/apache/helix/zookeeper/impl/client/TestRawZkClient.java:
##########
@@ -89,6 +89,65 @@ public void afterClass() {
     _zkClient.close();
   }
 
+  @Test
+  void testUnimplementedTypes() {
+    System.clearProperty("zookeeper.extendedTypesEnabled");
+    String parentPath = "/tmp";
+    String path = "/tmp/unimplemented";
+    long ttl = 1L;
+    _zkClient.deleteRecursively(parentPath);
+    try {
+      _zkClient.createPersistentWithTTL(path, true, ttl);
+    } catch (ZkException e) {
+      AssertJUnit.assertTrue(e.getCause() instanceof KeeperException.UnimplementedException);
+      return;
+    }
+    _zkClient.deleteRecursively(parentPath);
+    AssertJUnit.fail();
+  }
+
+  @Test
+  void testCreatePersistentWithTTL() {
+    System.setProperty("zookeeper.extendedTypesEnabled", "true");
+    String parentPath = "/tmp";
+    String path = "/tmp/createTTL";
+    _zkClient.deleteRecursively(parentPath);
+    AssertJUnit.assertFalse(_zkClient.exists(path));
+    long ttl = 1L;
+    _zkClient.createPersistentWithTTL(path, true, ttl);
+    AssertJUnit.assertTrue(_zkClient.exists(path));
+    _zkClient.deleteRecursively(parentPath);
+    System.clearProperty("zookeeper.extendedTypesEnabled");
+  }
+
+  @Test
+  void testCreatePersistentSequentialWithTTL() {
+    System.setProperty("zookeeper.extendedTypesEnabled", "true");
+    String parentPath = "/tmp";
+    String path = "/tmp/createSequentialTTL";
+    _zkClient.deleteRecursively(parentPath);
+    AssertJUnit.assertFalse(_zkClient.exists(path + "0000000000"));
+    long ttl = 1L;
+    _zkClient.createPersistent(parentPath);
+    _zkClient.createPersistentSequentialWithTTL(path, null, ttl);
+    AssertJUnit.assertTrue(_zkClient.exists(path + "0000000000"));
+    _zkClient.deleteRecursively(parentPath);
+    System.clearProperty("zookeeper.extendedTypesEnabled");
+  }
+
+  @Test
+  void testCreateContainer() {
+    System.setProperty("zookeeper.extendedTypesEnabled", "true");
+    String parentPath = "/tmp";
+    String path = "/tmp/createContainer";
+    _zkClient.deleteRecursively(parentPath);
+    AssertJUnit.assertFalse(_zkClient.exists(path));
+    _zkClient.createContainer(path, true);

Review Comment:
   +1



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

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] mgao0 commented on a diff in pull request #2090: Add TTL and Container modes to sync create API in ZkClient and ZkConnection

Posted by GitBox <gi...@apache.org>.
mgao0 commented on code in PR #2090:
URL: https://github.com/apache/helix/pull/2090#discussion_r875271537


##########
zookeeper-api/src/test/java/org/apache/helix/zookeeper/impl/client/TestRawZkClient.java:
##########
@@ -89,6 +89,65 @@ public void afterClass() {
     _zkClient.close();
   }
 
+  @Test
+  void testUnimplementedTypes() {
+    System.clearProperty("zookeeper.extendedTypesEnabled");
+    String parentPath = "/tmp";
+    String path = "/tmp/unimplemented";
+    long ttl = 1L;
+    _zkClient.deleteRecursively(parentPath);
+    try {
+      _zkClient.createPersistentWithTTL(path, true, ttl);
+    } catch (ZkException e) {
+      AssertJUnit.assertTrue(e.getCause() instanceof KeeperException.UnimplementedException);
+      return;
+    }
+    _zkClient.deleteRecursively(parentPath);
+    AssertJUnit.fail();
+  }
+
+  @Test
+  void testCreatePersistentWithTTL() {
+    System.setProperty("zookeeper.extendedTypesEnabled", "true");
+    String parentPath = "/tmp";
+    String path = "/tmp/createTTL";
+    _zkClient.deleteRecursively(parentPath);
+    AssertJUnit.assertFalse(_zkClient.exists(path));
+    long ttl = 1L;
+    _zkClient.createPersistentWithTTL(path, true, ttl);
+    AssertJUnit.assertTrue(_zkClient.exists(path));
+    _zkClient.deleteRecursively(parentPath);
+    System.clearProperty("zookeeper.extendedTypesEnabled");
+  }
+
+  @Test
+  void testCreatePersistentSequentialWithTTL() {
+    System.setProperty("zookeeper.extendedTypesEnabled", "true");
+    String parentPath = "/tmp";
+    String path = "/tmp/createSequentialTTL";
+    _zkClient.deleteRecursively(parentPath);
+    AssertJUnit.assertFalse(_zkClient.exists(path + "0000000000"));
+    long ttl = 1L;
+    _zkClient.createPersistent(parentPath);
+    _zkClient.createPersistentSequentialWithTTL(path, null, ttl);
+    AssertJUnit.assertTrue(_zkClient.exists(path + "0000000000"));
+    _zkClient.deleteRecursively(parentPath);
+    System.clearProperty("zookeeper.extendedTypesEnabled");
+  }
+
+  @Test
+  void testCreateContainer() {
+    System.setProperty("zookeeper.extendedTypesEnabled", "true");
+    String parentPath = "/tmp";
+    String path = "/tmp/createContainer";
+    _zkClient.deleteRecursively(parentPath);
+    AssertJUnit.assertFalse(_zkClient.exists(path));
+    _zkClient.createContainer(path, true);

Review Comment:
   Thanks @rabashizade , the updated tests look good to me.



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

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] mgao0 commented on a diff in pull request #2090: Add TTL and Container modes to sync create API in ZkClient and ZkConnection

Posted by GitBox <gi...@apache.org>.
mgao0 commented on code in PR #2090:
URL: https://github.com/apache/helix/pull/2090#discussion_r875270589


##########
zookeeper-api/src/main/java/org/apache/helix/zookeeper/zkclient/ZkClient.java:
##########
@@ -438,6 +438,41 @@ public void createPersistent(String path)
     createPersistent(path, false);
   }
 
+  /**
+   * Create a persistent node with TTL.
+   * @param path the path where you want the node to be created
+   * @param ttl TTL of the node in milliseconds
+   * @throws ZkInterruptedException
+   *           if operation was interrupted, or a required reconnection got interrupted
+   * @throws IllegalArgumentException
+   *           if called from anything except the ZooKeeper event thread
+   * @throws ZkException
+   *           if any ZooKeeper exception occurred
+   * @throws RuntimeException
+   *           if any other exception occurs
+   */
+  public void createPersistentWithTTL(String path, long ttl)

Review Comment:
   Sorry for the confusion, I shouldn't have put the comment on this line. But I was actually asking about the sequential nodes, when I compared them I found that we have different methods for persistentWithTTL vs persistentSequentialWithTTL.



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

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] narendly commented on a diff in pull request #2090: Add TTL and Container modes to sync create API in ZkClient and ZkConnection

Posted by GitBox <gi...@apache.org>.
narendly commented on code in PR #2090:
URL: https://github.com/apache/helix/pull/2090#discussion_r870825969


##########
zookeeper-api/src/main/java/org/apache/helix/zookeeper/zkclient/ZkClient.java:
##########
@@ -728,8 +1031,14 @@ private String create(final String path, final Object dataObject, final List<ACL
       final byte[] dataBytes = dataObject == null ? null : serialize(dataObject, path);
       checkDataSizeLimit(path, dataBytes);
 
-      final String actualPath = retryUntilConnected(
-          () -> getExpectedZookeeper(expectedSessionId).create(path, dataBytes, acl, mode));
+      final String actualPath;
+      if (mode.isTTL()) {
+        actualPath = retryUntilConnected(() -> getExpectedZookeeper(expectedSessionId)
+            .create(path, dataBytes, acl, mode, new Stat(), ttl));

Review Comment:
   Do we want a new `Stat` or `null` for this? We're not doing anything with the stat object, right?



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

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org