use of com.baidu.hugegraph.exception.ExternalException 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.exception.ExternalException 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.exception.ExternalException in project incubator-hugegraph-toolchain by apache.
the class FileMappingController method updateEdgeMapping.
@PutMapping("{id}/edge-mappings/{emid}")
public FileMapping updateEdgeMapping(@PathVariable("connId") int connId, @PathVariable("id") int id, @PathVariable("emid") String emId, @RequestBody EdgeMapping newEntity) {
FileMapping mapping = this.service.get(id);
if (mapping == null) {
throw new ExternalException("load.file-mapping.not-exist.id", id);
}
this.checkEdgeMappingValid(connId, newEntity, mapping);
EdgeMapping edgeMapping = mapping.getEdgeMapping(emId);
Ex.check(edgeMapping != null, "load.file-mapping.edge-mapping.not-exist.id", emId);
newEntity.setId(emId);
Set<EdgeMapping> edgeMappings = mapping.getEdgeMappings();
edgeMappings.remove(edgeMapping);
edgeMappings.add(newEntity);
this.service.update(mapping);
return mapping;
}
use of com.baidu.hugegraph.exception.ExternalException in project incubator-hugegraph-toolchain by apache.
the class FileMappingController method deleteVertexMapping.
@DeleteMapping("{id}/vertex-mappings/{vmid}")
public FileMapping deleteVertexMapping(@PathVariable("id") int id, @PathVariable("vmid") String vmid) {
FileMapping mapping = this.service.get(id);
if (mapping == null) {
throw new ExternalException("load.file-mapping.not-exist.id", id);
}
VertexMapping vertexMapping = mapping.getVertexMapping(vmid);
boolean removed = mapping.getVertexMappings().remove(vertexMapping);
if (!removed) {
throw new ExternalException("load.file-mapping.vertex-mapping.not-exist.id", vmid);
}
this.service.update(mapping);
return mapping;
}
use of com.baidu.hugegraph.exception.ExternalException in project incubator-hugegraph-toolchain by apache.
the class FileMappingController method deleteEdgeMapping.
@DeleteMapping("{id}/edge-mappings/{emid}")
public FileMapping deleteEdgeMapping(@PathVariable("id") int id, @PathVariable("emid") String emid) {
FileMapping mapping = this.service.get(id);
if (mapping == null) {
throw new ExternalException("load.file-mapping.not-exist.id", id);
}
EdgeMapping edgeMapping = mapping.getEdgeMapping(emid);
boolean removed = mapping.getEdgeMappings().remove(edgeMapping);
if (!removed) {
throw new ExternalException("load.file-mapping.edge-mapping.not-exist.id", emid);
}
this.service.update(mapping);
return mapping;
}
Aggregations