[ Server ] accomplish alive status precedure
This commit is contained in:
@@ -43,7 +43,7 @@ public class BuildStatusScheduleTask {
|
||||
private void buildAll() {
|
||||
|
||||
// Agent存活健康状态检查
|
||||
buildMonitorAllAgentStatusScheduleTask();
|
||||
buildMonitorAllAgentAliveStatusScheduleTask();
|
||||
|
||||
// Agent运行信息检查 Metric
|
||||
|
||||
@@ -99,12 +99,12 @@ public class BuildStatusScheduleTask {
|
||||
* 延迟触发时间 healthyCheckStartDelaySeconds
|
||||
* 定时任务间隔 healthyCronTimeExpress
|
||||
*/
|
||||
private void buildMonitorAllAgentStatusScheduleTask() {
|
||||
private void buildMonitorAllAgentAliveStatusScheduleTask() {
|
||||
|
||||
// build the Job
|
||||
octopusQuartzService.addMission(
|
||||
AgentAliveStatusMonitorJob.class,
|
||||
"monitorAllAgentStatusJob",
|
||||
"monitorAllAgentAliveStatusJob",
|
||||
JOB_GROUP_NAME,
|
||||
healthyCheckStartDelaySeconds,
|
||||
healthyCronTimeExpress,
|
||||
|
||||
@@ -49,8 +49,7 @@ public class AgentAliveStatusMonitorService {
|
||||
@Resource
|
||||
AsyncStatusService asyncStatusService;
|
||||
|
||||
|
||||
private HashMap<String, String> AGENT_HEALTHY_INIT_MAP;
|
||||
private HashMap<String, Boolean> AGENT_HEALTHY_INIT_MAP;
|
||||
|
||||
public void go() {
|
||||
|
||||
@@ -77,29 +76,27 @@ public class AgentAliveStatusMonitorService {
|
||||
updateAllAgentHealthyStatus(agentAliveStatusMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化Agent存活状态的Redis缓存的信息,全部设置为False,然后等待存活状态检测
|
||||
*/
|
||||
private void checkOrCreateRedisHealthyKey() {
|
||||
|
||||
// 检查开始的时候 需要手动将所有Agent的状态置为0
|
||||
// Agent如果存活,那么就可以将其自身状态修改为1
|
||||
|
||||
// build the redis all agent healthy map struct
|
||||
HashMap<String, String> initMap = new HashMap<>(32);
|
||||
HashMap<String, Boolean> initMap = new HashMap<>(32);
|
||||
ALL_AGENT_TOPIC_NAME_LIST
|
||||
.stream()
|
||||
.forEach(
|
||||
agentTopicName -> {
|
||||
initMap.put(
|
||||
agentTopicName,
|
||||
"0"
|
||||
Boolean.FALSE
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
initMap.put(
|
||||
"updateTime",
|
||||
TimeUtils.currentTimeString()
|
||||
);
|
||||
|
||||
// cache this map struct
|
||||
AGENT_HEALTHY_INIT_MAP = initMap;
|
||||
|
||||
@@ -111,6 +108,14 @@ public class AgentAliveStatusMonitorService {
|
||||
initMap
|
||||
);
|
||||
|
||||
redisTemplate
|
||||
.opsForHash()
|
||||
.put(
|
||||
ALL_AGENT_STATUS_REDIS_KEY,
|
||||
"initTime",
|
||||
TimeUtils.currentTimeString()
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
public void updateAllAgentHealthyStatus(Map<String, Boolean> agentAliveStatusMap) {
|
||||
@@ -123,6 +128,12 @@ public class AgentAliveStatusMonitorService {
|
||||
// 执行Metric上报定时任务
|
||||
// buildStatusScheduleTask.buildAgentMetricScheduleTask();
|
||||
|
||||
log.debug(
|
||||
"[存活状态] - 当前时间为 [ %s ] , 所有的Agent存活状态为=> %s",
|
||||
currentTimeString,
|
||||
agentAliveStatusMap
|
||||
);
|
||||
|
||||
// 这里仅仅是更新时间
|
||||
redisTemplate
|
||||
.opsForHash()
|
||||
|
||||
Reference in New Issue
Block a user