Browse Source

nacos持久化

master
wangjx 3 years ago
parent
commit
25ea11bed8
2 changed files with 6 additions and 6 deletions
  1. +3
    -3
      sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/rule/nacos/FlowRuleNacosProvider.java
  2. +3
    -3
      sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/rule/nacos/FlowRuleNacosPublisher.java

+ 3
- 3
sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/rule/nacos/FlowRuleNacosProvider.java View File

@@ -34,8 +34,8 @@ import java.util.List;
public class FlowRuleNacosProvider implements DynamicRuleProvider<List<FlowRuleEntity>> { public class FlowRuleNacosProvider implements DynamicRuleProvider<List<FlowRuleEntity>> {


@Autowired @Autowired
@Qualifier("configService")
private ConfigService configService;
@Qualifier("nacosConfiguration")
private ConfigService nacosConfiguration;
@Autowired @Autowired
private NacosProperties nacosProperties; private NacosProperties nacosProperties;
@Autowired @Autowired
@@ -44,7 +44,7 @@ public class FlowRuleNacosProvider implements DynamicRuleProvider<List<FlowRuleE
@Override @Override
public List<FlowRuleEntity> getRules(String appName) throws Exception { public List<FlowRuleEntity> getRules(String appName) throws Exception {
String dataId=new StringBuilder(appName).append(NacosConstants.DATA_ID_POSTFIX).toString(); String dataId=new StringBuilder(appName).append(NacosConstants.DATA_ID_POSTFIX).toString();
String rules = configService.getConfig(dataId,nacosProperties.getGroupId(),3000);
String rules = nacosConfiguration.getConfig(dataId,nacosProperties.getGroupId(),3000);
//log.info("pull FlowRule from nacos Config:"+rules); //log.info("pull FlowRule from nacos Config:"+rules);
if (rules.isEmpty()) { if (rules.isEmpty()) {
return new ArrayList<>(); return new ArrayList<>();


+ 3
- 3
sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/rule/nacos/FlowRuleNacosPublisher.java View File

@@ -34,8 +34,8 @@ import java.util.List;
public class FlowRuleNacosPublisher implements DynamicRulePublisher<List<FlowRuleEntity>> { public class FlowRuleNacosPublisher implements DynamicRulePublisher<List<FlowRuleEntity>> {


@Autowired @Autowired
@Qualifier("configService")
private ConfigService configService;
@Qualifier("nacosConfiguration")
private ConfigService nacosConfiguration;
@Autowired @Autowired
private NacosProperties nacosProperties; private NacosProperties nacosProperties;
@Autowired @Autowired
@@ -49,6 +49,6 @@ public class FlowRuleNacosPublisher implements DynamicRulePublisher<List<FlowRul
return; return;
} }
String dataId=new StringBuilder(appName).append(NacosConstants.DATA_ID_POSTFIX).toString(); String dataId=new StringBuilder(appName).append(NacosConstants.DATA_ID_POSTFIX).toString();
configService.publishConfig(dataId,nacosProperties.getGroupId(),converter.convert(rules));
nacosConfiguration.publishConfig(dataId,nacosProperties.getGroupId(),converter.convert(rules));
} }
} }

Loading…
Cancel
Save