|
| 1 | +/* |
| 2 | + * Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0. |
| 3 | + */ |
| 4 | +package io.holoinsight.server.home.task; |
| 5 | + |
| 6 | +import io.holoinsight.server.common.model.CLUSTER_ROLE_CONST; |
| 7 | +import io.holoinsight.server.common.service.AlarmHistoryDetailService; |
| 8 | +import io.holoinsight.server.common.service.AlarmMetricService; |
| 9 | +import io.holoinsight.server.common.service.FolderService; |
| 10 | +import io.holoinsight.server.common.service.MetricInfoService; |
| 11 | +import io.holoinsight.server.home.biz.service.CustomPluginService; |
| 12 | +import org.springframework.beans.factory.annotation.Autowired; |
| 13 | +import org.springframework.stereotype.Service; |
| 14 | + |
| 15 | +import java.util.ArrayList; |
| 16 | +import java.util.List; |
| 17 | + |
| 18 | +/** |
| 19 | + * @author limengyang |
| 20 | + * @version MonitorAlarmRrdTask.java, v 0.1 2024年09月19日 15:41 limengyang |
| 21 | + */ |
| 22 | +@Service |
| 23 | +@TaskHandler(code = "MONITOR_ALARM_RRD") |
| 24 | +public class MonitorAlarmRrdTask extends AbstractMonitorTask { |
| 25 | + |
| 26 | + public final static String TASK_ID = "MONITOR_ALARM_RRD"; |
| 27 | + |
| 28 | + public final static Long PERIOD = 5 * MINUTE; |
| 29 | + |
| 30 | + @Autowired |
| 31 | + private AlarmHistoryDetailService alarmHistoryDetailService; |
| 32 | + |
| 33 | + @Autowired |
| 34 | + private CustomPluginService customPluginService; |
| 35 | + |
| 36 | + @Autowired |
| 37 | + private FolderService folderService; |
| 38 | + |
| 39 | + @Autowired |
| 40 | + private MetricInfoService metricInfoService; |
| 41 | + |
| 42 | + @Autowired |
| 43 | + private AlarmMetricService alarmMetricService; |
| 44 | + |
| 45 | + |
| 46 | + public MonitorAlarmRrdTask() { |
| 47 | + super(1, 10, "MONITOR_ALARM_RRD"); |
| 48 | + } |
| 49 | + |
| 50 | + @Override |
| 51 | + public long getTaskPeriod() { |
| 52 | + return PERIOD; |
| 53 | + } |
| 54 | + |
| 55 | + @Override |
| 56 | + public boolean needRun() { |
| 57 | + return true; |
| 58 | + } |
| 59 | + |
| 60 | + @Override |
| 61 | + public List<MonitorTaskJob> buildJobs(long period) { |
| 62 | + List<MonitorTaskJob> jobs = new ArrayList<>(); |
| 63 | + jobs.add(new MonitorAlarmRrdTaskJob(period, alarmHistoryDetailService, customPluginService, |
| 64 | + metricInfoService, alarmMetricService, folderService)); |
| 65 | + return jobs; |
| 66 | + } |
| 67 | + |
| 68 | + public String getRole() { |
| 69 | + // 代表执行本任务的具体Role |
| 70 | + return CLUSTER_ROLE_CONST.META; |
| 71 | + } |
| 72 | + |
| 73 | +} |
0 commit comments