[ Status ] optimize the code

This commit is contained in:
IceDerce
2023-06-15 17:03:22 +08:00
parent 4b3f7be1dd
commit 54569cc41b
17 changed files with 123 additions and 157 deletions

View File

@@ -4,7 +4,8 @@ package io.wdd.rpc.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.wdd.common.response.R;
import io.wdd.rpc.init.AgentStatusCacheService;
import io.wdd.rpc.scheduler.service.status.AgentAliveStatusMonitorService;
import io.wdd.rpc.status.service.AsyncStatusService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -23,11 +24,14 @@ import static io.wdd.rpc.init.AgentStatusCacheService.*;
public class StatusController {
@Resource
AgentStatusCacheService agentStatusCacheService;
AsyncStatusService asyncStatusService;
@Resource
AgentAliveStatusMonitorService agentAliveStatusMonitorService;
@ApiOperation("[ Agent-状态 ] Map")
@GetMapping("/agent/status")
public R<Map<String, String>> GetAllAgentHealthyStatus() {
public R<Map<String, Boolean>> GetAllAgentHealthyStatus() {
return R.ok(ALL_AGENT_STATUS_MAP);
}
@@ -76,7 +80,9 @@ public class StatusController {
public R<Map<String, List<String>>> ManualUpdateAgentStatus() {
// 手动调用更新
agentStatusCacheService.updateAgentStatusMapCache(agentAliveStatusMap);
Map<String, Boolean> agentAliveStatusMap = asyncStatusService.AsyncCollectAgentAliveStatus(ALL_AGENT_TOPIC_NAME_LIST, 5);
agentAliveStatusMonitorService.updateAllAgentHealthyStatus(agentAliveStatusMap);
return R.ok(STATUS_AGENT_LIST_MAP);
}