92 lines
2.5 KiB
Java
92 lines
2.5 KiB
Java
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.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;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
import javax.annotation.Resource;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
import static io.wdd.rpc.init.AgentStatusCacheService.*;
|
|
|
|
|
|
@RestController
|
|
@Api(value = "Agent运行状态Controller", tags = "Status")
|
|
@RequestMapping("/octopus/server/status")
|
|
public class StatusController {
|
|
|
|
@Resource
|
|
AsyncStatusService asyncStatusService;
|
|
|
|
@Resource
|
|
AgentAliveStatusMonitorService agentAliveStatusMonitorService;
|
|
|
|
@ApiOperation("[ Agent-状态 ] Map")
|
|
@GetMapping("/agent/status")
|
|
public R<Map<String, Boolean>> GetAllAgentHealthyStatus() {
|
|
|
|
return R.ok(ALL_AGENT_STATUS_MAP);
|
|
}
|
|
|
|
@ApiOperation("[ 状态-Agent ] Map")
|
|
@GetMapping("/status/agent")
|
|
public R<Map<String, List<String>>> GetHealthyStatusAgentList() {
|
|
|
|
return R.ok(STATUS_AGENT_LIST_MAP);
|
|
}
|
|
|
|
@ApiOperation("[ Agent ] - 所有的Agent主机")
|
|
@PostMapping("/agent/all")
|
|
public R<List<String>> GetAllAgentTopicNameList() {
|
|
|
|
return R.ok(ALL_AGENT_TOPIC_NAME_LIST);
|
|
}
|
|
|
|
|
|
@ApiOperation("[ Agent ] - 所有主机String")
|
|
@PostMapping("/agent/all/string")
|
|
public R<String> GetAllAgentString() {
|
|
|
|
|
|
String data = ALL_AGENT_TOPIC_NAME_LIST.toString();
|
|
data.replace("[",
|
|
"");
|
|
data.replace("]",
|
|
"");
|
|
return R.ok(
|
|
data
|
|
);
|
|
|
|
}
|
|
|
|
|
|
@ApiOperation("[ Agent ] - 健康的Agent主机")
|
|
@PostMapping("/agent/healthy")
|
|
public R<List<String>> GetAllHealthyAgent() {
|
|
|
|
return R.ok(ALL_HEALTHY_AGENT_TOPIC_NAME_LIST);
|
|
}
|
|
|
|
@ApiOperation("手动更新Agent的状态")
|
|
@PostMapping("/agent/status/update")
|
|
public R<Map<String, List<String>>> ManualUpdateAgentStatus() {
|
|
|
|
// 手动调用更新
|
|
Map<String, Boolean> agentAliveStatusMap = asyncStatusService.AsyncCollectAgentAliveStatus(ALL_AGENT_TOPIC_NAME_LIST, 5);
|
|
|
|
agentAliveStatusMonitorService.updateAllAgentHealthyStatus(agentAliveStatusMap);
|
|
|
|
return R.ok(STATUS_AGENT_LIST_MAP);
|
|
}
|
|
|
|
|
|
}
|