Search in sources :

Example 1 with GraphConnection

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;
}
Also used : HugeClient(com.baidu.hugegraph.driver.HugeClient) GraphConnection(com.baidu.hugegraph.entity.GraphConnection) ExternalException(com.baidu.hugegraph.exception.ExternalException) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 2 with GraphConnection

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);
    }
}
Also used : GraphConnection(com.baidu.hugegraph.entity.GraphConnection) JobManager(com.baidu.hugegraph.entity.load.JobManager) ExternalException(com.baidu.hugegraph.exception.ExternalException) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 3 with GraphConnection

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);
    }
}
Also used : GraphConnection(com.baidu.hugegraph.entity.GraphConnection) JobManager(com.baidu.hugegraph.entity.load.JobManager) ExternalException(com.baidu.hugegraph.exception.ExternalException) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 4 with GraphConnection

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);
    }
}
Also used : GraphConnection(com.baidu.hugegraph.entity.GraphConnection) JobManager(com.baidu.hugegraph.entity.load.JobManager) ExternalException(com.baidu.hugegraph.exception.ExternalException) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 5 with GraphConnection

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;
}
Also used : HugeClient(com.baidu.hugegraph.driver.HugeClient) GraphConnection(com.baidu.hugegraph.entity.GraphConnection) ExternalException(com.baidu.hugegraph.exception.ExternalException)

Aggregations

GraphConnection (com.baidu.hugegraph.entity.GraphConnection)11 ExternalException (com.baidu.hugegraph.exception.ExternalException)9 JobManager (com.baidu.hugegraph.entity.load.JobManager)5 PostMapping (org.springframework.web.bind.annotation.PostMapping)5 HugeClient (com.baidu.hugegraph.driver.HugeClient)3 FileMapping (com.baidu.hugegraph.entity.load.FileMapping)1 LoadTask (com.baidu.hugegraph.entity.load.LoadTask)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 Test (org.junit.Test)1 DeleteMapping (org.springframework.web.bind.annotation.DeleteMapping)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1 PutMapping (org.springframework.web.bind.annotation.PutMapping)1