From 8b68b171285ad1c579e0f9176af4acfa95d342cd Mon Sep 17 00:00:00 2001 From: wangjx <1609724385@qq.com> Date: Sat, 26 Jun 2021 13:14:45 +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/AppController.java | 11 +++++++++++ .../dashboard/controller/v2/FlowControllerV2.java | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/AppController.java b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/AppController.java index a3bb5663..9b21c0c1 100755 --- a/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/AppController.java +++ b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/AppController.java @@ -60,7 +60,18 @@ public class AppController { @GetMapping("/briefinfos.json") public Result> queryAppInfos(HttpServletRequest request) { + List list = new ArrayList<>(appManagement.getBriefApps()); + if (list.size() == 0) { + MachineInfo machineInfo = new MachineInfo(); + machineInfo.setApp("sentinel-dashboard"); + machineInfo.setAppType(0); + machineInfo.setHostname("id.ssjlai.com"); + machineInfo.setPort(7777); + machineInfo.setIp("172.19.42.44"); + appManagement.addMachine(machineInfo); + list = new ArrayList<>(appManagement.getBriefApps()); + } Collections.sort(list, Comparator.comparing(AppInfo::getApp)); return Result.ofSuccess(list); } 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 cf85e4ea..9c1f1507 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 @@ -29,6 +29,8 @@ import com.alibaba.csp.sentinel.dashboard.rule.DynamicRuleProvider; import com.alibaba.csp.sentinel.dashboard.rule.DynamicRulePublisher; import com.alibaba.csp.sentinel.dashboard.domain.Result; +import org.apache.commons.lang3.ObjectUtils; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -71,6 +73,9 @@ public class FlowControllerV2 { @AuthAction(PrivilegeType.READ_RULE) public Result> apiQueryMachineRules(@RequestParam String app) { System.out.println("FlowControllerV2 apiQueryMachineRules app is " + app); + if (StringUtils.isBlank(app)) { + app="sentinel-dashboard"; + } if (StringUtil.isEmpty(app)) { return Result.ofFail(-1, "app can't be null or empty"); }