use of com.baidu.hugegraph.entity.load.JobManager in project incubator-hugegraph-toolchain by apache.
the class LoadTaskController method reason.
@GetMapping("{id}/reason")
public Response reason(@PathVariable("connId") int connId, @PathVariable("jobId") int jobId, @PathVariable("id") int id) {
LoadTask task = this.service.get(id);
if (task == null) {
throw new ExternalException("load.task.not-exist.id", id);
}
JobManager jobEntity = this.jobService.get(jobId);
Ex.check(jobEntity != null, "job-manager.not-exist.id", jobId);
Integer fileId = task.getFileId();
FileMapping mapping = this.fmService.get(fileId);
String reason = this.service.readLoadFailedReason(mapping);
return Response.builder().status(Constant.STATUS_OK).data(reason).build();
}
use of com.baidu.hugegraph.entity.load.JobManager in project incubator-hugegraph-toolchain by apache.
the class LoadTaskController method start.
@PostMapping("start")
public List<LoadTask> start(@PathVariable("connId") int connId, @PathVariable("jobId") int jobId, @RequestParam("file_mapping_ids") List<Integer> fileIds) {
GraphConnection connection = this.connService.get(connId);
if (connection == null) {
throw new ExternalException("graph-connection.not-exist.id", connId);
}
JobManager jobEntity = this.jobService.get(jobId);
Ex.check(jobEntity != null, "job-manager.not-exist.id", jobId);
Ex.check(jobEntity.getJobStatus() == JobStatus.SETTING, "load.task.start.no-permission");
boolean existError = false;
try {
List<LoadTask> tasks = new ArrayList<>();
for (Integer fileId : fileIds) {
FileMapping fileMapping = this.fmService.get(fileId);
if (fileMapping == null) {
throw new ExternalException("file-mapping.not-exist.id", fileId);
}
tasks.add(this.service.start(connection, fileMapping));
}
return tasks;
} catch (Exception e) {
existError = true;
throw e;
} finally {
if (existError) {
jobEntity.setJobStatus(JobStatus.FAILED);
} else {
jobEntity.setJobStatus(JobStatus.LOADING);
}
jobEntity.setUpdateTime(HubbleUtil.nowDate());
this.jobService.update(jobEntity);
}
}
use of com.baidu.hugegraph.entity.load.JobManager in project incubator-hugegraph-toolchain by apache.
the class LoadTaskController method pause.
@PostMapping("pause")
public LoadTask pause(@PathVariable("connId") int connId, @PathVariable("jobId") int jobId, @RequestParam("task_id") int taskId) {
GraphConnection connection = this.connService.get(connId);
if (connection == null) {
throw new ExternalException("graph-connection.not-exist.id", connId);
}
JobManager jobEntity = this.jobService.get(jobId);
Ex.check(jobEntity != null, "job-manager.not-exist.id", jobId);
Ex.check(jobEntity.getJobStatus() == JobStatus.LOADING, "load.task.pause.no-permission");
try {
return this.service.pause(taskId);
} finally {
jobEntity.setJobStatus(JobStatus.LOADING);
jobEntity.setUpdateTime(HubbleUtil.nowDate());
this.jobService.update(jobEntity);
}
}
use of com.baidu.hugegraph.entity.load.JobManager in project incubator-hugegraph-toolchain by apache.
the class FileMappingController method nextStep.
@PutMapping("next-step")
public JobManager nextStep(@PathVariable("jobId") int jobId) {
JobManager jobEntity = this.jobService.get(jobId);
Ex.check(jobEntity != null, "job-manager.not-exist.id", jobId);
Ex.check(jobEntity.getJobStatus() == JobStatus.MAPPING, "job.manager.status.unexpected", JobStatus.MAPPING, jobEntity.getJobStatus());
jobEntity.setJobStatus(JobStatus.SETTING);
this.jobService.update(jobEntity);
return jobEntity;
}
use of com.baidu.hugegraph.entity.load.JobManager in project incubator-hugegraph-toolchain by apache.
the class JobManagerController method update.
@PutMapping("{id}")
public JobManager update(@PathVariable("connId") int connId, @PathVariable("id") int id, @RequestBody JobManager newEntity) {
Ex.check(newEntity.getJobName().length() <= 48, "job.manager.job-name.reached-limit");
Ex.check(newEntity.getJobName() != null, () -> Constant.COMMON_NAME_PATTERN.matcher(newEntity.getJobName()).matches(), "job.manager.job-name.unmatch-regex");
Ex.check(!StringUtils.isEmpty(newEntity.getJobRemarks()), () -> Constant.COMMON_REMARK_PATTERN.matcher(newEntity.getJobRemarks()).matches(), "job.manager.job-remarks.unmatch-regex");
// Check exist Job Manager with this id
JobManager entity = this.service.get(id);
if (entity == null) {
throw new ExternalException("job-manager.not-exist.id", id);
}
if (!newEntity.getJobName().equals(entity.getJobName()) && this.service.getTask(newEntity.getJobName(), connId) != null) {
throw new InternalException("job.manager.job-name.repeated");
}
entity.setJobName(newEntity.getJobName());
entity.setJobRemarks(newEntity.getJobRemarks());
this.service.update(entity);
return entity;
}
Aggregations