优化交换机心跳监测功能
This commit is contained in:
+5
-6
@@ -265,10 +265,6 @@ public class MultiSwitchCollectionScheduler {
|
||||
log.error("SNMP采集器未初始化,无法启动交换机 {} 的心跳检测任务", switchIp);
|
||||
return null;
|
||||
}
|
||||
// 创建Cron表达式:每30s执行一次
|
||||
String cronExpression = "30 * * * * ?";
|
||||
|
||||
|
||||
Runnable heartbeatTask = () -> {
|
||||
try {
|
||||
// 获取当前时间作为检测时间戳
|
||||
@@ -319,8 +315,11 @@ public class MultiSwitchCollectionScheduler {
|
||||
}
|
||||
};
|
||||
|
||||
CronTrigger trigger = new CronTrigger(cronExpression);
|
||||
ScheduledFuture<?> future = taskScheduler.schedule(heartbeatTask, trigger);
|
||||
long intervalSeconds = 30L;
|
||||
Duration initialDelay = Duration.ofSeconds(10);
|
||||
Duration interval = Duration.ofSeconds(intervalSeconds);
|
||||
ScheduledFuture<?> future = taskScheduler.scheduleWithFixedDelay(
|
||||
heartbeatTask, Instant.now().plus(initialDelay), interval);
|
||||
|
||||
log.info("交换机 {} 心跳检测任务启动,检测间隔: 30秒", switchIp);
|
||||
return future;
|
||||
|
||||
Reference in New Issue
Block a user