You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@helix.apache.org by "Marcosrico (via GitHub)" <gi...@apache.org> on 2023/03/09 13:42:57 UTC

[GitHub] [helix] Marcosrico opened a new pull request, #2401: Ttlnode

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

   ### Issues
   
   - [ ] My PR addresses the following Helix issues and references them in the PR description:
   
   (#200 - Link your issue number here: You can write "Fixes #XXX". Please use the proper keyword so that the issue gets closed automatically. See https://docs.github.com/en/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue
   Any of the following keywords can be used: close, closes, closed, fix, fixes, fixed, resolve, resolves, resolved)
   
   ### Description
   
   - [ ] Here are some details about my PR, including screenshots of any UI changes:
   
   (Write a concise description including what, why, how)
   
   ### Tests
   
   - [ ] The following tests are written for this issue:
   
   (List the names of added unit/integration tests)
   
   - 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] Marcosrico commented on a diff in pull request #2401: TTL Node Lattice Implementation

Posted by "Marcosrico (via GitHub)" <gi...@apache.org>.
Marcosrico commented on code in PR #2401:
URL: https://github.com/apache/helix/pull/2401#discussion_r1134552689


##########
meta-client/src/test/java/org/apache/helix/metaclient/impl/zk/TestZkMetaClient.java:
##########
@@ -84,6 +89,40 @@ public void testCreateContainer() {
     }
   }
 
+  @Test
+  public void testCreateTTL() {
+    final String key = "/TestZkMetaClient_testTTL";
+    try (ZkMetaClient<String> zkMetaClient = createZkMetaClient()) {
+      zkMetaClient.connect();
+      zkMetaClient.createWithTTL(key, ENTRY_STRING_VALUE, 1000);
+      Assert.assertNotNull(zkMetaClient.exists(key));
+    }
+  }
+
+  @Test
+  public void testRenewTTL() {
+    final String key = "/TestZkMetaClient_testRenewTTL_1";
+    try (ZkMetaClient<String> zkMetaClient = createZkMetaClient()) {
+      zkMetaClient.connect();
+      zkMetaClient.createWithTTL(key, ENTRY_STRING_VALUE, 10000);
+      Assert.assertNotNull(zkMetaClient.exists(key));
+
+      MetaClientInterface.Stat stat = zkMetaClient.exists(key);
+
+      // Sleep for a small period of time for a bigger difference between
+      // creation and modified time.
+      Thread.sleep(5000);

Review Comment:
   Hmm it was there when I was printing statements but I guess it isn't necessary, will remove them. Thanks!



-- 
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] Marcosrico commented on a diff in pull request #2401: TTL Node Lattice Implementation

Posted by "Marcosrico (via GitHub)" <gi...@apache.org>.
Marcosrico commented on code in PR #2401:
URL: https://github.com/apache/helix/pull/2401#discussion_r1135864937


##########
meta-client/src/test/java/org/apache/helix/metaclient/impl/zk/TestZkMetaClient.java:
##########
@@ -19,12 +19,12 @@
  * under the License.
  */
 
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;

Review Comment:
   Oh that's what you meant by grouping the imports. My bad, i'll fix it, thanks!



-- 
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] Marcosrico commented on a diff in pull request #2401: TTL Node Lattice Implementation

Posted by "Marcosrico (via GitHub)" <gi...@apache.org>.
Marcosrico commented on code in PR #2401:
URL: https://github.com/apache/helix/pull/2401#discussion_r1134554958


##########
meta-client/src/main/java/org/apache/helix/metaclient/impl/zk/ZkMetaClient.java:
##########
@@ -94,12 +97,21 @@ public void create(String key, Object data, MetaClientInterface.EntryMode mode)
 
   @Override
   public void createWithTTL(String key, T data, long ttl) {
-    throw new UnsupportedOperationException("TTL nodes aren't yet supported.");
+    try{
+      _zkClient.createPersistentWithTTL(key, data, ttl);
+    } catch (ZkException e) {
+      throw translateZkExceptionToMetaclientException(e);
+    }
   }
 
   @Override
   public void renewTTLNode(String key) {
-    throw new UnsupportedOperationException("TTL nodes aren't yet supported.");
+    if (!_zkClient.exists(key)) {
+      throw new MetaClientNoNodeException("Node at path " + key + " does not exist.");
+    }
+
+    T oldData = _zkClient.readData(key, _zkClient.getStat(key));

Review Comment:
   You're right, will fix. Thanks!



-- 
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] Marcosrico commented on pull request #2401: TTL Node Lattice Implementation

