diff --git a/server/src/main/java/io/wdd/rpc/scheduler/service/status/MonitorAllAgentStatus.java b/server/src/main/java/io/wdd/rpc/scheduler/service/status/MonitorAllAgentStatus.java index 4c42211..222db4d 100644 --- a/server/src/main/java/io/wdd/rpc/scheduler/service/status/MonitorAllAgentStatus.java +++ b/server/src/main/java/io/wdd/rpc/scheduler/service/status/MonitorAllAgentStatus.java @@ -161,15 +161,17 @@ public class MonitorAllAgentStatus { private void updateAllAgentHealthyStatus() { + List statusList = redisTemplate .opsForHash() .multiGet( ALL_AGENT_STATUS_REDIS_KEY, ALL_AGENT_TOPIC_NAME_LIST ); - // current log to console is ok - // agent-topic-name : STATUS(healthy, failed, unknown) + + + // 结构保存为agentStatusMap ==> agent-topic-name : STATUS(healthy, failed, unknown) HashMap agentStatusMap = new HashMap<>(32); for (int i = 0; i < ALL_AGENT_TOPIC_NAME_LIST.size(); i++) { agentStatusMap.put( @@ -227,17 +229,32 @@ public class MonitorAllAgentStatus { allHealthyAgentTopicNames.add(ALL_AGENT_TOPIC_NAME_LIST.get(i)); } } + // 缓存相应的存活Agent ALL_HEALTHY_AGENT_TOPIC_NAMES = allHealthyAgentTopicNames; // 执行Metric上报任务 buildStatusScheduleTask.buildAgentMetricScheduleTask(); + + + // init the healthy map + // 需要将所有的Agent的状态置为 "0" + ALL_AGENT_TOPIC_NAME_LIST + .stream() + .forEach( + agentTopicName -> { + AGENT_HEALTHY_INIT_MAP.put( + agentTopicName, + "0" + ); + } + ); + // update time AGENT_HEALTHY_INIT_MAP.put( "updateTime", currentTimeString ); - // init the healthy map redisTemplate .opsForHash() .putAll( diff --git a/server/src/main/java/io/wdd/server/controller/ServerController.java b/server/src/main/java/io/wdd/server/controller/ServerController.java index 20b08f6..2a03dfa 100644 --- a/server/src/main/java/io/wdd/server/controller/ServerController.java +++ b/server/src/main/java/io/wdd/server/controller/ServerController.java @@ -3,13 +3,14 @@ package io.wdd.server.controller; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import io.wdd.common.beans.response.R; import io.wdd.server.beans.po.DomainInfoPO; import io.wdd.server.beans.po.ServerInfoPO; import io.wdd.server.beans.vo.AppInfoVO; import io.wdd.server.beans.vo.DomainInfoVO; import io.wdd.server.beans.vo.ServerInfoVO; import io.wdd.server.coreService.CoreServerService; -import io.wdd.common.beans.response.R; import org.apache.commons.lang3.ObjectUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.lang.Nullable; @@ -40,8 +41,17 @@ public class ServerController { } @PostMapping("/single") - public R serverGetSingle(@RequestParam(value = "serverIPv4") @Nullable String ipv4, @RequestParam(value = "serverName") @Nullable String serverName, @RequestParam(value = "serverLocation") @Nullable String serverLocation) { - return R.ok(coreServerService.serverGetSingle(serverName, ipv4, serverLocation)); + @ApiOperation("根据信息查询单个服务器信息") + public R serverGetSingle( + @RequestParam(value = "serverIPv4", required = false) @ApiParam(value = "服务器IPv4地址", required = false) @Nullable String ipv4, + @RequestParam(value = "serverName", required = false) @ApiParam(value = "服务器名称", required = false) @Nullable String serverName, + @RequestParam(value = "serverLocation", required = false) @ApiParam(value = "服务器地理位置", required = false) @Nullable String serverLocation + ) { + return R.ok(coreServerService.serverGetSingle( + serverName, + ipv4, + serverLocation + )); } @PostMapping("/serverCreate") @@ -67,7 +77,10 @@ public class ServerController { @PostMapping("/serverDelete") public R serverDelete(@RequestParam(value = "serverId") @Nullable Long serverId, @RequestParam(value = "serverName") @Nullable String serverName) { - if (coreServerService.serverDelete(serverId, serverName)) { + if (coreServerService.serverDelete( + serverId, + serverName + )) { R.ok("Delete Server Successfully !"); } @@ -91,7 +104,10 @@ public class ServerController { @PostMapping("/appCreate") public R appCreate(@RequestParam(value = "serverId", required = true) Long serverId, @RequestBody @Validated AppInfoVO appInfoVO) { - AppInfoVO newAppForServer = coreServerService.appCreate(serverId, appInfoVO); + AppInfoVO newAppForServer = coreServerService.appCreate( + serverId, + appInfoVO + ); if (ObjectUtils.isNotEmpty(newAppForServer)) { return R.ok(newAppForServer); @@ -106,7 +122,10 @@ public class ServerController { @PostMapping("/appDelete") public R appDelete(@RequestParam(value = "serverId", required = true) Long serverId, @RequestParam(value = "appId", required = true) Long appId) { - if (coreServerService.appDelete(serverId, appId)) { + if (coreServerService.appDelete( + serverId, + appId + )) { return R.ok("delete app successfully!"); } @@ -132,32 +151,42 @@ public class ServerController { } @GetMapping("domainGetSingle") - public R> domainGetSingle(@RequestParam(value = "serverId") Long serverId, @RequestParam(value = "domainName", required = false) @javax.annotation.Nullable String domainName, @RequestParam(value = "dnsIP", required = false) @javax.annotation.Nullable String dnsIP + public R> domainGetSingle( + @RequestParam(value = "serverId") Long serverId, @RequestParam(value = "domainName", required = false) @javax.annotation.Nullable String domainName, @RequestParam(value = "dnsIP", required = false) @javax.annotation.Nullable String dnsIP ) { - return R.ok(coreServerService.domainGetSingle(serverId, domainName, dnsIP)); + return R.ok(coreServerService.domainGetSingle( + serverId, + domainName, + dnsIP + )); } // create @PostMapping("domainCreate") public R domainCreate( @RequestParam(value = "serverId") Long serverId, - @RequestBody @Validated DomainInfoVO domainInfoVO) { + @RequestBody @Validated DomainInfoVO domainInfoVO + ) { - if (coreServerService.domainCreate(serverId, domainInfoVO)) { + if (coreServerService.domainCreate( + serverId, + domainInfoVO + )) { return R.ok("create domain successfully !"); } return R.failed("create domain failed !"); } - + // update @PostMapping("domainUpdate") public R update( @RequestParam(value = "serverId") Long serverId, - @RequestBody @Validated DomainInfoPO domainInfoPO) { + @RequestBody @Validated DomainInfoPO domainInfoPO + ) { if (coreServerService.domainUpdate(domainInfoPO)) { return R.ok("update domain successfully !"); @@ -173,7 +202,10 @@ public class ServerController { @RequestParam(value = "domainId") Long domainId ) { - if (coreServerService.domainDelete(serverId, domainId)) { + if (coreServerService.domainDelete( + serverId, + domainId + )) { return R.ok("delete domain successfully !"); } diff --git a/source/src/main/java/io/wdd/source/shell/lib/wdd-lib-sys.sh b/source/src/main/java/io/wdd/source/shell/lib/wdd-lib-sys.sh index 25f1d16..c9c722c 100644 --- a/source/src/main/java/io/wdd/source/shell/lib/wdd-lib-sys.sh +++ b/source/src/main/java/io/wdd/source/shell/lib/wdd-lib-sys.sh @@ -142,6 +142,8 @@ gcloud compute instances create tokyo-amd64-03 --project=compact-lacing-371804 - gcloud compute ssh --zone "asia-northeast1-b" "tokyo-amd64-03" --project "compact-lacing-371804" +gcloud compute instances list --project "compact-lacing-371804" + wget https://raw.githubusercontent.com/zeaslity/ProjectOctopus/main/source/src/main/java/io/wdd/source/shell/agent-bootup.sh && chmod +x agent-bootup.sh && /bin/bash agent-bootup.sh