Kaynağa Gözat

nacos持久化

master
wangjx 3 yıl önce
ebeveyn
işleme
34b46c74f8
3 değiştirilmiş dosya ile 19 ekleme ve 19 silme
  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 Dosyayı Görüntüle

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

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));
return Result.ofSuccess(list);
}


+ 4
- 4
sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/v2/FlowControllerV2.java Dosyayı Görüntüle

@@ -72,10 +72,10 @@ public class FlowControllerV2 {
@GetMapping("/rules")
@AuthAction(PrivilegeType.READ_RULE)
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)) {
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 Dosyayı Görüntüle

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

@Override
public long addMachine(MachineInfo machineInfo) {
logger.info("SimpleMachineDiscovery addMachine");
// 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);
@@ -51,7 +51,7 @@ public class SimpleMachineDiscovery implements MachineDiscovery {

@Override
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");
AppInfo appInfo = apps.get(app);
if (appInfo != null) {
@@ -64,20 +64,20 @@ public class SimpleMachineDiscovery implements MachineDiscovery {
public List<String> getAppNames() {


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

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

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



Yükleniyor…
İptal
Kaydet