[Exec] modify sync and async execution function
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package io.wdd.rpc.scheduler.job;
|
||||
|
||||
import io.wdd.rpc.scheduler.config.QuartzLogOperator;
|
||||
import io.wdd.rpc.scheduler.service.status.MonitorAllAgentStatus;
|
||||
import io.wdd.rpc.scheduler.service.status.CheckAgentAliveStatus;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.springframework.scheduling.quartz.QuartzJobBean;
|
||||
@@ -11,7 +11,7 @@ import javax.annotation.Resource;
|
||||
public class AgentStatusMonitorJob extends QuartzJobBean {
|
||||
|
||||
@Resource
|
||||
MonitorAllAgentStatus monitorAllAgentStatus;
|
||||
CheckAgentAliveStatus checkAgentAliveStatus;
|
||||
|
||||
@Resource
|
||||
QuartzLogOperator quartzLogOperator;
|
||||
@@ -23,7 +23,7 @@ public class AgentStatusMonitorJob extends QuartzJobBean {
|
||||
//JobDataMap jobDataMap = jobExecutionContext.getJobDetail().getJobDataMap();
|
||||
|
||||
// actually execute the monitor service
|
||||
monitorAllAgentStatus.go();
|
||||
checkAgentAliveStatus.go();
|
||||
|
||||
// log to somewhere
|
||||
quartzLogOperator.save();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package io.wdd.rpc.scheduler.service.script;
|
||||
|
||||
|
||||
import io.wdd.rpc.execute.service.AsyncExecutionService;
|
||||
import io.wdd.rpc.execute.service.SyncExecutionService;
|
||||
import io.wdd.rpc.scheduler.beans.ScriptSchedulerDTO;
|
||||
import io.wdd.rpc.scheduler.config.QuartzSchedulerUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -20,7 +20,7 @@ import java.util.List;
|
||||
public class AgentApplyScheduledScript {
|
||||
|
||||
@Resource
|
||||
AsyncExecutionService asyncExecutionService;
|
||||
SyncExecutionService asyncExecutionService;
|
||||
|
||||
@Resource
|
||||
QuartzSchedulerUtils quartzSchedulerUtils;
|
||||
@@ -46,7 +46,7 @@ public class AgentApplyScheduledScript {
|
||||
|
||||
// 发送命令到Agent中
|
||||
List<String> resultKeyList = asyncExecutionService
|
||||
.SendCommandToAgentComplete(
|
||||
.SyncSendCommandToAgentComplete(
|
||||
targetMachineList,
|
||||
scriptType,
|
||||
completeCommandList,
|
||||
|
||||
@@ -10,7 +10,7 @@ import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static io.wdd.rpc.init.ServerCacheAgentStatus.ALL_HEALTHY_AGENT_TOPIC_NAME_LIST;
|
||||
import static io.wdd.rpc.init.AgentStatusCacheService.ALL_HEALTHY_AGENT_TOPIC_NAME_LIST;
|
||||
import static io.wdd.rpc.status.OctopusStatusMessage.METRIC_STATUS_MESSAGE_TYPE;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package io.wdd.rpc.scheduler.service.status;
|
||||
|
||||
import io.wdd.common.utils.TimeUtils;
|
||||
import io.wdd.rpc.init.ServerCacheAgentStatus;
|
||||
import io.wdd.rpc.init.AgentStatusCacheService;
|
||||
import io.wdd.rpc.scheduler.service.BuildStatusScheduleTask;
|
||||
import io.wdd.rpc.status.OctopusStatusMessage;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -13,10 +13,11 @@ import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static io.wdd.rpc.init.ServerCacheAgentStatus.ALL_AGENT_TOPIC_NAME_LIST;
|
||||
import static io.wdd.rpc.init.AgentStatusCacheService.ALL_AGENT_TOPIC_NAME_LIST;
|
||||
import static io.wdd.rpc.status.OctopusStatusMessage.ALL_AGENT_STATUS_REDIS_KEY;
|
||||
import static io.wdd.rpc.status.OctopusStatusMessage.HEALTHY_STATUS_MESSAGE_TYPE;
|
||||
|
||||
@@ -37,7 +38,7 @@ import static io.wdd.rpc.status.OctopusStatusMessage.HEALTHY_STATUS_MESSAGE_TYPE
|
||||
@Service
|
||||
@Slf4j
|
||||
@Lazy
|
||||
public class MonitorAllAgentStatus {
|
||||
public class CheckAgentAliveStatus {
|
||||
|
||||
private static final int MAX_WAIT_AGENT_REPORT_STATUS_TIME = 5;
|
||||
@Resource
|
||||
@@ -46,7 +47,7 @@ public class MonitorAllAgentStatus {
|
||||
CollectAgentStatus collectAgentStatus;
|
||||
|
||||
@Resource
|
||||
ServerCacheAgentStatus serverCacheAgentStatus;
|
||||
AgentStatusCacheService agentStatusCacheService;
|
||||
|
||||
@Resource
|
||||
BuildStatusScheduleTask buildStatusScheduleTask;
|
||||
@@ -57,7 +58,7 @@ public class MonitorAllAgentStatus {
|
||||
|
||||
try {
|
||||
// 1. 获取所有注册的Agent 手动更新
|
||||
serverCacheAgentStatus.updateAllAgentTopicNameCache();
|
||||
agentStatusCacheService.updateAllAgentTopicNameCache();
|
||||
if (CollectionUtils.isEmpty(ALL_AGENT_TOPIC_NAME_LIST)) {
|
||||
log.warn("[Scheduler] No Agent Registered ! End Up Status Monitor !");
|
||||
return;
|
||||
@@ -67,6 +68,10 @@ public class MonitorAllAgentStatus {
|
||||
checkOrCreateRedisHealthyKey();
|
||||
|
||||
// 2.发送状态检查信息, agent需要update相应的HashMap的值
|
||||
// 2023年6月14日 2. 发送ping等待所有的Agent返回PONG, 然后进行redis的状态修改
|
||||
CountDownLatch aliveStatusCDL = new CountDownLatch(ALL_AGENT_TOPIC_NAME_LIST.size());
|
||||
|
||||
|
||||
buildAndSendAgentHealthMessage();
|
||||
|
||||
// 3. 休眠 MAX_WAIT_AGENT_REPORT_STATUS_TIME 秒 等待agent的状态上报
|
||||
@@ -139,7 +144,7 @@ public class MonitorAllAgentStatus {
|
||||
String currentTimeString = TimeUtils.currentTimeString();
|
||||
|
||||
// 更新所有的缓存状态
|
||||
serverCacheAgentStatus.updateAgentStatusMapCache();
|
||||
agentStatusCacheService.updateAgentStatusMapCache();
|
||||
|
||||
// 执行Metric上报定时任务
|
||||
buildStatusScheduleTask.buildAgentMetricScheduleTask();
|
||||
Reference in New Issue
Block a user