Search in sources :

Example 1 with JobManagerReasonResult

use of com.baidu.hugegraph.entity.load.JobManagerReasonResult in project incubator-hugegraph-toolchain by apache.

the class JobManagerController method reason.

@GetMapping("{id}/reason")
public Response reason(@PathVariable("connId") int connId, @PathVariable("id") int id) {
    JobManager job = this.service.get(id);
    if (job == null) {
        throw new ExternalException("job.manager.not-exist.id", id);
    }
    List<LoadTask> tasks = this.taskService.batchTasks(job.getId());
    List<JobManagerReasonResult> reasonResults = new ArrayList<>();
    tasks.forEach(task -> {
        JobManagerReasonResult reasonResult = new JobManagerReasonResult();
        int fileId = task.getFileId();
        String reason = "";
        if (task.getStatus() == LoadStatus.FAILED) {
            FileMapping mapping = this.fmService.get(fileId);
            reason = this.taskService.readLoadFailedReason(mapping);
        }
        reasonResult.setTaskId(task.getJobId());
        reasonResult.setFileId(task.getFileId());
        reasonResult.setFileName(task.getFileName());
        reasonResult.setReason(reason);
        reasonResults.add(reasonResult);
    });
    return Response.builder().status(Constant.STATUS_OK).data(reasonResults).build();
}
Also used : LoadTask(com.baidu.hugegraph.entity.load.LoadTask) FileMapping(com.baidu.hugegraph.entity.load.FileMapping) ArrayList(java.util.ArrayList) JobManager(com.baidu.hugegraph.entity.load.JobManager) ExternalException(com.baidu.hugegraph.exception.ExternalException) JobManagerReasonResult(com.baidu.hugegraph.entity.load.JobManagerReasonResult) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Aggregations

FileMapping (com.baidu.hugegraph.entity.load.FileMapping)1 JobManager (com.baidu.hugegraph.entity.load.JobManager)1 JobManagerReasonResult (com.baidu.hugegraph.entity.load.JobManagerReasonResult)1 LoadTask (com.baidu.hugegraph.entity.load.LoadTask)1 ExternalException (com.baidu.hugegraph.exception.ExternalException)1 ArrayList (java.util.ArrayList)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1