From def563711fb42d604d728fe13bdc95c697473d02 Mon Sep 17 00:00:00 2001 From: wangjx <1609724385@qq.com> Date: Sat, 26 Jun 2021 10:40:05 +0800 Subject: [PATCH] =?UTF-8?q?nacos=E6=8C=81=E4=B9=85=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sentinel/dashboard/controller/v2/FlowControllerV2.java | 5 ++--- .../sentinel/dashboard/discovery/SimpleMachineDiscovery.java | 1 + .../sentinel/dashboard/rule/nacos/FlowRuleNacosProvider.java | 5 +++++ .../dashboard/rule/nacos/FlowRuleNacosPublisher.java | 5 +++++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/v2/FlowControllerV2.java b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/v2/FlowControllerV2.java index 90a022a2..cf85e4ea 100755 --- a/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/v2/FlowControllerV2.java +++ b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/v2/FlowControllerV2.java @@ -70,7 +70,7 @@ public class FlowControllerV2 { @GetMapping("/rules") @AuthAction(PrivilegeType.READ_RULE) public Result> apiQueryMachineRules(@RequestParam String app) { - + System.out.println("FlowControllerV2 apiQueryMachineRules app is " + app); if (StringUtil.isEmpty(app)) { return Result.ofFail(-1, "app can't be null or empty"); } @@ -163,8 +163,7 @@ public class FlowControllerV2 { @PutMapping("/rule/{id}") @AuthAction(AuthService.PrivilegeType.WRITE_RULE) - public Result apiUpdateFlowRule(@PathVariable("id") Long id, - @RequestBody FlowRuleEntity entity) { + public Result apiUpdateFlowRule(@PathVariable("id") Long id, @RequestBody FlowRuleEntity entity) { if (id == null || id <= 0) { return Result.ofFail(-1, "Invalid id"); } diff --git a/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/SimpleMachineDiscovery.java b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/SimpleMachineDiscovery.java index 140cfcd7..e14f92b1 100755 --- a/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/SimpleMachineDiscovery.java +++ b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/SimpleMachineDiscovery.java @@ -42,6 +42,7 @@ public class SimpleMachineDiscovery implements MachineDiscovery { @Override public long addMachine(MachineInfo machineInfo) { + logger.info("SimpleMachineDiscovery addMachine"); AssertUtil.notNull(machineInfo, "machineInfo cannot be null"); AppInfo appInfo = apps.computeIfAbsent(machineInfo.getApp(), o -> new AppInfo(machineInfo.getApp(), machineInfo.getAppType())); appInfo.addMachine(machineInfo); diff --git a/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/rule/nacos/FlowRuleNacosProvider.java b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/rule/nacos/FlowRuleNacosProvider.java index 54405af3..a63d3f6b 100644 --- a/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/rule/nacos/FlowRuleNacosProvider.java +++ b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/rule/nacos/FlowRuleNacosProvider.java @@ -20,6 +20,8 @@ import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.FlowRuleEntity; import com.alibaba.csp.sentinel.dashboard.rule.DynamicRuleProvider; import com.alibaba.csp.sentinel.datasource.Converter; import com.alibaba.nacos.api.config.ConfigService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Service; @@ -33,6 +35,8 @@ import java.util.List; @Service public class FlowRuleNacosProvider implements DynamicRuleProvider> { + @Autowired + private static Logger logger = LoggerFactory.getLogger(FlowRuleNacosProvider.class); @Autowired @Qualifier("nacosConfiguration") private ConfigService nacosConfiguration; @@ -43,6 +47,7 @@ public class FlowRuleNacosProvider implements DynamicRuleProvider getRules(String appName) throws Exception { + logger.info("FlowRuleNacosProvider getRules [appName] " + appName); String dataId=new StringBuilder(appName).append(NacosConstants.DATA_ID_POSTFIX).toString(); String rules = nacosConfiguration.getConfig(dataId,nacosProperties.getGroupId(),3000); //log.info("pull FlowRule from nacos Config:"+rules); diff --git a/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/rule/nacos/FlowRuleNacosPublisher.java b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/rule/nacos/FlowRuleNacosPublisher.java index 7938be99..99d26798 100644 --- a/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/rule/nacos/FlowRuleNacosPublisher.java +++ b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/rule/nacos/FlowRuleNacosPublisher.java @@ -21,6 +21,8 @@ import com.alibaba.csp.sentinel.dashboard.rule.DynamicRulePublisher; import com.alibaba.csp.sentinel.datasource.Converter; import com.alibaba.csp.sentinel.util.AssertUtil; import com.alibaba.nacos.api.config.ConfigService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Service; @@ -33,6 +35,8 @@ import java.util.List; @Service public class FlowRuleNacosPublisher implements DynamicRulePublisher> { + @Autowired + private static Logger logger = LoggerFactory.getLogger(FlowRuleNacosPublisher.class); @Autowired @Qualifier("nacosConfiguration") private ConfigService nacosConfiguration; @@ -44,6 +48,7 @@ public class FlowRuleNacosPublisher implements DynamicRulePublisher rules) throws Exception { + logger.info("FlowRuleNacosPublisher publish [appName] " + appName); AssertUtil.notEmpty(appName, "appName不能为空"); if(rules == null) { return;