Java Code Examples for com.alibaba.csp.sentinel.slots.block.RuleConstant#CONTROL_BEHAVIOR_WARM_UP_RATE_LIMITER
The following examples show how to use
com.alibaba.csp.sentinel.slots.block.RuleConstant#CONTROL_BEHAVIOR_WARM_UP_RATE_LIMITER .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FlowRuleUtil.java From Sentinel-Dashboard-Nacos with Apache License 2.0 | 6 votes |
private static TrafficShapingController generateRater(/*@Valid*/ FlowRule rule) { if (rule.getGrade() == RuleConstant.FLOW_GRADE_QPS) { switch (rule.getControlBehavior()) { case RuleConstant.CONTROL_BEHAVIOR_WARM_UP: return new WarmUpController(rule.getCount(), rule.getWarmUpPeriodSec(), ColdFactorProperty.coldFactor); case RuleConstant.CONTROL_BEHAVIOR_RATE_LIMITER: return new RateLimiterController(rule.getMaxQueueingTimeMs(), rule.getCount()); case RuleConstant.CONTROL_BEHAVIOR_WARM_UP_RATE_LIMITER: return new WarmUpRateLimiterController(rule.getCount(), rule.getWarmUpPeriodSec(), rule.getMaxQueueingTimeMs(), ColdFactorProperty.coldFactor); case RuleConstant.CONTROL_BEHAVIOR_DEFAULT: default: // Default mode or unknown mode: default traffic shaping controller (fast-reject). } } return new DefaultController(rule.getCount(), rule.getGrade()); }
Example 2
Source File: FlowRuleUtil.java From Sentinel with Apache License 2.0 | 6 votes |
private static TrafficShapingController generateRater(/*@Valid*/ FlowRule rule) { if (rule.getGrade() == RuleConstant.FLOW_GRADE_QPS) { switch (rule.getControlBehavior()) { case RuleConstant.CONTROL_BEHAVIOR_WARM_UP: return new WarmUpController(rule.getCount(), rule.getWarmUpPeriodSec(), ColdFactorProperty.coldFactor); case RuleConstant.CONTROL_BEHAVIOR_RATE_LIMITER: return new RateLimiterController(rule.getMaxQueueingTimeMs(), rule.getCount()); case RuleConstant.CONTROL_BEHAVIOR_WARM_UP_RATE_LIMITER: return new WarmUpRateLimiterController(rule.getCount(), rule.getWarmUpPeriodSec(), rule.getMaxQueueingTimeMs(), ColdFactorProperty.coldFactor); case RuleConstant.CONTROL_BEHAVIOR_DEFAULT: default: // Default mode or unknown mode: default traffic shaping controller (fast-reject). } } return new DefaultController(rule.getCount(), rule.getGrade()); }
Example 3
Source File: FlowRuleUtil.java From Sentinel-Dashboard-Nacos with Apache License 2.0 | 5 votes |
private static boolean checkControlBehaviorField(/*@NonNull*/ FlowRule rule) { switch (rule.getControlBehavior()) { case RuleConstant.CONTROL_BEHAVIOR_WARM_UP: return rule.getWarmUpPeriodSec() > 0; case RuleConstant.CONTROL_BEHAVIOR_RATE_LIMITER: return rule.getMaxQueueingTimeMs() > 0; case RuleConstant.CONTROL_BEHAVIOR_WARM_UP_RATE_LIMITER: return rule.getWarmUpPeriodSec() > 0 && rule.getMaxQueueingTimeMs() > 0; default: return true; } }
Example 4
Source File: FlowRuleUtil.java From Sentinel with Apache License 2.0 | 5 votes |
private static boolean checkControlBehaviorField(/*@NonNull*/ FlowRule rule) { switch (rule.getControlBehavior()) { case RuleConstant.CONTROL_BEHAVIOR_WARM_UP: return rule.getWarmUpPeriodSec() > 0; case RuleConstant.CONTROL_BEHAVIOR_RATE_LIMITER: return rule.getMaxQueueingTimeMs() > 0; case RuleConstant.CONTROL_BEHAVIOR_WARM_UP_RATE_LIMITER: return rule.getWarmUpPeriodSec() > 0 && rule.getMaxQueueingTimeMs() > 0; default: return true; } }