交换机采集数据优化

This commit is contained in:
qiminbao
2025-09-28 09:25:57 +08:00
parent 6c098b3950
commit 72626c2b69
2 changed files with 12 additions and 8 deletions
@@ -16,7 +16,7 @@ public class SchedulerConfig {
@Bean
public ThreadPoolTaskScheduler taskScheduler() {
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
scheduler.setPoolSize(10); // 核心线程数
scheduler.setPoolSize(50); // 核心线程数
scheduler.setThreadNamePrefix("dynamic-scheduler-");
scheduler.setAwaitTerminationSeconds(60);
scheduler.setWaitForTasksToCompleteOnShutdown(true);
@@ -28,7 +28,7 @@ public class SchedulerConfig {
@Bean("taskExecutor")
public ThreadPoolTaskScheduler taskExecutor() {
ThreadPoolTaskScheduler executor = new ThreadPoolTaskScheduler();
executor.setPoolSize(11); // 工作线程数
executor.setPoolSize(50); // 工作线程数
executor.setThreadNamePrefix("task-worker-");
executor.setAwaitTerminationSeconds(30);
executor.setWaitForTasksToCompleteOnShutdown(true);
@@ -106,7 +106,7 @@ public class AgentServiceImpl implements AgentService {
if(GlobalConfig.netCollect != collect || GlobalConfig.netInterval != interval){
GlobalConfig.netCollect = collect;
if(collect){
GlobalConfig.netInterval = interval;
// GlobalConfig.netInterval = interval;
long milli = AgentUtil.millisecondsToNext5Minute();
dynamicTaskService.scheduleTask(type,
businessTasks::netTask, milli, GlobalConfig.netInterval*1000L);
@@ -410,10 +410,10 @@ public class AgentServiceImpl implements AgentService {
if(GlobalConfig.switchNetCollect != collect || GlobalConfig.switchNetInterval != interval){
flag = true;
GlobalConfig.switchNetCollect = collect;
GlobalConfig.switchNetInterval = interval;
if(!collect){
GlobalConfig.switchNetInterval = 300;
}
// GlobalConfig.switchNetInterval = interval;
// if(!collect){
// GlobalConfig.switchNetInterval = 300;
// }
}
break;
case "switchModuleCollect": //光模块采集
@@ -598,7 +598,11 @@ public class AgentServiceImpl implements AgentService {
}
if (flag) {
if(collect){
long milli = AgentUtil.millisecondsToNext5Minute();
long milli = AgentUtil.getMillisToNextMinute() + 60000;
if(StringUtils.equals(type,"switchNetCollect")){
milli = AgentUtil.millisecondsToNext5Minute();
interval = 300;
}
dynamicTaskService.scheduleTask(type,
() -> businessTasks.switchBoardTask(type), milli, interval*1000L);
}else{