Java Code Examples for com.alibaba.csp.sentinel.slots.block.degrade.DegradeRuleManager#register2Property()
The following examples show how to use
com.alibaba.csp.sentinel.slots.block.degrade.DegradeRuleManager#register2Property() .
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: FileDataSourceDemo.java From Sentinel-Dashboard-Nacos with Apache License 2.0 | 6 votes |
private void listenRules() throws Exception { ClassLoader classLoader = getClass().getClassLoader(); String flowRulePath = URLDecoder.decode(classLoader.getResource("FlowRule.json").getFile(), "UTF-8"); String degradeRulePath = URLDecoder.decode(classLoader.getResource("DegradeRule.json").getFile(), "UTF-8"); String systemRulePath = URLDecoder.decode(classLoader.getResource("SystemRule.json").getFile(), "UTF-8"); // Data source for FlowRule FileRefreshableDataSource<List<FlowRule>> flowRuleDataSource = new FileRefreshableDataSource<>( flowRulePath, flowRuleListParser); FlowRuleManager.register2Property(flowRuleDataSource.getProperty()); // Data source for DegradeRule FileRefreshableDataSource<List<DegradeRule>> degradeRuleDataSource = new FileRefreshableDataSource<>( degradeRulePath, degradeRuleListParser); DegradeRuleManager.register2Property(degradeRuleDataSource.getProperty()); // Data source for SystemRule FileRefreshableDataSource<List<SystemRule>> systemRuleDataSource = new FileRefreshableDataSource<>( systemRulePath, systemRuleListParser); SystemRuleManager.register2Property(systemRuleDataSource.getProperty()); }
Example 2
Source File: FileDataSourceDemo.java From Sentinel with Apache License 2.0 | 6 votes |
private void listenRules() throws Exception { ClassLoader classLoader = getClass().getClassLoader(); String flowRulePath = URLDecoder.decode(classLoader.getResource("FlowRule.json").getFile(), "UTF-8"); String degradeRulePath = URLDecoder.decode(classLoader.getResource("DegradeRule.json").getFile(), "UTF-8"); String systemRulePath = URLDecoder.decode(classLoader.getResource("SystemRule.json").getFile(), "UTF-8"); // Data source for FlowRule FileRefreshableDataSource<List<FlowRule>> flowRuleDataSource = new FileRefreshableDataSource<>( flowRulePath, flowRuleListParser); FlowRuleManager.register2Property(flowRuleDataSource.getProperty()); // Data source for DegradeRule FileRefreshableDataSource<List<DegradeRule>> degradeRuleDataSource = new FileRefreshableDataSource<>( degradeRulePath, degradeRuleListParser); DegradeRuleManager.register2Property(degradeRuleDataSource.getProperty()); // Data source for SystemRule FileRefreshableDataSource<List<SystemRule>> systemRuleDataSource = new FileRefreshableDataSource<>( systemRulePath, systemRuleListParser); SystemRuleManager.register2Property(systemRuleDataSource.getProperty()); }
Example 3
Source File: AbstractDataSourceProperties.java From spring-cloud-alibaba with Apache License 2.0 | 5 votes |
public void postRegister(AbstractDataSource dataSource) { switch (this.getRuleType()) { case FLOW: FlowRuleManager.register2Property(dataSource.getProperty()); break; case DEGRADE: DegradeRuleManager.register2Property(dataSource.getProperty()); break; case PARAM_FLOW: ParamFlowRuleManager.register2Property(dataSource.getProperty()); break; case SYSTEM: SystemRuleManager.register2Property(dataSource.getProperty()); break; case AUTHORITY: AuthorityRuleManager.register2Property(dataSource.getProperty()); break; case GW_FLOW: GatewayRuleManager.register2Property(dataSource.getProperty()); break; case GW_API_GROUP: GatewayApiDefinitionManager.register2Property(dataSource.getProperty()); break; default: break; } }