Search in sources :

Example 1 with JobStatus

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;
}
Also used : LoadTask(com.baidu.hugegraph.entity.load.LoadTask) JobStatus(com.baidu.hugegraph.entity.enums.JobStatus) Page(com.baomidou.mybatisplus.extension.plugins.pagination.Page) IPage(com.baomidou.mybatisplus.core.metadata.IPage) JobManager(com.baidu.hugegraph.entity.load.JobManager) Date(java.util.Date)

Aggregations

JobStatus (com.baidu.hugegraph.entity.enums.JobStatus)1 JobManager (com.baidu.hugegraph.entity.load.JobManager)1 LoadTask (com.baidu.hugegraph.entity.load.LoadTask)1 IPage (com.baomidou.mybatisplus.core.metadata.IPage)1 Page (com.baomidou.mybatisplus.extension.plugins.pagination.Page)1 Date (java.util.Date)1