use of com.baidu.hugegraph.entity.load.LoadTask in project incubator-hugegraph-toolchain by apache.
the class LoadTaskController method delete.
@DeleteMapping("{id}")
public void delete(@PathVariable("id") int id) {
LoadTask task = this.service.get(id);
if (task == null) {
throw new ExternalException("load.task.not-exist.id", id);
}
this.service.remove(id);
}
use of com.baidu.hugegraph.entity.load.LoadTask 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);
}
}
Aggregations