use of com.baidu.hugegraph.entity.GraphConnection in project incubator-hugegraph-toolchain by apache.
the class GraphConnectionController method get.
@GetMapping("{id}")
public GraphConnection get(@PathVariable("id") int id) {
GraphConnection entity = this.connService.get(id);
if (entity == null) {
throw new ExternalException("graph-connection.not-exist.id", id);
}
if (!this.poolService.containsKey(id)) {
this.sslService.configSSL(this.config, entity);
HugeClient client = HugeClientUtil.tryConnect(entity);
this.poolService.put(entity, client);
}
return entity;
}
use of com.baidu.hugegraph.entity.GraphConnection in project incubator-hugegraph-toolchain by apache.
the class LoadTaskController method stop.
@PostMapping("stop")
public LoadTask stop(@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.stop(taskId);
} finally {
jobEntity.setJobStatus(JobStatus.LOADING);
jobEntity.setUpdateTime(HubbleUtil.nowDate());
this.jobService.update(jobEntity);
}
}
use of com.baidu.hugegraph.entity.GraphConnection 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.entity.GraphConnection 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.entity.GraphConnection 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;
}
Aggregations