Browse Source

nacos持久化

master
wangjx 3 years ago
parent
commit
34b46c74f8
3 changed files with 19 additions and 19 deletions
  1. +10
    -10
      sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/AppController.java
  2. +4
    -4
      sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/v2/FlowControllerV2.java
  3. +5
    -5
      sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/SimpleMachineDiscovery.java

+ 10
- 10
sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/AppController.java View File

@@ -62,16 +62,16 @@ public class AppController {
public Result<List<AppInfo>> queryAppInfos(HttpServletRequest request) { public Result<List<AppInfo>> queryAppInfos(HttpServletRequest request) {


List<AppInfo> list = new ArrayList<>(appManagement.getBriefApps()); List<AppInfo> 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());
}
// 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)); Collections.sort(list, Comparator.comparing(AppInfo::getApp));
return Result.ofSuccess(list); return Result.ofSuccess(list);
} }


+ 4
- 4
sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/v2/FlowControllerV2.java View File

@@ -72,10 +72,10 @@ public class FlowControllerV2 {
@GetMapping("/rules") @GetMapping("/rules")
@AuthAction(PrivilegeType.READ_RULE) @AuthAction(PrivilegeType.READ_RULE)
public Result<List<FlowRuleEntity>> apiQueryMachineRules(@RequestParam String app) { public Result<List<FlowRuleEntity>> apiQueryMachineRules(@RequestParam String app) {
System.out.println("FlowControllerV2 apiQueryMachineRules app is " + app);
if (StringUtils.isBlank(app)) {
app="sentinel-dashboard";
}
// System.out.println("FlowControllerV2 apiQueryMachineRules app is " + app);
// if (StringUtils.isBlank(app)) {
// app="sentinel-dashboard";
// }
if (StringUtil.isEmpty(app)) { if (StringUtil.isEmpty(app)) {
return Result.ofFail(-1, "app can't be null or empty"); return Result.ofFail(-1, "app can't be null or empty");
} }


+ 5
- 5
sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/SimpleMachineDiscovery.java View File

@@ -42,7 +42,7 @@ public class SimpleMachineDiscovery implements MachineDiscovery {


@Override @Override
public long addMachine(MachineInfo machineInfo) { public long addMachine(MachineInfo machineInfo) {
logger.info("SimpleMachineDiscovery addMachine");
// logger.info("SimpleMachineDiscovery addMachine");
AssertUtil.notNull(machineInfo, "machineInfo cannot be null"); AssertUtil.notNull(machineInfo, "machineInfo cannot be null");
AppInfo appInfo = apps.computeIfAbsent(machineInfo.getApp(), o -> new AppInfo(machineInfo.getApp(), machineInfo.getAppType())); AppInfo appInfo = apps.computeIfAbsent(machineInfo.getApp(), o -> new AppInfo(machineInfo.getApp(), machineInfo.getAppType()));
appInfo.addMachine(machineInfo); appInfo.addMachine(machineInfo);
@@ -51,7 +51,7 @@ public class SimpleMachineDiscovery implements MachineDiscovery {


@Override @Override
public boolean removeMachine(String app, String ip, int port) { public boolean removeMachine(String app, String ip, int port) {
logger.info("app is " + app);
// logger.info("app is " + app);
AssertUtil.assertNotBlank(app, "app name cannot be blank"); AssertUtil.assertNotBlank(app, "app name cannot be blank");
AppInfo appInfo = apps.get(app); AppInfo appInfo = apps.get(app);
if (appInfo != null) { if (appInfo != null) {
@@ -64,20 +64,20 @@ public class SimpleMachineDiscovery implements MachineDiscovery {
public List<String> getAppNames() { public List<String> getAppNames() {




logger.info("apps.keySet is " + apps.keySet());
// logger.info("apps.keySet is " + apps.keySet());
return new ArrayList<>(apps.keySet()); return new ArrayList<>(apps.keySet());
} }


@Override @Override
public AppInfo getDetailApp(String app) { public AppInfo getDetailApp(String app) {
logger.info("app is " + app);
// logger.info("app is " + app);
AssertUtil.assertNotBlank(app, "app name cannot be blank"); AssertUtil.assertNotBlank(app, "app name cannot be blank");
return apps.get(app); return apps.get(app);
} }


@Override @Override
public Set<AppInfo> getBriefApps() { public Set<AppInfo> getBriefApps() {
logger.info("apps is " + apps.toString());
// logger.info("apps is " + apps.toString());
return new HashSet<>(apps.values()); return new HashSet<>(apps.values());
} }




Loading…
Cancel
Save