Source:
public void testThrottleOnlyClusterLevelAnyType() { for (int i = 0; i < NODE_NR - 3; i++) { _participants[i].syncStart(); } _gSetupTool.addResourceToCluster(CLUSTER_NAME, WorkflowGenerator.DEFAULT_TGT_DB + "_OnlyANY", 20, STATE_MODEL, RebalanceMode.FULL_AUTO.name()); _gSetupTool.rebalanceStorageCluster(CLUSTER_NAME, WorkflowGenerator.DEFAULT_TGT_DB + "_OnlyANY", _replica); Assert.assertTrue(_clusterVerifier.verifyByPolling()); 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) { LOGGER.error("Exception to verify the transaction count", e); assert false; } }); ClusterLiveNodesVerifier clusterLiveNodesVerifier = new ClusterLiveNodesVerifier( _gZkClient, CLUSTER_NAME, Lists.transform(Arrays.asList(_participants), MockParticipantManager::getInstanceName)); Assert.assertTrue(clusterLiveNodesVerifier.verifyByZkCallback(1000)); Assert.assertTrue(_clusterVerifier.verifyByPolling()); for (int i = 0; i < NODE_NR; i++) { _participants[i].syncStop(); } }

Target:
public void testThrottleOnlyClusterLevelAnyType() { for (int i = 0; i < NODE_NR - 3; i++) { _participants[i].syncStart(); } _gSetupTool.addResourceToCluster(CLUSTER_NAME, WorkflowGenerator.DEFAULT_TGT_DB + "_OnlyANY", 20, STATE_MODEL, RebalanceMode.FULL_AUTO.name()); _gSetupTool.rebalanceStorageCluster(CLUSTER_NAME, WorkflowGenerator.DEFAULT_TGT_DB + "_OnlyANY", _replica); Assert.assertTrue(_clusterVerifier.verifyByPolling()); 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) { e.printStackTrace(); assert false; } }); ClusterLiveNodesVerifier liveNodesVerifier = new ClusterLiveNodesVerifier(_gZkClient, CLUSTER_NAME, Lists.transform(Arrays.asList(_participants), MockParticipantManager::getInstanceName)); Assert.assertTrue(liveNodesVerifier.verifyByZkCallback(1000)); Assert.assertTrue(_clusterVerifier.verifyByPolling()); for (int i = 0; i < NODE_NR; i++) { _participants[i].syncStop(); } }