use of com.dtstack.taier.common.enums.Deleted in project Taier by DTStack.
the class AbstractJobScanningScheduler method scanningJob.
/**
* 扫描实例
*/
private void scanningJob() {
try {
String nodeAddress = zkService.getLocalAddress();
// 1. 获得节点信息
if (StringUtils.isBlank(nodeAddress)) {
return;
}
LOGGER.info("scanningJob start scheduleType : {} nodeAddress:{}", getSchedulerName(), nodeAddress);
// 2. 获得排序最小序号
Long minSort = getMinSort();
LOGGER.info("scanning start param: scheduleType {} nodeAddress {} minSort {} ", getSchedulerName(), nodeAddress, minSort);
// 3. 扫描实例
List<ScheduleJobDetails> scheduleJobDetails = listExecJob(minSort, nodeAddress, Boolean.TRUE);
while (CollectionUtils.isNotEmpty(scheduleJobDetails)) {
// 查询任务
List<Long> taskIds = scheduleJobDetails.stream().map(ScheduleJobDetails::getScheduleJob).map(ScheduleJob::getTaskId).collect(Collectors.toList());
Map<Long, ScheduleTaskShade> scheduleTaskShadeMap = scheduleTaskService.lambdaQuery().in(ScheduleTaskShade::getTaskId, taskIds).eq(ScheduleTaskShade::getIsDeleted, Deleted.NORMAL.getStatus()).list().stream().collect(Collectors.toMap(ScheduleTaskShade::getTaskId, g -> (g)));
for (ScheduleJobDetails scheduleJobDetail : scheduleJobDetails) {
// 提交实例
ScheduleJob scheduleJob = scheduleJobDetail.getScheduleJob();
ScheduleTaskShade scheduleTaskShade = scheduleTaskShadeMap.get(scheduleJob.getTaskId());
if (scheduleTaskShade == null) {
String errMsg = JobCheckStatus.NO_TASK.getMsg();
scheduleJobService.updateStatusAndLogInfoById(scheduleJob.getJobId(), TaskStatus.SUBMITFAILD.getStatus(), errMsg);
LOGGER.warn("jobId:{} scheduleType:{} submit failed for taskId:{} already deleted.", scheduleJob.getJobId(), getSchedulerName(), scheduleJob.getTaskId());
continue;
}
scheduleJobDetail.setScheduleTaskShade(scheduleTaskShade);
if (isSubmitJob(scheduleJobDetail)) {
submitJob(scheduleJobDetail);
}
if (minSort < scheduleJob.getJobExecuteOrder()) {
minSort = scheduleJob.getJobExecuteOrder();
}
}
scheduleJobDetails = listExecJob(minSort, nodeAddress, Boolean.FALSE);
}
} catch (Exception e) {
LOGGER.error("scheduleType:{} emitJob2Queue error:", getSchedulerName(), e);
}
}
Aggregations