|
|
@@ -1,21 +1,12 @@
|
|
|
package cn.reghao.autodop.dmaster.monitor.service;
|
|
|
|
|
|
-import cn.reghao.autodop.common.http.DefaultWebRequest;
|
|
|
-import cn.reghao.autodop.common.http.WebRequest;
|
|
|
-import cn.reghao.autodop.dmaster.app.repository.AppRunningRepository;
|
|
|
-import cn.reghao.autodop.dmaster.machine.db.crud.MachineStatCrudService;
|
|
|
import cn.reghao.autodop.dmaster.monitor.entity.MonitorJob;
|
|
|
import cn.reghao.autodop.dmaster.monitor.repository.MonitorJobRepository;
|
|
|
import cn.reghao.autodop.dmaster.notification.entity.NotifyGroup;
|
|
|
-import cn.reghao.autodop.dmaster.notification.service.NotifyService;
|
|
|
-import cn.reghao.autodop.dmaster.utils.clazz.PackageScanner;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.quartz.JobDataMap;
|
|
|
import org.quartz.SchedulerException;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.io.IOException;
|
|
|
-
|
|
|
/**
|
|
|
* @author reghao
|
|
|
* @date 2020-10-22 17:51:56
|
|
|
@@ -25,61 +16,10 @@ import java.io.IOException;
|
|
|
public class MonitorServiceImpl implements MonitorService {
|
|
|
private MonitorScheduler monitorScheduler;
|
|
|
private MonitorJobRepository monitorJobRepository;
|
|
|
- private MachineStatCrudService statCrudService;
|
|
|
- private AppRunningRepository runningRepository;
|
|
|
- private NotifyService notifyService;
|
|
|
- private PackageScanner packageScanner;
|
|
|
- private WebRequest webRequest;
|
|
|
|
|
|
- public MonitorServiceImpl(MonitorScheduler monitorScheduler,
|
|
|
- MonitorJobRepository monitorJobRepository,
|
|
|
- MachineStatCrudService statCrudService,
|
|
|
- AppRunningRepository runningRepository,
|
|
|
- NotifyService notifyService) {
|
|
|
+ public MonitorServiceImpl(MonitorScheduler monitorScheduler, MonitorJobRepository monitorJobRepository) {
|
|
|
this.monitorScheduler = monitorScheduler;
|
|
|
this.monitorJobRepository = monitorJobRepository;
|
|
|
- this.statCrudService = statCrudService;
|
|
|
- this.runningRepository = runningRepository;
|
|
|
- this.notifyService = notifyService;
|
|
|
- this.packageScanner = new PackageScanner();
|
|
|
- this.webRequest = new DefaultWebRequest();
|
|
|
- }
|
|
|
-
|
|
|
- public void startMachineMonitorJob(String machineId, String jobClassName) throws IOException, SchedulerException {
|
|
|
- /*String jobId = String.format("%s-%s", machineId, jobClassName);
|
|
|
- MonitorJob MonitorJob = MonitorJobRepository.findByMachineId(machineId);
|
|
|
- MonitorJob monitorJob = MonitorJob.getJobMap().get(jobId);
|
|
|
-
|
|
|
- List<NotifyGroup> notifyGroups = MonitorJob.getNotifyGroups();
|
|
|
- String cronExp = monitorJob.getCronExp();
|
|
|
- String jobPkg = "cn.reghao.autodop.dmaster.monitor.service.job";
|
|
|
- Class jobClass = packageScanner.findClassBySimpleName(monitorJob.getJobClassName(), jobPkg);
|
|
|
-
|
|
|
- JobDataMap jobDataMap = new JobDataMap();
|
|
|
- jobDataMap.put("notifyService", notifyService);
|
|
|
- jobDataMap.put("notifyGroups", notifyGroups);
|
|
|
- jobDataMap.put("machineId", MonitorJob.getMachineId());
|
|
|
- jobDataMap.put("statCrudService", statCrudService);
|
|
|
- monitorScheduler.addJob(jobId, cronExp, jobClass, jobDataMap);*/
|
|
|
- }
|
|
|
-
|
|
|
- public void startAppMonitorJob(String appId, String machineId, String jobClassName)
|
|
|
- throws IOException, SchedulerException {
|
|
|
- String jobId = String.format("%s-%s-%s", appId, machineId, jobClassName);
|
|
|
- MonitorJob monitorJob = monitorJobRepository.findByJobId(jobId);
|
|
|
-
|
|
|
- String cronExp = monitorJob.getCronExp();
|
|
|
- String jobPkg = "cn.reghao.autodop.dmaster.monitor.service.job";
|
|
|
- Class jobClass = packageScanner.findClassBySimpleName(monitorJob.getJobClassName(), jobPkg);
|
|
|
-
|
|
|
- JobDataMap jobDataMap = new JobDataMap();
|
|
|
- jobDataMap.put("notifyService", notifyService);
|
|
|
- jobDataMap.put("notifyGroups", monitorJob.getNotifyGroups());
|
|
|
- jobDataMap.put("webRequest", webRequest);
|
|
|
- jobDataMap.put("appId", appId);
|
|
|
- jobDataMap.put("machineId", machineId);
|
|
|
- jobDataMap.put("runningRepository", runningRepository);
|
|
|
- monitorScheduler.addJob(monitorJob.getJobId(), cronExp, jobClass, jobDataMap);
|
|
|
}
|
|
|
|
|
|
@Override
|