Posted by "Marcosrico (via GitHub)" <gi...@apache.org>.
Marcosrico commented on PR #2401:
URL: https://github.com/apache/helix/pull/2401#issuecomment-1468468969

   This PR is ready to merge, approved by @qqu0127
   Commit message: TTL Node Lattice Implementation


-- 
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] qqu0127 commented on a diff in pull request #2401: TTL Node Lattice Implementation

Posted by "qqu0127 (via GitHub)" <gi...@apache.org>.
qqu0127 commented on code in PR #2401:
URL: https://github.com/apache/helix/pull/2401#discussion_r1135634142


##########
meta-client/src/test/java/org/apache/helix/metaclient/impl/zk/TestZkMetaClient.java:
##########
@@ -19,12 +19,12 @@
  * under the License.
  */
 
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;

Review Comment:
   Let's not use import *, fyi https://stackoverflow.com/questions/147454/why-is-using-a-wild-card-with-a-java-import-statement-bad



-- 
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] xyuanlu commented on a diff in pull request #2401: TTL Node Lattice Implementation

Posted by "xyuanlu (via GitHub)" <gi...@apache.org>.
xyuanlu commented on code in PR #2401:
URL: https://github.com/apache/helix/pull/2401#discussion_r1134472598


##########
meta-client/src/main/java/org/apache/helix/metaclient/impl/zk/ZkMetaClient.java:
##########
@@ -94,12 +97,21 @@ public void create(String key, Object data, MetaClientInterface.EntryMode mode)
 
   @Override
   public void createWithTTL(String key, T data, long ttl) {
-    throw new UnsupportedOperationException("TTL nodes aren't yet supported.");
+    try{
+      _zkClient.createPersistentWithTTL(key, data, ttl);
+    } catch (ZkException e) {
+      throw translateZkExceptionToMetaclientException(e);
+    }
   }
 
   @Override
   public void renewTTLNode(String key) {
-    throw new UnsupportedOperationException("TTL nodes aren't yet supported.");
+    if (!_zkClient.exists(key)) {
+      throw new MetaClientNoNodeException("Node at path " + key + " does not exist.");
+    }
+
+    T oldData = _zkClient.readData(key, _zkClient.getStat(key));

Review Comment:
   I think read here would validate if node exists. No need to check exists 



-- 
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] Marcosrico commented on a diff in pull request #2401: TTL Node Lattice Implementation

Posted by "Marcosrico (via GitHub)" <gi...@apache.org>.
Marcosrico commented on code in PR #2401:
URL: https://github.com/apache/helix/pull/2401#discussion_r1134541738


##########
meta-client/src/test/java/org/apache/helix/metaclient/impl/zk/TestZkMetaClient.java:
##########
@@ -38,9 +43,9 @@
 import org.apache.helix.metaclient.api.MetaClientInterface;
 import org.apache.helix.metaclient.api.Op;
 import org.apache.helix.metaclient.api.OpResult;
-import org.apache.helix.metaclient.exception.MetaClientException;
 import org.apache.helix.metaclient.impl.zk.factory.ZkMetaClientConfig;
 import org.apache.zookeeper.KeeperException;
+import org.junit.Ignore;

Review Comment:
   Yes my bad, thanks for the catch



-- 
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] xyuanlu commented on a diff in pull request #2401: TTL Node Lattice Implementation

Posted by "xyuanlu (via GitHub)" <gi...@apache.org>.
xyuanlu commented on code in PR #2401:
URL: https://github.com/apache/helix/pull/2401#discussion_r1132705474


##########
meta-client/src/main/java/org/apache/helix/metaclient/impl/zk/ZkMetaClient.java:
##########
@@ -90,12 +90,17 @@ public void create(String key, Object data, MetaClientInterface.EntryMode mode)
 
   @Override
   public void createWithTTL(String key, T data, long ttl) {
-    throw new UnsupportedOperationException("TTL nodes aren't yet supported.");
+    try{
+      _zkClient.createPersistentWithTTL(key, data, ttl);
+    } catch (ZkException e) {
+      throw translateZkExceptionToMetaclientException(e);
+    }
   }
 
