use of com.baidu.hugegraph.entity.enums.JobStatus in project incubator-hugegraph-toolchain by apache.
the class JobManagerService method list.
public IPage<JobManager> list(int connId, int pageNo, int pageSize, String content) {
QueryWrapper<JobManager> query = Wrappers.query();
query.eq("conn_id", connId);
if (!content.isEmpty()) {
query.like("job_name", content);
}
query.orderByDesc("create_time");
Page<JobManager> page = new Page<>(pageNo, pageSize);
IPage<JobManager> list = this.mapper.selectPage(page, query);
list.getRecords().forEach(task -> {
if (task.getJobStatus() == JobStatus.LOADING) {
List<LoadTask> tasks = this.taskService.taskListByJob(task.getId());
JobStatus status = JobStatus.SUCCESS;
for (LoadTask loadTask : tasks) {
if (loadTask.getStatus().inRunning() || loadTask.getStatus() == LoadStatus.PAUSED || loadTask.getStatus() == LoadStatus.STOPPED) {
status = JobStatus.LOADING;
break;
}
if (loadTask.getStatus() == LoadStatus.FAILED) {
status = JobStatus.FAILED;
break;
}
}
if (status == JobStatus.SUCCESS || status == JobStatus.FAILED) {
task.setJobStatus(status);
this.update(task);
}
}
Date endDate = task.getJobStatus() == JobStatus.FAILED || task.getJobStatus() == JobStatus.SUCCESS ? task.getUpdateTime() : HubbleUtil.nowDate();
task.setJobDuration(endDate.getTime() - task.getCreateTime().getTime());
});
return list;
}
Aggregations