use of com.baidu.hugegraph.exception.ExternalException in project incubator-hugegraph-toolchain by apache.
the class LoadTaskController method resume.
@PostMapping("resume")
public LoadTask resume(@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.resume(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 LoadTaskController method retry.
@PostMapping("retry")
public LoadTask retry(@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.retry(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 AsyncTaskController method delete.
@DeleteMapping
public void delete(@PathVariable("connId") int connId, @RequestParam("ids") List<Integer> ids) {
for (int id : ids) {
Task task = this.service.get(connId, id);
if (task == null) {
throw new ExternalException("async.task.not-exist.id", id);
}
this.service.remove(connId, id);
}
}
use of com.baidu.hugegraph.exception.ExternalException in project incubator-hugegraph-toolchain by apache.
the class HugeClientPoolService method getOrCreate.
public synchronized HugeClient getOrCreate(Integer id) {
HugeClient client = super.get(id);
if (client != null) {
return client;
}
GraphConnection connection = this.connService.get(id);
if (connection == null) {
throw new ExternalException("graph-connection.get.failed", id);
}
if (connection.getTimeout() == null) {
int timeout = this.config.get(HubbleOptions.CLIENT_REQUEST_TIMEOUT);
connection.setTimeout(timeout);
}
this.sslService.configSSL(this.config, connection);
client = HugeClientUtil.tryConnect(connection);
this.put(id, client);
return client;
}
use of com.baidu.hugegraph.exception.ExternalException in project incubator-hugegraph-toolchain by apache.
the class LoadTaskService method buildLoadTask.
private LoadTask buildLoadTask(GraphConnection connection, FileMapping fileMapping) {
try {
LoadOptions options = this.buildLoadOptions(connection, fileMapping);
// NOTE: For simplicity, one file corresponds to one import task
LoadMapping mapping = this.buildLoadMapping(connection, fileMapping);
this.bindMappingToOptions(options, mapping, fileMapping.getPath());
return new LoadTask(options, connection, fileMapping);
} catch (Exception e) {
Throwable rootCause = Ex.rootCause(e);
throw new ExternalException("load.build-task.failed", rootCause);
}
}
Aggregations