+  //TODO: Implement logic for renewTTL once expiry time can be verified through testing.
   @Override
   public void renewTTLNode(String key) {
-    throw new UnsupportedOperationException("TTL nodes aren't yet supported.");
+    throw new NotImplementedException("Renew TTL node is not available yet.");

Review Comment:
   Thanks for making the change. I would still suggest implementing renewTTL and add TODO for TTL node check later when possible. 



-- 
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] Marcosrico commented on a diff in pull request #2401: TTL Node Lattice Implementation

Posted by "Marcosrico (via GitHub)" <gi...@apache.org>.
Marcosrico commented on code in PR #2401:
URL: https://github.com/apache/helix/pull/2401#discussion_r1134267056


##########
meta-client/src/main/java/org/apache/helix/metaclient/impl/zk/ZkMetaClient.java:
##########
@@ -90,12 +90,17 @@ public void create(String key, Object data, MetaClientInterface.EntryMode mode)
 
   @Override
   public void createWithTTL(String key, T data, long ttl) {
-    throw new UnsupportedOperationException("TTL nodes aren't yet supported.");
+    try{
+      _zkClient.createPersistentWithTTL(key, data, ttl);
+    } catch (ZkException e) {
+      throw translateZkExceptionToMetaclientException(e);
+    }
   }
 
+  //TODO: Implement logic for renewTTL once expiry time can be verified through testing.
   @Override
   public void renewTTLNode(String key) {
-    throw new UnsupportedOperationException("TTL nodes aren't yet supported.");
+    throw new NotImplementedException("Renew TTL node is not available yet.");

Review Comment:
   Sounds good, added the changes



-- 
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] qqu0127 commented on a diff in pull request #2401: TTL Node Lattice Implementation

Posted by "qqu0127 (via GitHub)" <gi...@apache.org>.
qqu0127 commented on code in PR #2401:
URL: https://github.com/apache/helix/pull/2401#discussion_r1134494792


##########
meta-client/src/test/java/org/apache/helix/metaclient/impl/zk/TestZkMetaClient.java:
##########
@@ -23,8 +23,13 @@
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
-import java.util.Map;
 import java.util.Set;
+
+import org.apache.helix.metaclient.api.DataUpdater;
+import org.apache.helix.metaclient.api.MetaClientInterface;
+import org.apache.helix.metaclient.exception.MetaClientException;
+import java.util.Map;

Review Comment:
   nit: it's cleaner to group java.* import together :D 



##########
meta-client/src/test/java/org/apache/helix/metaclient/impl/zk/TestZkMetaClient.java:
##########
@@ -38,9 +43,9 @@
 import org.apache.helix.metaclient.api.MetaClientInterface;
 import org.apache.helix.metaclient.api.Op;
 import org.apache.helix.metaclient.api.OpResult;
-import org.apache.helix.metaclient.exception.MetaClientException;
 import org.apache.helix.metaclient.impl.zk.factory.ZkMetaClientConfig;
 import org.apache.zookeeper.KeeperException;
+import org.junit.Ignore;

Review Comment:
   Unused import?



##########
meta-client/src/test/java/org/apache/helix/metaclient/impl/zk/TestZkMetaClient.java:
##########
@@ -84,6 +89,40 @@ public void testCreateContainer() {
     }
   }
 
+  @Test
+  public void testCreateTTL() {
+    final String key = "/TestZkMetaClient_testTTL";
+    try (ZkMetaClient<String> zkMetaClient = createZkMetaClient()) {
+      zkMetaClient.connect();
+      zkMetaClient.createWithTTL(key, ENTRY_STRING_VALUE, 1000);
+      Assert.assertNotNull(zkMetaClient.exists(key));
+    }
+  }
+
+  @Test
+  public void testRenewTTL() {
+    final String key = "/TestZkMetaClient_testRenewTTL_1";
+    try (ZkMetaClient<String> zkMetaClient = createZkMetaClient()) {
+      zkMetaClient.connect();
+      zkMetaClient.createWithTTL(key, ENTRY_STRING_VALUE, 10000);
+      Assert.assertNotNull(zkMetaClient.exists(key));
+
+      MetaClientInterface.Stat stat = zkMetaClient.exists(key);
+
+      // Sleep for a small period of time for a bigger difference between
+      // creation and modified time.
+      Thread.sleep(5000);

Review Comment:
   Is this necessary for testing?



-- 
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] xyuanlu merged pull request #2401: TTL Node Lattice Implementation

Posted by "xyuanlu (via GitHub)" <gi...@apache.org>.
xyuanlu merged PR #2401:
URL: https://github.com/apache/helix/pull/2401


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