You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@helix.apache.org by GitBox <gi...@apache.org> on 2019/07/20 17:54:59 UTC

[GitHub] [helix] pkuwm commented on a change in pull request #333: Fix issue when client only sets ANY at cluster level throttle config

pkuwm commented on a change in pull request #333: Fix issue when client only sets ANY at cluster level throttle config
URL: https://github.com/apache/helix/pull/333#discussion_r305588139
 
 

 ##########
 File path: helix-core/src/test/java/org/apache/helix/integration/TestPartitionMovementThrottle.java
 ##########
 @@ -211,8 +218,54 @@ public void testANYtypeThrottle() throws InterruptedException {
     Thread.sleep(2000L);
 
     for (int i = 0; i < NODE_NR; i++) {
-      validateThrottle(DelayedTransition.getInstancePatitionTransitionTimes(),
-          _participants[i].getInstanceName(), 1);
+      Assert.assertTrue(getMaxParallelTransitionCount(DelayedTransition.getInstancePatitionTransitionTimes(), _participants[i].getInstanceName()) <= 1);
+    }
+  }
+
+  @Test
+  public void testThrottleOnlyClusterLevelAnyType() {
+    // start some participants
+    for (int i = 0; i < NODE_NR - 3; i++) {
+      _participants[i].syncStart();
+    }
+    // Add resource: TestDB_ANY of 20 partitions
+    _gSetupTool.addResourceToCluster(CLUSTER_NAME, WorkflowGenerator.DEFAULT_TGT_DB + "_OnlyANY", 20,
+        STATE_MODEL, RebalanceMode.FULL_AUTO.name());
+    // Act the rebalance process
+    _gSetupTool.rebalanceStorageCluster(CLUSTER_NAME, WorkflowGenerator.DEFAULT_TGT_DB + "_OnlyANY",
+        _replica);
+
+    Assert.assertTrue(_clusterVerifier.verifyByPolling());
+
+    // overwrite the cluster level throttle configuration
+    ClusterConfig clusterConfig = _configAccessor.getClusterConfig(CLUSTER_NAME);
+    StateTransitionThrottleConfig anyTypeClusterThrottle = new StateTransitionThrottleConfig(
+        StateTransitionThrottleConfig.RebalanceType.ANY, StateTransitionThrottleConfig.ThrottleScope.CLUSTER, 1);
+    clusterConfig.setStateTransitionThrottleConfigs(ImmutableList.of(anyTypeClusterThrottle));
+    _configAccessor.setClusterConfig(CLUSTER_NAME, clusterConfig);
+
+    DelayedTransition.setDelay(20);
+    DelayedTransition.enableThrottleRecord();
+
+    List<MockParticipantManager> newNodes = Arrays.asList(_participants).subList(NODE_NR - 3, NODE_NR);
+    newNodes.forEach(MockParticipantManager::syncStart);
+    newNodes.forEach(node -> {
+      try {
+        Assert.assertTrue(TestHelper.verify(
+            () -> getMaxParallelTransitionCount(DelayedTransition.getInstancePatitionTransitionTimes(), node.getInstanceName()) <= 1, 1000 * 2));
+      } catch (Exception e) {
 
 Review comment:
   Would this exception be more specific? What type of exception would 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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services