Search in sources :

Example 1 with WriteBackException

use of com.baidu.hugegraph.computer.core.output.hg.exceptions.WriteBackException in project hugegraph-computer by hugegraph.

the class TaskManager method submitInSingle.

private void submitInSingle(List<Vertex> batch) {
    try {
        this.singleSemaphore.acquire();
    } catch (InterruptedException e) {
        throw new WriteBackException("Interrupted while waiting to submit single", e);
    }
    InsertTask task = new SingleInsertTask(this.config, this.client, batch, this.loadSummary);
    CompletableFuture.runAsync(task, this.singleService).whenComplete((r, e) -> {
        this.singleSemaphore.release();
    });
}
Also used : WriteBackException(com.baidu.hugegraph.computer.core.output.hg.exceptions.WriteBackException)

Example 2 with WriteBackException

use of com.baidu.hugegraph.computer.core.output.hg.exceptions.WriteBackException in project hugegraph-computer by hugegraph.

the class TaskManager method submitBatch.

public void submitBatch(List<Vertex> batch) {
    try {
        this.batchSemaphore.acquire();
    } catch (InterruptedException e) {
        throw new WriteBackException("Interrupted while waiting to submit batch", e);
    }
    InsertTask task = new BatchInsertTask(this.config, this.client, batch, this.loadSummary);
    CompletableFuture.runAsync(task, this.batchService).exceptionally(e -> {
        LOG.warn("Batch insert error, try single insert", e);
        this.submitInSingle(batch);
        return null;
    }).whenComplete((r, e) -> this.batchSemaphore.release());
}
Also used : HugeClient(com.baidu.hugegraph.driver.HugeClient) ComputerOptions(com.baidu.hugegraph.computer.core.config.ComputerOptions) Logger(org.slf4j.Logger) Semaphore(java.util.concurrent.Semaphore) WriteBackException(com.baidu.hugegraph.computer.core.output.hg.exceptions.WriteBackException) ExecutorUtil(com.baidu.hugegraph.util.ExecutorUtil) CompletableFuture(java.util.concurrent.CompletableFuture) Vertex(com.baidu.hugegraph.structure.graph.Vertex) Config(com.baidu.hugegraph.computer.core.config.Config) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) Log(com.baidu.hugegraph.util.Log) Printer(com.baidu.hugegraph.computer.core.output.hg.metrics.Printer) HugeClientBuilder(com.baidu.hugegraph.driver.HugeClientBuilder) LoadSummary(com.baidu.hugegraph.computer.core.output.hg.metrics.LoadSummary) ExecutorService(java.util.concurrent.ExecutorService) WriteBackException(com.baidu.hugegraph.computer.core.output.hg.exceptions.WriteBackException)

Aggregations

WriteBackException (com.baidu.hugegraph.computer.core.output.hg.exceptions.WriteBackException)2 ComputerOptions (com.baidu.hugegraph.computer.core.config.ComputerOptions)1 Config (com.baidu.hugegraph.computer.core.config.Config)1 LoadSummary (com.baidu.hugegraph.computer.core.output.hg.metrics.LoadSummary)1 Printer (com.baidu.hugegraph.computer.core.output.hg.metrics.Printer)1 HugeClient (com.baidu.hugegraph.driver.HugeClient)1 HugeClientBuilder (com.baidu.hugegraph.driver.HugeClientBuilder)1 Vertex (com.baidu.hugegraph.structure.graph.Vertex)1 ExecutorUtil (com.baidu.hugegraph.util.ExecutorUtil)1 Log (com.baidu.hugegraph.util.Log)1 List (java.util.List)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 ExecutorService (java.util.concurrent.ExecutorService)1 Semaphore (java.util.concurrent.Semaphore)1 TimeUnit (java.util.concurrent.TimeUnit)1 Logger (org.slf4j.Logger)1