mirror of
https://gitee.com/mirrors/Spring-Cloud-Alibaba.git
synced 2021-06-26 13:25:11 +08:00
fix bug about sentinel commercialization for 1.x branch
This commit is contained in:
parent
c6fd82cb45
commit
7e2b312fdd
@ -44,6 +44,7 @@ import org.springframework.util.CollectionUtils;
|
|||||||
import org.springframework.util.ReflectionUtils;
|
import org.springframework.util.ReflectionUtils;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import com.alibaba.csp.sentinel.datasource.AbstractDataSource;
|
||||||
import com.alibaba.csp.sentinel.datasource.ReadableDataSource;
|
import com.alibaba.csp.sentinel.datasource.ReadableDataSource;
|
||||||
import com.alibaba.csp.sentinel.property.SentinelProperty;
|
import com.alibaba.csp.sentinel.property.SentinelProperty;
|
||||||
import com.alibaba.csp.sentinel.slots.block.AbstractRule;
|
import com.alibaba.csp.sentinel.slots.block.AbstractRule;
|
||||||
@ -277,7 +278,18 @@ public class SentinelDataSourceHandler {
|
|||||||
|
|
||||||
beanFactory.registerBeanDefinition(dataSourceName, builder.getBeanDefinition());
|
beanFactory.registerBeanDefinition(dataSourceName, builder.getBeanDefinition());
|
||||||
// init in Spring
|
// init in Spring
|
||||||
beanFactory.getBean(dataSourceName);
|
AbstractDataSource newDataSource = (AbstractDataSource) beanFactory
|
||||||
|
.getBean(dataSourceName);
|
||||||
|
// commercialization
|
||||||
|
if (!StringUtils.isEmpty(System.getProperties()
|
||||||
|
.getProperty(SentinelDataSourceConstants.NACOS_DATASOURCE_ENDPOINT))) {
|
||||||
|
if (dataSourceName.contains(SentinelConstants.FLOW_DATASOURCE_NAME)) {
|
||||||
|
FlowRuleManager.register2Property(newDataSource.getProperty());
|
||||||
|
}
|
||||||
|
else if (dataSourceName.contains(SentinelConstants.DEGRADE_DATASOURCE_NAME)) {
|
||||||
|
DegradeRuleManager.register2Property(newDataSource.getProperty());
|
||||||
|
}
|
||||||
|
}
|
||||||
dataSourceBeanNameList.add(dataSourceName);
|
dataSourceBeanNameList.add(dataSourceName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user