[GitHub] [helix] i3wangyi commented on a change in pull request #333: Fix issue when client only sets ANY at cluster level throttle config
i3wangyi 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_r310226396 ## File path: helix-core/src/main/java/org/apache/helix/controller/stages/StateTransitionThrottleController.java ## @@ -208,13 +210,20 @@ protected void chargeResource(StateTransitionThrottleConfig.RebalanceType rebala */ protected void chargeInstance(StateTransitionThrottleConfig.RebalanceType rebalanceType, String instance) { -if (_pendingTransitionAllowedPerInstance.containsKey(instance) -&& _pendingTransitionAllowedPerInstance.get(instance).containsKey(rebalanceType)) { - chargeANYType(_pendingTransitionAllowedPerInstance.get(instance)); - Long instanceThrottle = _pendingTransitionAllowedPerInstance.get(instance).get(rebalanceType); - if (instanceThrottle > 0) { -_pendingTransitionAllowedPerInstance.get(instance).put(rebalanceType, instanceThrottle - 1); - } +charge(rebalanceType, _pendingTransitionAllowedPerInstance.getOrDefault(instance, new HashMap<>())); + } + + private void charge(StateTransitionThrottleConfig.RebalanceType rebalanceType, + Map quota) { +if (StateTransitionThrottleConfig.RebalanceType.NONE.equals(rebalanceType)) { + logger.error("Wrong rebalance type NONE as parameter"); + return; +} +// if ANY type is present, decrement one else do nothing +quota.computeIfPresent(StateTransitionThrottleConfig.RebalanceType.ANY, (key, val) -> Math.max(0, val - 1)); Review comment: Look at the method parameter, these names are already taken 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [helix] i3wangyi commented on a change in pull request #333: Fix issue when client only sets ANY at cluster level throttle config
i3wangyi 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_r309981145 ## File path: helix-core/src/test/java/org/apache/helix/integration/common/ZkStandAloneCMTestBase.java ## @@ -28,8 +28,6 @@ import org.apache.helix.integration.manager.MockParticipantManager; import org.apache.helix.tools.ClusterVerifiers.BestPossibleExternalViewVerifier; import org.apache.helix.tools.ClusterVerifiers.ZkHelixClusterVerifier; -import org.slf4j.Logger; Review comment: Sorry I guess these are just auto-done by IDE 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [helix] i3wangyi commented on a change in pull request #333: Fix issue when client only sets ANY at cluster level throttle config
i3wangyi 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_r309981100 ## File path: helix-core/src/test/java/org/apache/helix/integration/TestPartitionMovementThrottle.java ## @@ -279,13 +332,15 @@ public void testResourceThrottleWithDelayRebalancer() { Assert.assertTrue(_clusterVerifier.verifyByPolling()); for (String db : _dbs) { - validateThrottle(DelayedTransition.getResourcePatitionTransitionTimes(), db, 2); + int maxInParallel = getMaxParallelTransitionCount(DelayedTransition.getResourcePatitionTransitionTimes(), db); + System.out.println( + "MaxInParallel: " + maxInParallel + " maxPendingTransition: " + 2); + Assert.assertTrue(maxInParallel <= 2, "Throttle condition does not meet for " + db); } } - private void validateThrottle( Review comment: Yes. The TestHelper.verify method expects an interface with boolean return value. The original method returns void. As you can see, I just pull out the part where it verifies `maxParallelCount <= input `which makes more sense and visible 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [helix] i3wangyi commented on a change in pull request #333: Fix issue when client only sets ANY at cluster level throttle config
i3wangyi 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_r309979933 ## File path: helix-core/src/main/java/org/apache/helix/controller/stages/StateTransitionThrottleController.java ## @@ -208,13 +210,20 @@ protected void chargeResource(StateTransitionThrottleConfig.RebalanceType rebala */ protected void chargeInstance(StateTransitionThrottleConfig.RebalanceType rebalanceType, String instance) { -if (_pendingTransitionAllowedPerInstance.containsKey(instance) -&& _pendingTransitionAllowedPerInstance.get(instance).containsKey(rebalanceType)) { - chargeANYType(_pendingTransitionAllowedPerInstance.get(instance)); - Long instanceThrottle = _pendingTransitionAllowedPerInstance.get(instance).get(rebalanceType); - if (instanceThrottle > 0) { -_pendingTransitionAllowedPerInstance.get(instance).put(rebalanceType, instanceThrottle - 1); - } +charge(rebalanceType, _pendingTransitionAllowedPerInstance.getOrDefault(instance, new HashMap<>())); + } + + private void charge(StateTransitionThrottleConfig.RebalanceType rebalanceType, + Map quota) { +if (StateTransitionThrottleConfig.RebalanceType.NONE.equals(rebalanceType)) { + logger.error("Wrong rebalance type NONE as parameter"); + return; +} +// if ANY type is present, decrement one else do nothing +quota.computeIfPresent(StateTransitionThrottleConfig.RebalanceType.ANY, (key, val) -> Math.max(0, val - 1)); Review comment: The names are taken by method parameters. They're more important and names of (key, val) should be fine under simple logics for people familiar with the method. 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: us...@infra.apache.org With regards, Apache Git Services