Java Code Examples for com.alibaba.csp.sentinel.slots.block.flow.FlowRule#setMaxQueueingTimeMs()
The following examples show how to use
com.alibaba.csp.sentinel.slots.block.flow.FlowRule#setMaxQueueingTimeMs() .
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: PaceFlowDemo.java From Sentinel-Dashboard-Nacos with Apache License 2.0 | 6 votes |
private static void initPaceFlowRule() { List<FlowRule> rules = new ArrayList<FlowRule>(); FlowRule rule1 = new FlowRule(); rule1.setResource(KEY); rule1.setCount(count); rule1.setGrade(RuleConstant.FLOW_GRADE_QPS); rule1.setLimitApp("default"); /* * CONTROL_BEHAVIOR_RATE_LIMITER means requests more than threshold will be queueing in the queue, * until the queueing time is more than {@link FlowRule#maxQueueingTimeMs}, the requests will be rejected. */ rule1.setControlBehavior(RuleConstant.CONTROL_BEHAVIOR_RATE_LIMITER); rule1.setMaxQueueingTimeMs(20 * 1000); rules.add(rule1); FlowRuleManager.loadRules(rules); }
Example 2
Source File: PullConsumerDemo.java From Sentinel-Dashboard-Nacos with Apache License 2.0 | 6 votes |
private static void initFlowControlRule() { FlowRule rule = new FlowRule(); rule.setResource(KEY); // Indicates the interval between two adjacent requests is 200 ms. rule.setCount(5); rule.setGrade(RuleConstant.FLOW_GRADE_QPS); rule.setLimitApp("default"); // Enable rate limiting (uniform). This can ensure fixed intervals between two adjacent calls. // In this example, intervals between two incoming calls (message consumption) will be 200 ms constantly. rule.setControlBehavior(RuleConstant.CONTROL_BEHAVIOR_RATE_LIMITER); // If more requests are coming, they'll be put into the waiting queue. // The queue has a queueing timeout. Requests that may exceed the timeout will be immediately blocked. // In this example, the max timeout is 5s. rule.setMaxQueueingTimeMs(5 * 1000); FlowRuleManager.loadRules(Collections.singletonList(rule)); }
Example 3
Source File: FlowRuleEntity.java From Sentinel-Dashboard-Nacos with Apache License 2.0 | 6 votes |
@Override public FlowRule toRule() { FlowRule flowRule = new FlowRule(); flowRule.setCount(this.count); flowRule.setGrade(this.grade); flowRule.setResource(this.resource); flowRule.setLimitApp(this.limitApp); flowRule.setRefResource(this.refResource); flowRule.setStrategy(this.strategy); if (this.controlBehavior != null) { flowRule.setControlBehavior(controlBehavior); } if (this.warmUpPeriodSec != null) { flowRule.setWarmUpPeriodSec(warmUpPeriodSec); } if (this.maxQueueingTimeMs != null) { flowRule.setMaxQueueingTimeMs(maxQueueingTimeMs); } flowRule.setClusterMode(clusterMode); flowRule.setClusterConfig(clusterConfig); return flowRule; }
Example 4
Source File: PaceFlowDemo.java From Sentinel with Apache License 2.0 | 6 votes |
private static void initPaceFlowRule() { List<FlowRule> rules = new ArrayList<FlowRule>(); FlowRule rule1 = new FlowRule(); rule1.setResource(KEY); rule1.setCount(count); rule1.setGrade(RuleConstant.FLOW_GRADE_QPS); rule1.setLimitApp("default"); /* * CONTROL_BEHAVIOR_RATE_LIMITER means requests more than threshold will be queueing in the queue, * until the queueing time is more than {@link FlowRule#maxQueueingTimeMs}, the requests will be rejected. */ rule1.setControlBehavior(RuleConstant.CONTROL_BEHAVIOR_RATE_LIMITER); rule1.setMaxQueueingTimeMs(20 * 1000); rules.add(rule1); FlowRuleManager.loadRules(rules); }
Example 5
Source File: PullConsumerDemo.java From Sentinel with Apache License 2.0 | 6 votes |
private static void initFlowControlRule() { FlowRule rule = new FlowRule(); rule.setResource(KEY); // Indicates the interval between two adjacent requests is 200 ms. rule.setCount(5); rule.setGrade(RuleConstant.FLOW_GRADE_QPS); rule.setLimitApp("default"); // Enable rate limiting (uniform). This can ensure fixed intervals between two adjacent calls. // In this example, intervals between two incoming calls (message consumption) will be 200 ms constantly. rule.setControlBehavior(RuleConstant.CONTROL_BEHAVIOR_RATE_LIMITER); // If more requests are coming, they'll be put into the waiting queue. // The queue has a queueing timeout. Requests that may exceed the timeout will be immediately blocked. // In this example, the max timeout is 5s. rule.setMaxQueueingTimeMs(5 * 1000); FlowRuleManager.loadRules(Collections.singletonList(rule)); }
Example 6
Source File: FlowRuleEntity.java From Sentinel with Apache License 2.0 | 6 votes |
@Override public FlowRule toRule() { FlowRule flowRule = new FlowRule(); flowRule.setCount(this.count); flowRule.setGrade(this.grade); flowRule.setResource(this.resource); flowRule.setLimitApp(this.limitApp); flowRule.setRefResource(this.refResource); flowRule.setStrategy(this.strategy); if (this.controlBehavior != null) { flowRule.setControlBehavior(controlBehavior); } if (this.warmUpPeriodSec != null) { flowRule.setWarmUpPeriodSec(warmUpPeriodSec); } if (this.maxQueueingTimeMs != null) { flowRule.setMaxQueueingTimeMs(maxQueueingTimeMs); } flowRule.setClusterMode(clusterMode); flowRule.setClusterConfig(clusterConfig); return flowRule; }
Example 7
Source File: WarmUpRateLimiterFlowDemo.java From Sentinel-Dashboard-Nacos with Apache License 2.0 | 5 votes |
private static void initFlowRule() { List<FlowRule> rules = new ArrayList<FlowRule>(); FlowRule rule1 = new FlowRule(); rule1.setResource(KEY); rule1.setCount(20); rule1.setGrade(RuleConstant.FLOW_GRADE_QPS); rule1.setLimitApp("default"); rule1.setControlBehavior(RuleConstant.CONTROL_BEHAVIOR_WARM_UP_RATE_LIMITER); rule1.setWarmUpPeriodSec(10); rule1.setMaxQueueingTimeMs(100); rules.add(rule1); FlowRuleManager.loadRules(rules); }
Example 8
Source File: WarmUpRateLimiterFlowDemo.java From Sentinel with Apache License 2.0 | 5 votes |
private static void initFlowRule() { List<FlowRule> rules = new ArrayList<FlowRule>(); FlowRule rule1 = new FlowRule(); rule1.setResource(KEY); rule1.setCount(20); rule1.setGrade(RuleConstant.FLOW_GRADE_QPS); rule1.setLimitApp("default"); rule1.setControlBehavior(RuleConstant.CONTROL_BEHAVIOR_WARM_UP_RATE_LIMITER); rule1.setWarmUpPeriodSec(10); rule1.setMaxQueueingTimeMs(100); rules.add(rule1); FlowRuleManager.loadRules(rules); }