[ server ] [ status ]- fix bug
This commit is contained in:
@@ -161,15 +161,17 @@ public class MonitorAllAgentStatus {
|
|||||||
|
|
||||||
private void updateAllAgentHealthyStatus() {
|
private void updateAllAgentHealthyStatus() {
|
||||||
|
|
||||||
|
|
||||||
List statusList = redisTemplate
|
List statusList = redisTemplate
|
||||||
.opsForHash()
|
.opsForHash()
|
||||||
.multiGet(
|
.multiGet(
|
||||||
ALL_AGENT_STATUS_REDIS_KEY,
|
ALL_AGENT_STATUS_REDIS_KEY,
|
||||||
ALL_AGENT_TOPIC_NAME_LIST
|
ALL_AGENT_TOPIC_NAME_LIST
|
||||||
);
|
);
|
||||||
|
|
||||||
// current log to console is ok
|
// 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);
|
HashMap<String, String> agentStatusMap = new HashMap<>(32);
|
||||||
for (int i = 0; i < ALL_AGENT_TOPIC_NAME_LIST.size(); i++) {
|
for (int i = 0; i < ALL_AGENT_TOPIC_NAME_LIST.size(); i++) {
|
||||||
agentStatusMap.put(
|
agentStatusMap.put(
|
||||||
@@ -227,17 +229,32 @@ public class MonitorAllAgentStatus {
|
|||||||
allHealthyAgentTopicNames.add(ALL_AGENT_TOPIC_NAME_LIST.get(i));
|
allHealthyAgentTopicNames.add(ALL_AGENT_TOPIC_NAME_LIST.get(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 缓存相应的存活Agent
|
||||||
ALL_HEALTHY_AGENT_TOPIC_NAMES = allHealthyAgentTopicNames;
|
ALL_HEALTHY_AGENT_TOPIC_NAMES = allHealthyAgentTopicNames;
|
||||||
// 执行Metric上报任务
|
// 执行Metric上报任务
|
||||||
buildStatusScheduleTask.buildAgentMetricScheduleTask();
|
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
|
// update time
|
||||||
AGENT_HEALTHY_INIT_MAP.put(
|
AGENT_HEALTHY_INIT_MAP.put(
|
||||||
"updateTime",
|
"updateTime",
|
||||||
currentTimeString
|
currentTimeString
|
||||||
);
|
);
|
||||||
|
|
||||||
// init the healthy map
|
|
||||||
redisTemplate
|
redisTemplate
|
||||||
.opsForHash()
|
.opsForHash()
|
||||||
.putAll(
|
.putAll(
|
||||||
|
|||||||
@@ -3,13 +3,14 @@ package io.wdd.server.controller;
|
|||||||
|
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
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.DomainInfoPO;
|
||||||
import io.wdd.server.beans.po.ServerInfoPO;
|
import io.wdd.server.beans.po.ServerInfoPO;
|
||||||
import io.wdd.server.beans.vo.AppInfoVO;
|
import io.wdd.server.beans.vo.AppInfoVO;
|
||||||
import io.wdd.server.beans.vo.DomainInfoVO;
|
import io.wdd.server.beans.vo.DomainInfoVO;
|
||||||
import io.wdd.server.beans.vo.ServerInfoVO;
|
import io.wdd.server.beans.vo.ServerInfoVO;
|
||||||
import io.wdd.server.coreService.CoreServerService;
|
import io.wdd.server.coreService.CoreServerService;
|
||||||
import io.wdd.common.beans.response.R;
|
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
@@ -40,8 +41,17 @@ public class ServerController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/single")
|
@PostMapping("/single")
|
||||||
public R serverGetSingle(@RequestParam(value = "serverIPv4") @Nullable String ipv4, @RequestParam(value = "serverName") @Nullable String serverName, @RequestParam(value = "serverLocation") @Nullable String serverLocation) {
|
@ApiOperation("根据信息查询单个服务器信息")
|
||||||
return R.ok(coreServerService.serverGetSingle(serverName, ipv4, serverLocation));
|
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")
|
@PostMapping("/serverCreate")
|
||||||
@@ -67,7 +77,10 @@ public class ServerController {
|
|||||||
@PostMapping("/serverDelete")
|
@PostMapping("/serverDelete")
|
||||||
public R<String> serverDelete(@RequestParam(value = "serverId") @Nullable Long serverId, @RequestParam(value = "serverName") @Nullable String serverName) {
|
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 !");
|
R.ok("Delete Server Successfully !");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,7 +104,10 @@ public class ServerController {
|
|||||||
@PostMapping("/appCreate")
|
@PostMapping("/appCreate")
|
||||||
public R<AppInfoVO> appCreate(@RequestParam(value = "serverId", required = true) Long serverId, @RequestBody @Validated AppInfoVO appInfoVO) {
|
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)) {
|
if (ObjectUtils.isNotEmpty(newAppForServer)) {
|
||||||
return R.ok(newAppForServer);
|
return R.ok(newAppForServer);
|
||||||
@@ -106,7 +122,10 @@ public class ServerController {
|
|||||||
@PostMapping("/appDelete")
|
@PostMapping("/appDelete")
|
||||||
public R<String> appDelete(@RequestParam(value = "serverId", required = true) Long serverId, @RequestParam(value = "appId", required = true) Long appId) {
|
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!");
|
return R.ok("delete app successfully!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,32 +151,42 @@ public class ServerController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("domainGetSingle")
|
@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
|
// create
|
||||||
@PostMapping("domainCreate")
|
@PostMapping("domainCreate")
|
||||||
public R<String> domainCreate(
|
public R<String> domainCreate(
|
||||||
@RequestParam(value = "serverId") Long serverId,
|
@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.ok("create domain successfully !");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return R.failed("create domain failed !");
|
return R.failed("create domain failed !");
|
||||||
}
|
}
|
||||||
|
|
||||||
// update
|
// update
|
||||||
@PostMapping("domainUpdate")
|
@PostMapping("domainUpdate")
|
||||||
public R<String> update(
|
public R<String> update(
|
||||||
@RequestParam(value = "serverId") Long serverId,
|
@RequestParam(value = "serverId") Long serverId,
|
||||||
@RequestBody @Validated DomainInfoPO domainInfoPO) {
|
@RequestBody @Validated DomainInfoPO domainInfoPO
|
||||||
|
) {
|
||||||
|
|
||||||
if (coreServerService.domainUpdate(domainInfoPO)) {
|
if (coreServerService.domainUpdate(domainInfoPO)) {
|
||||||
return R.ok("update domain successfully !");
|
return R.ok("update domain successfully !");
|
||||||
@@ -173,7 +202,10 @@ public class ServerController {
|
|||||||
@RequestParam(value = "domainId") Long domainId
|
@RequestParam(value = "domainId") Long domainId
|
||||||
) {
|
) {
|
||||||
|
|
||||||
if (coreServerService.domainDelete(serverId, domainId)) {
|
if (coreServerService.domainDelete(
|
||||||
|
serverId,
|
||||||
|
domainId
|
||||||
|
)) {
|
||||||
return R.ok("delete domain successfully !");
|
return R.ok("delete domain successfully !");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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 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
|
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
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user