[ server ] [ status ]- fix bug

This commit is contained in:
zeaslity
2023-02-02 16:47:35 +08:00
parent 5aacdae89b
commit 2fe8b8526f
3 changed files with 67 additions and 16 deletions

View File

@@ -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<String, String> 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(

View File

@@ -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<String> 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<AppInfoVO> 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<String> 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<List<DomainInfoVO>> 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<List<DomainInfoVO>> 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<String> 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<String> 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 !");
}