Search in sources :

Example 21 with ExternalException

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);
    }
}
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 22 with ExternalException

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);
    }
}
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 23 with ExternalException

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);
    }
}
Also used : Task(com.baidu.hugegraph.structure.Task) ExternalException(com.baidu.hugegraph.exception.ExternalException) DeleteMapping(org.springframework.web.bind.annotation.DeleteMapping)

Example 24 with ExternalException

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

Example 25 with ExternalException

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);
    }
}
Also used : LoadTask(com.baidu.hugegraph.entity.load.LoadTask) LoadOptions(com.baidu.hugegraph.loader.executor.LoadOptions) ExternalException(com.baidu.hugegraph.exception.ExternalException) LoadMapping(com.baidu.hugegraph.loader.mapping.LoadMapping) ExternalException(com.baidu.hugegraph.exception.ExternalException) IOException(java.io.IOException) InternalException(com.baidu.hugegraph.exception.InternalException)

Aggregations

ExternalException (com.baidu.hugegraph.exception.ExternalException)42 HugeClient (com.baidu.hugegraph.driver.HugeClient)14 FileMapping (com.baidu.hugegraph.entity.load.FileMapping)11 ServerException (com.baidu.hugegraph.exception.ServerException)11 GraphConnection (com.baidu.hugegraph.entity.GraphConnection)9 JobManager (com.baidu.hugegraph.entity.load.JobManager)9 DeleteMapping (org.springframework.web.bind.annotation.DeleteMapping)9 IndexLabel (com.baidu.hugegraph.structure.schema.IndexLabel)8 PostMapping (org.springframework.web.bind.annotation.PostMapping)8 LoadTask (com.baidu.hugegraph.entity.load.LoadTask)5 VertexLabel (com.baidu.hugegraph.structure.schema.VertexLabel)5 PutMapping (org.springframework.web.bind.annotation.PutMapping)5 EdgeLabel (com.baidu.hugegraph.structure.schema.EdgeLabel)4 PropertyKey (com.baidu.hugegraph.structure.schema.PropertyKey)4 InternalException (com.baidu.hugegraph.exception.InternalException)3 GetMapping (org.springframework.web.bind.annotation.GetMapping)3 EdgeMapping (com.baidu.hugegraph.entity.load.EdgeMapping)2 VertexMapping (com.baidu.hugegraph.entity.load.VertexMapping)2 GremlinCollection (com.baidu.hugegraph.entity.query.GremlinCollection)2 ClientException (com.baidu.hugegraph.rest.ClientException)2