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/12/23 17:20:44 UTC
[GitHub] [helix] Marcosrico opened a new pull request, #2328: Multi Implementation and Test Cases
Marcosrico opened a new pull request, #2328:
URL: https://github.com/apache/helix/pull/2328
### Issues
- [x] My PR addresses the following Helix issues and references them in the PR description:
https://github.com/apache/helix/issues/2240
### Description
- [x] Here are some details about my PR, including screenshots of any UI changes:
Implemented the logic for zk.multi to enable zk transactional support.
### Tests
- [x] The following tests are written for this issue:
Wrote test cases to test transactional support in all clients (dedicated, shared, and federated).
- [x] The following is the result of the "mvn test" command on the appropriate module:
### Code Quality
- [x] 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] xyuanlu merged pull request #2328: Multi Implementation and Test Cases
Posted by GitBox <gi...@apache.org>.
xyuanlu merged PR #2328:
URL: https://github.com/apache/helix/pull/2328
--
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 #2328: Multi Implementation and Test Cases
Posted by GitBox <gi...@apache.org>.
xyuanlu commented on code in PR #2328:
URL: https://github.com/apache/helix/pull/2328#discussion_r1063669211
##########
zookeeper-api/src/test/java/org/apache/helix/zookeeper/impl/client/RealmAwareZkClientTestBase.java:
##########
@@ -67,4 +76,127 @@ public void afterClass() {
_msdsServer.stopServer();
}
}
-}
+ /**
+ * Initialize requirement for testing multi support.
+ */
+ @Test
+ public void testMultiSetup() {
+ // Create a connection config with a valid sharding key
+ RealmAwareZkClient.RealmAwareZkConnectionConfig.Builder builder =
+ new RealmAwareZkClient.RealmAwareZkConnectionConfig.Builder();
+ RealmAwareZkClient.RealmAwareZkConnectionConfig connectionConfig =
+ builder.setZkRealmShardingKey(ZK_SHARDING_KEY_PREFIX).build();
+ try {
+ _realmAwareZkClient = new FederatedZkClient(connectionConfig,
+ new RealmAwareZkClient.RealmAwareZkClientConfig());
+ } catch (IllegalArgumentException e) {
+ Assert.fail("Invalid Sharding Key.");
+ } catch (Exception e) {
Review Comment:
If you want to integrate these two, then you can just catch `Exception ` since `IllegalArgumentException` is a subclass of general `Exception ` ( https://docs.oracle.com/javase/7/docs/api/java/lang/IllegalArgumentException.html)
Throw the unexpected exception also work as the stack trace will contain enough info.
In my opinion both work.
--
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] rahulrane50 commented on a diff in pull request #2328: Multi Implementation and Test Cases
Posted by GitBox <gi...@apache.org>.
rahulrane50 commented on code in PR #2328:
URL: https://github.com/apache/helix/pull/2328#discussion_r1056554655
##########
zookeeper-api/src/main/java/org/apache/helix/zookeeper/impl/client/FederatedZkClient.java:
##########
@@ -477,10 +477,31 @@ public long getCreationTime(String path) {
return getZkClient(path).getCreationTime(path);
}
+ /**
+ * Executes ZkMulti on operations that are connected to the same Zk server.
+ * Will throw exception if any operation's server connection is different.
+ * @param ops
+ * @return
+ * @throws IllegalArgumentException
+ */
@Override
public List<OpResult> multi(Iterable<Op> ops) {
- throwUnsupportedOperationException();
- return null;
+ if (ops == null) {
+ throw new NullPointerException("ops must not be null.");
+ }
+ String opPath = null;
+ String opPathRealm = null;
+ for (Op op : ops) {
+ if (opPath == null) {
+ opPath = op.getPath();
+ opPathRealm = getZkRealm(op.getPath());
+ } else {
+ if (!opPathRealm.equals(getZkRealm(op.getPath()))){
+ throw new IllegalArgumentException("Cannot execute multi on ops of different realms!");
+ }
+ }
+ }
+ return getZkClient(opPath).multi(ops);
Review Comment:
also this getZkClient might fail if none of the ops in provided list have valid opPath right?
##########
zookeeper-api/src/main/java/org/apache/helix/zookeeper/impl/client/FederatedZkClient.java:
##########
@@ -477,10 +477,31 @@ public long getCreationTime(String path) {
return getZkClient(path).getCreationTime(path);
}
+ /**
+ * Executes ZkMulti on operations that are connected to the same Zk server.
+ * Will throw exception if any operation's server connection is different.
+ * @param ops
+ * @return
+ * @throws IllegalArgumentException
+ */
@Override
public List<OpResult> multi(Iterable<Op> ops) {
- throwUnsupportedOperationException();
- return null;
+ if (ops == null) {
+ throw new NullPointerException("ops must not be null.");
+ }
+ String opPath = null;
+ String opPathRealm = null;
+ for (Op op : ops) {
+ if (opPath == null) {
+ opPath = op.getPath();
+ opPathRealm = getZkRealm(op.getPath());
Review Comment:
Neat: we already got opPath on line 496, can we re-use it here?
##########
zookeeper-api/src/test/java/org/apache/helix/zookeeper/impl/client/RealmAwareZkClientTestBase.java:
##########
@@ -67,4 +76,127 @@ public void afterClass() {
_msdsServer.stopServer();
}
}
-}
+ /**
+ * Initialize requirement for testing multi support.
+ */
+ @Test
+ public void testMulti() {
+ // Create a connection config with a valid sharding key
+ RealmAwareZkClient.RealmAwareZkConnectionConfig.Builder builder =
+ new RealmAwareZkClient.RealmAwareZkConnectionConfig.Builder();
+ RealmAwareZkClient.RealmAwareZkConnectionConfig connectionConfig =
+ builder.setZkRealmShardingKey(ZK_SHARDING_KEY_PREFIX).build();
+ try {
+ _realmAwareZkClient = new FederatedZkClient(connectionConfig,
+ new RealmAwareZkClient.RealmAwareZkClientConfig());
+ } catch (IllegalArgumentException e) {
+ Assert.fail("Invalid Sharding Key.");
+ } catch (Exception e) {
+ Assert.fail("Should not see any other types of Exceptions: " + e);
+ }
+ }
+
+ /**
+ * Test that zk multi works for create.
+ */
+ @Test(dependsOnMethods = "testMulti")
+ public void testMultiCreate() {
+ String test_name = "/test_multi_create";
+
+ //Create Nodes
+ List<Op> ops = Arrays.asList(
+ Op.create(PARENT_PATH, new byte[0],
+ ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT),
+ Op.create(PARENT_PATH + test_name, new byte[0],
+ ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT));
+
+ //Execute transactional support on operations and verify they were run
+ List<OpResult> opResults = _realmAwareZkClient.multi(ops);
+ Assert.assertTrue(opResults.get(0) instanceof OpResult.CreateResult);
+ Assert.assertTrue(opResults.get(1) instanceof OpResult.CreateResult);
+
+ cleanup();
+ }
+
+ /**
+ * Multi should be an all or nothing transaction. Creating correct
+ * paths and a singular bad one should all fail.
+ */
+ @Test(dependsOnMethods = "testMultiCreate")
Review Comment:
Curious, why does it depends on "testMultiCreate"?
##########
zookeeper-api/src/main/java/org/apache/helix/zookeeper/impl/client/FederatedZkClient.java:
##########
@@ -477,10 +477,31 @@ public long getCreationTime(String path) {
return getZkClient(path).getCreationTime(path);
}
+ /**
+ * Executes ZkMulti on operations that are connected to the same Zk server.
+ * Will throw exception if any operation's server connection is different.
+ * @param ops
+ * @return
+ * @throws IllegalArgumentException
+ */
@Override
public List<OpResult> multi(Iterable<Op> ops) {
- throwUnsupportedOperationException();
- return null;
+ if (ops == null) {
+ throw new NullPointerException("ops must not be null.");
+ }
+ String opPath = null;
+ String opPathRealm = null;
+ for (Op op : ops) {
Review Comment:
From my understanding of code, in this for loop you want to filter ops who have same ZkRealm. Just wondering if there could be case where first few ops in given ops list won't have any realm but later ones have it. In that case, here even those first few ops will be sent for "multi" operation right? Should we use any lambda filter method which filters out all ops with same ZkRealm.
--
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 #2328: Multi Implementation and Test Cases
Posted by GitBox <gi...@apache.org>.
Marcosrico commented on code in PR #2328:
URL: https://github.com/apache/helix/pull/2328#discussion_r1063666261
##########
zookeeper-api/src/test/java/org/apache/helix/zookeeper/impl/client/RealmAwareZkClientTestBase.java:
##########
@@ -67,4 +76,127 @@ public void afterClass() {
_msdsServer.stopServer();
}
}
-}
+ /**
+ * Initialize requirement for testing multi support.
+ */
+ @Test
+ public void testMultiSetup() {
+ // Create a connection config with a valid sharding key
+ RealmAwareZkClient.RealmAwareZkConnectionConfig.Builder builder =
+ new RealmAwareZkClient.RealmAwareZkConnectionConfig.Builder();
+ RealmAwareZkClient.RealmAwareZkConnectionConfig connectionConfig =
+ builder.setZkRealmShardingKey(ZK_SHARDING_KEY_PREFIX).build();
+ try {
+ _realmAwareZkClient = new FederatedZkClient(connectionConfig,
+ new RealmAwareZkClient.RealmAwareZkClientConfig());
+ } catch (IllegalArgumentException e) {
+ Assert.fail("Invalid Sharding Key.");
+ } catch (Exception e) {
Review Comment:
Good point. I am not sure what the general convention was, but for test cases do we want to throw the original exception or catch it and fail with a clearer debug message?
--
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 #2328: Multi Implementation and Test Cases
Posted by GitBox <gi...@apache.org>.
Marcosrico commented on code in PR #2328:
URL: https://github.com/apache/helix/pull/2328#discussion_r1056618635
##########
zookeeper-api/src/main/java/org/apache/helix/zookeeper/impl/client/FederatedZkClient.java:
##########
@@ -477,10 +477,31 @@ public long getCreationTime(String path) {
return getZkClient(path).getCreationTime(path);
}
+ /**
+ * Executes ZkMulti on operations that are connected to the same Zk server.
+ * Will throw exception if any operation's server connection is different.
+ * @param ops
+ * @return
+ * @throws IllegalArgumentException
+ */
@Override
public List<OpResult> multi(Iterable<Op> ops) {
- throwUnsupportedOperationException();
- return null;
+ if (ops == null) {
+ throw new NullPointerException("ops must not be null.");
+ }
+ String opPath = null;
+ String opPathRealm = null;
+ for (Op op : ops) {
Review Comment:
I think an op must have a ZkRealm in order to be valid. Trying to get the path of an op with no ZkRealm would throw an error (in `TrieRoutingData.getMetadataStoreRealm()`) and so the multi operation won't succeed.
--
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 #2328: Multi Implementation and Test Cases
Posted by GitBox <gi...@apache.org>.
Marcosrico commented on PR #2328:
URL: https://github.com/apache/helix/pull/2328#issuecomment-1376162347
This PR is ready to merge, approved by @xyuanlu and @rahulrane50
Commit message:
Federated Zk Client Multi implementation for Zk transactional support.
--
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 #2328: Multi Implementation and Test Cases
Posted by GitBox <gi...@apache.org>.
qqu0127 commented on code in PR #2328:
URL: https://github.com/apache/helix/pull/2328#discussion_r1061711963
##########
helix-core/src/test/java/org/apache/helix/integration/multizk/TestMultiInMultiZk.java:
##########
@@ -63,6 +63,7 @@ public void beforeClass() throws Exception {
System.out.println(elm);
}
}
+ System.out.println("end start");
Review Comment:
Can we remove this?
##########
helix-core/src/test/java/org/apache/helix/integration/multizk/TestMultiZkHelixJavaApis.java:
##########
@@ -72,7 +78,7 @@
* cluster-Zk realm routing information.
* This test verifies that all Helix Java APIs work as expected.
*/
-public class TestMultiZkHelixJavaApis extends TestMultiZkConnectionConfig {
+public abstract class TestMultiZkHelixJavaApis extends TestMultiZkConnectionConfig {
Review Comment:
has this been resolved yet?
--
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 #2328: Multi Implementation and Test Cases
Posted by GitBox <gi...@apache.org>.
xyuanlu commented on code in PR #2328:
URL: https://github.com/apache/helix/pull/2328#discussion_r1063835557
##########
zookeeper-api/src/test/java/org/apache/helix/zookeeper/impl/client/RealmAwareZkClientTestBase.java:
##########
@@ -67,4 +76,132 @@ public void afterClass() {
_msdsServer.stopServer();
}
}
-}
+ /**
+ * Initialize requirement for testing multi support.
+ */
+ @Test
+ public void testMultiSetup() throws InvalidRoutingDataException {
+ // Create a connection config with a valid sharding key
+ RealmAwareZkClient.RealmAwareZkConnectionConfig.Builder builder =
+ new RealmAwareZkClient.RealmAwareZkConnectionConfig.Builder();
+ RealmAwareZkClient.RealmAwareZkConnectionConfig connectionConfig =
+ builder.setZkRealmShardingKey(ZK_SHARDING_KEY_PREFIX).build();
+
+ _realmAwareZkClient = new FederatedZkClient(connectionConfig,
+ new RealmAwareZkClient.RealmAwareZkClientConfig());
+ }
+
+ /**
+ * Test that zk multi works for create.
+ */
+ @Test(dependsOnMethods = "testMultiSetup")
+ public void testMultiCreate() {
+ String test_name = "/test_multi_create";
+
+ //Create Nodes
+ List<Op> ops = Arrays.asList(
+ Op.create(PARENT_PATH, new byte[0],
+ ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT),
+ Op.create(PARENT_PATH + test_name, new byte[0],
+ ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT));
+
+ //Execute transactional support on operations and verify they were run
+ List<OpResult> opResults = _realmAwareZkClient.multi(ops);
+ Assert.assertTrue(opResults.get(0) instanceof OpResult.CreateResult);
+ Assert.assertTrue(opResults.get(1) instanceof OpResult.CreateResult);
+
+ //Verify that the znodes were created
+ Assert.assertTrue(_realmAwareZkClient.exists(PARENT_PATH), "Path has not been created.");
+ Assert.assertTrue(_realmAwareZkClient.exists(PARENT_PATH + test_name), "Path has not been created.");
+
+ cleanup();
+ }
+
+ /**
+ * Multi should be an all or nothing transaction. Creating correct
+ * paths and a singular bad one should all fail.
+ */
+ @Test(dependsOnMethods = "testMultiCreate")
+ public void testMultiFail() {
+ String test_name = "/test_multi_fail";
+ //Create Nodes
+ List<Op> ops = Arrays.asList(
+ Op.create(PARENT_PATH, new byte[0],
+ ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT),
+ Op.create(PARENT_PATH + test_name, new byte[0],
+ ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT),
+ Op.create(TEST_INVALID_PATH, new byte[0],
+ ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT));
+ try {
+ _realmAwareZkClient.multi(ops);
+ Assert.fail("Should have thrown an exception. Cannot run multi on incorrect path.");
+ } catch (Exception e) {
+ boolean pathExists = _realmAwareZkClient.exists(PARENT_PATH);
+ Assert.assertFalse(pathExists, "Path should not have been created.");
+
+ cleanup();
+ }
+ }
+
+ /**
+ * Test that zk multi works for delete.
+ */
+ @Test(dependsOnMethods = "testMultiFail")
+ public void testMultiDelete() {
+ String test_name = "/test_multi_delete";
+ //Create Nodes
+ List<Op> ops = Arrays.asList(
+ Op.create(PARENT_PATH, new byte[0],
+ ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT),
+ Op.create(PARENT_PATH + test_name, new byte[0],
+ ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT),
+ Op.delete(PARENT_PATH + test_name, -1));
+
+ List<OpResult> opResults = _realmAwareZkClient.multi(ops);
+ Assert.assertTrue(opResults.get(0) instanceof OpResult.CreateResult);
+ Assert.assertTrue(opResults.get(1) instanceof OpResult.CreateResult);
+ Assert.assertTrue(opResults.get(2) instanceof OpResult.DeleteResult);
+
+ Assert.assertTrue(_realmAwareZkClient.exists(PARENT_PATH), "Path has not been created.");
+ Assert.assertFalse(_realmAwareZkClient.exists(PARENT_PATH + test_name), "Path should have been removed.");
Review Comment:
I guess the message should be the opposite?
--
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 #2328: Multi Implementation and Test Cases
Posted by GitBox <gi...@apache.org>.
Marcosrico commented on code in PR #2328:
URL: https://github.com/apache/helix/pull/2328#discussion_r1061758168
##########
zookeeper-api/src/main/java/org/apache/helix/zookeeper/impl/client/FederatedZkClient.java:
##########
@@ -477,10 +477,31 @@ public long getCreationTime(String path) {
return getZkClient(path).getCreationTime(path);
}
+ /**
+ * Executes ZkMulti on operations that are connected to the same Zk server.
+ * Will throw exception if any operation's server connection is different.
+ * @param ops
+ * @return
+ * @throws IllegalArgumentException
+ */
@Override
public List<OpResult> multi(Iterable<Op> ops) {
- throwUnsupportedOperationException();
- return null;
+ if (ops == null) {
+ throw new NullPointerException("ops must not be null.");
+ }
+ String opPath = null;
+ String opPathRealm = null;
+ for (Op op : ops) {
Review Comment:
Thanks for the suggestion! The solution looks cleaner and while my past solution might fail early, the cost of getting the zkrealm is minimum. I modified your implementation slightly, let me know if it looks good!
--
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 #2328: Multi Implementation and Test Cases
Posted by GitBox <gi...@apache.org>.
xyuanlu commented on code in PR #2328:
URL: https://github.com/apache/helix/pull/2328#discussion_r1061805673
##########
zookeeper-api/src/test/java/org/apache/helix/zookeeper/impl/client/RealmAwareZkClientTestBase.java:
##########
@@ -67,4 +76,127 @@ public void afterClass() {
_msdsServer.stopServer();
}
}
-}
+ /**
+ * Initialize requirement for testing multi support.
+ */
+ @Test
+ public void testMulti() {
+ // Create a connection config with a valid sharding key
+ RealmAwareZkClient.RealmAwareZkConnectionConfig.Builder builder =
+ new RealmAwareZkClient.RealmAwareZkConnectionConfig.Builder();
+ RealmAwareZkClient.RealmAwareZkConnectionConfig connectionConfig =
+ builder.setZkRealmShardingKey(ZK_SHARDING_KEY_PREFIX).build();
+ try {
+ _realmAwareZkClient = new FederatedZkClient(connectionConfig,
+ new RealmAwareZkClient.RealmAwareZkClientConfig());
+ } catch (IllegalArgumentException e) {
+ Assert.fail("Invalid Sharding Key.");
+ } catch (Exception e) {
+ Assert.fail("Should not see any other types of Exceptions: " + e);
Review Comment:
If this test class is only for setting up test env, I would suggest a better 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] Marcosrico commented on a diff in pull request #2328: Multi Implementation and Test Cases
Posted by GitBox <gi...@apache.org>.
Marcosrico commented on code in PR #2328:
URL: https://github.com/apache/helix/pull/2328#discussion_r1056619386
##########
zookeeper-api/src/main/java/org/apache/helix/zookeeper/impl/client/FederatedZkClient.java:
##########
@@ -477,10 +477,31 @@ public long getCreationTime(String path) {
return getZkClient(path).getCreationTime(path);
}
+ /**
+ * Executes ZkMulti on operations that are connected to the same Zk server.
+ * Will throw exception if any operation's server connection is different.
+ * @param ops
+ * @return
+ * @throws IllegalArgumentException
+ */
@Override
public List<OpResult> multi(Iterable<Op> ops) {
- throwUnsupportedOperationException();
- return null;
+ if (ops == null) {
+ throw new NullPointerException("ops must not be null.");
+ }
+ String opPath = null;
+ String opPathRealm = null;
+ for (Op op : ops) {
+ if (opPath == null) {
+ opPath = op.getPath();
+ opPathRealm = getZkRealm(op.getPath());
+ } else {
+ if (!opPathRealm.equals(getZkRealm(op.getPath()))){
+ throw new IllegalArgumentException("Cannot execute multi on ops of different realms!");
+ }
+ }
+ }
+ return getZkClient(opPath).multi(ops);
Review Comment:
getZkRealm() method checks whether the input path is a valid opPath so it would fail before entering this call. Perhaps we should write a catch / throw clause in the case that occurs?
--
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 #2328: Multi Implementation and Test Cases
Posted by GitBox <gi...@apache.org>.
mgao0 commented on code in PR #2328:
URL: https://github.com/apache/helix/pull/2328#discussion_r1056688265
##########
helix-core/src/test/java/org/apache/helix/integration/multizk/TestMultiZkHelixJavaApis.java:
##########
@@ -72,7 +78,7 @@
* cluster-Zk realm routing information.
* This test verifies that all Helix Java APIs work as expected.
*/
-public class TestMultiZkHelixJavaApis extends TestMultiZkConnectionConfig {
+public abstract class TestMultiZkHelixJavaApis extends TestMultiZkConnectionConfig {
Review Comment:
Could you please explain what is the purpose of making this class abstract?
##########
zookeeper-api/src/main/java/org/apache/helix/zookeeper/impl/client/FederatedZkClient.java:
##########
@@ -477,10 +477,31 @@ public long getCreationTime(String path) {
return getZkClient(path).getCreationTime(path);
}
+ /**
+ * Executes ZkMulti on operations that are connected to the same Zk server.
+ * Will throw exception if any operation's server connection is different.
+ * @param ops
+ * @return
+ * @throws IllegalArgumentException
+ */
@Override
public List<OpResult> multi(Iterable<Op> ops) {
- throwUnsupportedOperationException();
- return null;
+ if (ops == null) {
+ throw new NullPointerException("ops must not be null.");
+ }
+ String opPath = null;
+ String opPathRealm = null;
+ for (Op op : ops) {
Review Comment:
I'll suggest to implement this logic like this
`realms = ops.stream()
.map(op -> getZkRealm(op.getPath()))
.distinct()
.collect(toList());`
`if (realms.size() == 1) {
....
} else {
....
}`
This might be a cleaner solution from the code aspect, but your implementation maybe able to fail early if there are different realms. Just a thought, you can think about the trade-offs.
--
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 #2328: Multi Implementation and Test Cases
Posted by GitBox <gi...@apache.org>.
Marcosrico commented on code in PR #2328:
URL: https://github.com/apache/helix/pull/2328#discussion_r1063545627
##########
zookeeper-api/src/test/java/org/apache/helix/zookeeper/impl/client/RealmAwareZkClientTestBase.java:
##########
@@ -67,4 +76,127 @@ public void afterClass() {
_msdsServer.stopServer();
}
}
-}
+ /**
+ * Initialize requirement for testing multi support.
+ */
+ @Test
+ public void testMultiSetup() {
+ // Create a connection config with a valid sharding key
+ RealmAwareZkClient.RealmAwareZkConnectionConfig.Builder builder =
+ new RealmAwareZkClient.RealmAwareZkConnectionConfig.Builder();
+ RealmAwareZkClient.RealmAwareZkConnectionConfig connectionConfig =
+ builder.setZkRealmShardingKey(ZK_SHARDING_KEY_PREFIX).build();
+ try {
+ _realmAwareZkClient = new FederatedZkClient(connectionConfig,
+ new RealmAwareZkClient.RealmAwareZkClientConfig());
+ } catch (IllegalArgumentException e) {
+ Assert.fail("Invalid Sharding Key.");
+ } catch (Exception e) {
Review Comment:
how would you integrate both? Each catch is to specify a different error origin
--
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 #2328: Multi Implementation and Test Cases
Posted by GitBox <gi...@apache.org>.
Marcosrico commented on code in PR #2328:
URL: https://github.com/apache/helix/pull/2328#discussion_r1063666261
##########
zookeeper-api/src/test/java/org/apache/helix/zookeeper/impl/client/RealmAwareZkClientTestBase.java:
##########
@@ -67,4 +76,127 @@ public void afterClass() {
_msdsServer.stopServer();
}
}
-}
+ /**
+ * Initialize requirement for testing multi support.
+ */
+ @Test
+ public void testMultiSetup() {
+ // Create a connection config with a valid sharding key
+ RealmAwareZkClient.RealmAwareZkConnectionConfig.Builder builder =
+ new RealmAwareZkClient.RealmAwareZkConnectionConfig.Builder();
+ RealmAwareZkClient.RealmAwareZkConnectionConfig connectionConfig =
+ builder.setZkRealmShardingKey(ZK_SHARDING_KEY_PREFIX).build();
+ try {
+ _realmAwareZkClient = new FederatedZkClient(connectionConfig,
+ new RealmAwareZkClient.RealmAwareZkClientConfig());
+ } catch (IllegalArgumentException e) {
+ Assert.fail("Invalid Sharding Key.");
+ } catch (Exception e) {
Review Comment:
Good point. I am not sure what the general convention is, but for test cases do we want to throw the original exception or catch it and fail with a clearer debug message?
--
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 #2328: Multi Implementation and Test Cases
Posted by GitBox <gi...@apache.org>.
Marcosrico commented on code in PR #2328:
URL: https://github.com/apache/helix/pull/2328#discussion_r1063671368
##########
zookeeper-api/src/test/java/org/apache/helix/zookeeper/impl/client/RealmAwareZkClientTestBase.java:
##########
@@ -67,4 +76,127 @@ public void afterClass() {
_msdsServer.stopServer();
}
}
-}
+ /**
+ * Initialize requirement for testing multi support.
+ */
+ @Test
+ public void testMultiSetup() {
+ // Create a connection config with a valid sharding key
+ RealmAwareZkClient.RealmAwareZkConnectionConfig.Builder builder =
+ new RealmAwareZkClient.RealmAwareZkConnectionConfig.Builder();
+ RealmAwareZkClient.RealmAwareZkConnectionConfig connectionConfig =
+ builder.setZkRealmShardingKey(ZK_SHARDING_KEY_PREFIX).build();
+ try {
+ _realmAwareZkClient = new FederatedZkClient(connectionConfig,
+ new RealmAwareZkClient.RealmAwareZkClientConfig());
+ } catch (IllegalArgumentException e) {
+ Assert.fail("Invalid Sharding Key.");
+ } catch (Exception e) {
Review Comment:
Sound good, I think think I'll have the exceptions be thrown without catching them then. Thank you for the input!
--
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 #2328: Multi Implementation and Test Cases
Posted by GitBox <gi...@apache.org>.
xyuanlu commented on code in PR #2328:
URL: https://github.com/apache/helix/pull/2328#discussion_r1062797854
##########
zookeeper-api/src/test/java/org/apache/helix/zookeeper/impl/client/RealmAwareZkClientTestBase.java:
##########
@@ -67,4 +76,127 @@ public void afterClass() {
_msdsServer.stopServer();
}
}
-}
+ /**
+ * Initialize requirement for testing multi support.
+ */
+ @Test
+ public void testMultiSetup() {
+ // Create a connection config with a valid sharding key
+ RealmAwareZkClient.RealmAwareZkConnectionConfig.Builder builder =
+ new RealmAwareZkClient.RealmAwareZkConnectionConfig.Builder();
+ RealmAwareZkClient.RealmAwareZkConnectionConfig connectionConfig =
+ builder.setZkRealmShardingKey(ZK_SHARDING_KEY_PREFIX).build();
+ try {
+ _realmAwareZkClient = new FederatedZkClient(connectionConfig,
+ new RealmAwareZkClient.RealmAwareZkClientConfig());
+ } catch (IllegalArgumentException e) {
+ Assert.fail("Invalid Sharding Key.");
+ } catch (Exception e) {
+ Assert.fail("Should not see any other types of Exceptions: " + e);
+ }
+ }
+
+ /**
+ * Test that zk multi works for create.
+ */
+ @Test(dependsOnMethods = "testMultiSetup")
+ public void testMultiCreate() {
+ String test_name = "/test_multi_create";
+
+ //Create Nodes
+ List<Op> ops = Arrays.asList(
+ Op.create(PARENT_PATH, new byte[0],
+ ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT),
+ Op.create(PARENT_PATH + test_name, new byte[0],
+ ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT));
+
+ //Execute transactional support on operations and verify they were run
+ List<OpResult> opResults = _realmAwareZkClient.multi(ops);
+ Assert.assertTrue(opResults.get(0) instanceof OpResult.CreateResult);
+ Assert.assertTrue(opResults.get(1) instanceof OpResult.CreateResult);
+
Review Comment:
We probably want to check if all znodes are actually created as well. Same with all following tests.
--
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 #2328: Multi Implementation and Test Cases
Posted by GitBox <gi...@apache.org>.
xyuanlu commented on code in PR #2328:
URL: https://github.com/apache/helix/pull/2328#discussion_r1062796974
##########
zookeeper-api/src/test/java/org/apache/helix/zookeeper/impl/client/RealmAwareZkClientTestBase.java:
##########
@@ -67,4 +76,127 @@ public void afterClass() {
_msdsServer.stopServer();
}
}
-}
+ /**
+ * Initialize requirement for testing multi support.
+ */
+ @Test
+ public void testMultiSetup() {
+ // Create a connection config with a valid sharding key
+ RealmAwareZkClient.RealmAwareZkConnectionConfig.Builder builder =
+ new RealmAwareZkClient.RealmAwareZkConnectionConfig.Builder();
+ RealmAwareZkClient.RealmAwareZkConnectionConfig connectionConfig =
+ builder.setZkRealmShardingKey(ZK_SHARDING_KEY_PREFIX).build();
+ try {
+ _realmAwareZkClient = new FederatedZkClient(connectionConfig,
+ new RealmAwareZkClient.RealmAwareZkClientConfig());
+ } catch (IllegalArgumentException e) {
+ Assert.fail("Invalid Sharding Key.");
+ } catch (Exception e) {
Review Comment:
can we integrate these 2 catches?
--
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 #2328: Multi Implementation and Test Cases
Posted by GitBox <gi...@apache.org>.
Marcosrico commented on code in PR #2328:
URL: https://github.com/apache/helix/pull/2328#discussion_r1063839802
##########
zookeeper-api/src/test/java/org/apache/helix/zookeeper/impl/client/RealmAwareZkClientTestBase.java:
##########
@@ -67,4 +76,132 @@ public void afterClass() {
_msdsServer.stopServer();
}
}
-}
+ /**
+ * Initialize requirement for testing multi support.
+ */
+ @Test
+ public void testMultiSetup() throws InvalidRoutingDataException {
+ // Create a connection config with a valid sharding key
+ RealmAwareZkClient.RealmAwareZkConnectionConfig.Builder builder =
+ new RealmAwareZkClient.RealmAwareZkConnectionConfig.Builder();
+ RealmAwareZkClient.RealmAwareZkConnectionConfig connectionConfig =
+ builder.setZkRealmShardingKey(ZK_SHARDING_KEY_PREFIX).build();
+
+ _realmAwareZkClient = new FederatedZkClient(connectionConfig,
+ new RealmAwareZkClient.RealmAwareZkClientConfig());
+ }
+
+ /**
+ * Test that zk multi works for create.
+ */
+ @Test(dependsOnMethods = "testMultiSetup")
+ public void testMultiCreate() {
+ String test_name = "/test_multi_create";
+
+ //Create Nodes
+ List<Op> ops = Arrays.asList(
+ Op.create(PARENT_PATH, new byte[0],
+ ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT),
+ Op.create(PARENT_PATH + test_name, new byte[0],
+ ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT));
+
+ //Execute transactional support on operations and verify they were run
+ List<OpResult> opResults = _realmAwareZkClient.multi(ops);
+ Assert.assertTrue(opResults.get(0) instanceof OpResult.CreateResult);
+ Assert.assertTrue(opResults.get(1) instanceof OpResult.CreateResult);
+
+ //Verify that the znodes were created
+ Assert.assertTrue(_realmAwareZkClient.exists(PARENT_PATH), "Path has not been created.");
+ Assert.assertTrue(_realmAwareZkClient.exists(PARENT_PATH + test_name), "Path has not been created.");
+
+ cleanup();
+ }
+
+ /**
+ * Multi should be an all or nothing transaction. Creating correct
+ * paths and a singular bad one should all fail.
+ */
+ @Test(dependsOnMethods = "testMultiCreate")
+ public void testMultiFail() {
+ String test_name = "/test_multi_fail";
+ //Create Nodes
+ List<Op> ops = Arrays.asList(
+ Op.create(PARENT_PATH, new byte[0],
+ ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT),
+ Op.create(PARENT_PATH + test_name, new byte[0],
+ ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT),
+ Op.create(TEST_INVALID_PATH, new byte[0],
+ ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT));
+ try {
+ _realmAwareZkClient.multi(ops);
+ Assert.fail("Should have thrown an exception. Cannot run multi on incorrect path.");
+ } catch (Exception e) {
+ boolean pathExists = _realmAwareZkClient.exists(PARENT_PATH);
+ Assert.assertFalse(pathExists, "Path should not have been created.");
+
+ cleanup();
+ }
+ }
+
+ /**
+ * Test that zk multi works for delete.
+ */
+ @Test(dependsOnMethods = "testMultiFail")
+ public void testMultiDelete() {
+ String test_name = "/test_multi_delete";
+ //Create Nodes
+ List<Op> ops = Arrays.asList(
+ Op.create(PARENT_PATH, new byte[0],
+ ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT),
+ Op.create(PARENT_PATH + test_name, new byte[0],
+ ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT),
+ Op.delete(PARENT_PATH + test_name, -1));
+
+ List<OpResult> opResults = _realmAwareZkClient.multi(ops);
+ Assert.assertTrue(opResults.get(0) instanceof OpResult.CreateResult);
+ Assert.assertTrue(opResults.get(1) instanceof OpResult.CreateResult);
+ Assert.assertTrue(opResults.get(2) instanceof OpResult.DeleteResult);
+
+ Assert.assertTrue(_realmAwareZkClient.exists(PARENT_PATH), "Path has not been created.");
+ Assert.assertFalse(_realmAwareZkClient.exists(PARENT_PATH + test_name), "Path should have been removed.");
Review Comment:
I think the message only shows when the condition isn't true. For example, if PARENT_PATH does not exist, then it would error with "Path has not been created"
--
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 #2328: Multi Implementation and Test Cases
Posted by GitBox <gi...@apache.org>.
Marcosrico commented on code in PR #2328:
URL: https://github.com/apache/helix/pull/2328#discussion_r1061729205
##########
helix-core/src/test/java/org/apache/helix/integration/multizk/TestMultiInMultiZk.java:
##########
@@ -63,6 +63,7 @@ public void beforeClass() throws Exception {
System.out.println(elm);
}
}
+ System.out.println("end start");
Review Comment:
Yup!
--
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 #2328: Multi Implementation and Test Cases
Posted by GitBox <gi...@apache.org>.
Marcosrico commented on code in PR #2328:
URL: https://github.com/apache/helix/pull/2328#discussion_r1056620097
##########
zookeeper-api/src/test/java/org/apache/helix/zookeeper/impl/client/RealmAwareZkClientTestBase.java:
##########
@@ -67,4 +76,127 @@ public void afterClass() {
_msdsServer.stopServer();
}
}
-}
+ /**
+ * Initialize requirement for testing multi support.
+ */
+ @Test
+ public void testMulti() {
+ // Create a connection config with a valid sharding key
+ RealmAwareZkClient.RealmAwareZkConnectionConfig.Builder builder =
+ new RealmAwareZkClient.RealmAwareZkConnectionConfig.Builder();
+ RealmAwareZkClient.RealmAwareZkConnectionConfig connectionConfig =
+ builder.setZkRealmShardingKey(ZK_SHARDING_KEY_PREFIX).build();
+ try {
+ _realmAwareZkClient = new FederatedZkClient(connectionConfig,
+ new RealmAwareZkClient.RealmAwareZkClientConfig());
+ } catch (IllegalArgumentException e) {
+ Assert.fail("Invalid Sharding Key.");
+ } catch (Exception e) {
+ Assert.fail("Should not see any other types of Exceptions: " + e);
+ }
+ }
+
+ /**
+ * Test that zk multi works for create.
+ */
+ @Test(dependsOnMethods = "testMulti")
+ public void testMultiCreate() {
+ String test_name = "/test_multi_create";
+
+ //Create Nodes
+ List<Op> ops = Arrays.asList(
+ Op.create(PARENT_PATH, new byte[0],
+ ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT),
+ Op.create(PARENT_PATH + test_name, new byte[0],
+ ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT));
+
+ //Execute transactional support on operations and verify they were run
+ List<OpResult> opResults = _realmAwareZkClient.multi(ops);
+ Assert.assertTrue(opResults.get(0) instanceof OpResult.CreateResult);
+ Assert.assertTrue(opResults.get(1) instanceof OpResult.CreateResult);
+
+ cleanup();
+ }
+
+ /**
+ * Multi should be an all or nothing transaction. Creating correct
+ * paths and a singular bad one should all fail.
+ */
+ @Test(dependsOnMethods = "testMultiCreate")
Review Comment:
It doesn't necessarily have to depend on "testMultiCreate" but my intention was to make sure each test completes in the same order to avoid any race conditions where we try and create an op with a path that already exists (and hasn't been cleaned up yet). I think this achieves it?
--
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 #2328: Multi Implementation and Test Cases
Posted by GitBox <gi...@apache.org>.
Marcosrico commented on code in PR #2328:
URL: https://github.com/apache/helix/pull/2328#discussion_r1060736731
##########
helix-core/src/test/java/org/apache/helix/integration/multizk/TestMultiZkHelixJavaApis.java:
##########
@@ -72,7 +78,7 @@
* cluster-Zk realm routing information.
* This test verifies that all Helix Java APIs work as expected.
*/
-public class TestMultiZkHelixJavaApis extends TestMultiZkConnectionConfig {
+public abstract class TestMultiZkHelixJavaApis extends TestMultiZkConnectionConfig {
Review Comment:
No reason, I don't remember changing it. 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] qqu0127 commented on a diff in pull request #2328: Multi Implementation and Test Cases
Posted by GitBox <gi...@apache.org>.
qqu0127 commented on code in PR #2328:
URL: https://github.com/apache/helix/pull/2328#discussion_r1063600425
##########
zookeeper-api/src/test/java/org/apache/helix/zookeeper/impl/client/RealmAwareZkClientTestBase.java:
##########
@@ -67,4 +76,127 @@ public void afterClass() {
_msdsServer.stopServer();
}
}
-}
+ /**
+ * Initialize requirement for testing multi support.
+ */
+ @Test
+ public void testMultiSetup() {
+ // Create a connection config with a valid sharding key
+ RealmAwareZkClient.RealmAwareZkConnectionConfig.Builder builder =
+ new RealmAwareZkClient.RealmAwareZkConnectionConfig.Builder();
+ RealmAwareZkClient.RealmAwareZkConnectionConfig connectionConfig =
+ builder.setZkRealmShardingKey(ZK_SHARDING_KEY_PREFIX).build();
+ try {
+ _realmAwareZkClient = new FederatedZkClient(connectionConfig,
+ new RealmAwareZkClient.RealmAwareZkClientConfig());
+ } catch (IllegalArgumentException e) {
+ Assert.fail("Invalid Sharding Key.");
+ } catch (Exception e) {
Review Comment:
Just to share a different thought, if the exception is abnormal, maybe we don't need to catch and check at all. Just let it throw.
--
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 #2328: Multi Implementation and Test Cases
Posted by GitBox <gi...@apache.org>.
xyuanlu commented on code in PR #2328:
URL: https://github.com/apache/helix/pull/2328#discussion_r1062797854
##########
zookeeper-api/src/test/java/org/apache/helix/zookeeper/impl/client/RealmAwareZkClientTestBase.java:
##########
@@ -67,4 +76,127 @@ public void afterClass() {
_msdsServer.stopServer();
}
}
-}
+ /**
+ * Initialize requirement for testing multi support.
+ */
+ @Test
+ public void testMultiSetup() {
+ // Create a connection config with a valid sharding key
+ RealmAwareZkClient.RealmAwareZkConnectionConfig.Builder builder =
+ new RealmAwareZkClient.RealmAwareZkConnectionConfig.Builder();
+ RealmAwareZkClient.RealmAwareZkConnectionConfig connectionConfig =
+ builder.setZkRealmShardingKey(ZK_SHARDING_KEY_PREFIX).build();
+ try {
+ _realmAwareZkClient = new FederatedZkClient(connectionConfig,
+ new RealmAwareZkClient.RealmAwareZkClientConfig());
+ } catch (IllegalArgumentException e) {
+ Assert.fail("Invalid Sharding Key.");
+ } catch (Exception e) {
+ Assert.fail("Should not see any other types of Exceptions: " + e);
+ }
+ }
+
+ /**
+ * Test that zk multi works for create.
+ */
+ @Test(dependsOnMethods = "testMultiSetup")
+ public void testMultiCreate() {
+ String test_name = "/test_multi_create";
+
+ //Create Nodes
+ List<Op> ops = Arrays.asList(
+ Op.create(PARENT_PATH, new byte[0],
+ ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT),
+ Op.create(PARENT_PATH + test_name, new byte[0],
+ ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT));
+
+ //Execute transactional support on operations and verify they were run
+ List<OpResult> opResults = _realmAwareZkClient.multi(ops);
+ Assert.assertTrue(opResults.get(0) instanceof OpResult.CreateResult);
+ Assert.assertTrue(opResults.get(1) instanceof OpResult.CreateResult);
+
Review Comment:
We probably want to check if all znodes are actually created 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