use of com.baidu.hugegraph.loader.exception.LoadException in project incubator-hugegraph-toolchain by apache.
the class TaskManager method submitInSingle.
private void submitInSingle(InputStruct struct, ElementMapping mapping, List<Record> batch) {
long start = System.currentTimeMillis();
try {
this.singleSemaphore.acquire();
} catch (InterruptedException e) {
throw new LoadException("Interrupted while waiting to submit %s " + "batch in single mode", e, mapping.type());
}
LoadSummary summary = this.context.summary();
InsertTask task = new SingleInsertTask(this.context, struct, mapping, batch);
CompletableFuture.runAsync(task, this.singleService).whenComplete((r, e) -> {
summary.metrics(struct).minusFlighting(batch.size());
this.singleSemaphore.release();
long end = System.currentTimeMillis();
this.context.summary().addTimeRange(mapping.type(), start, end);
});
}
use of com.baidu.hugegraph.loader.exception.LoadException in project incubator-hugegraph-toolchain by apache.
the class TaskManager method submitBatch.
public void submitBatch(InputStruct struct, ElementMapping mapping, List<Record> batch) {
long start = System.currentTimeMillis();
try {
this.batchSemaphore.acquire();
} catch (InterruptedException e) {
throw new LoadException("Interrupted while waiting to submit %s " + "batch in batch mode", e, mapping.type());
}
LoadSummary summary = this.context.summary();
summary.metrics(struct).plusFlighting(batch.size());
InsertTask task = new BatchInsertTask(this.context, struct, mapping, batch);
CompletableFuture.runAsync(task, this.batchService).whenComplete((r, e) -> {
if (e != null) {
LOG.warn("Batch insert {} error, try single insert", mapping.type(), e);
// The time of single insert is counted separately
this.submitInSingle(struct, mapping, batch);
} else {
summary.metrics(struct).minusFlighting(batch.size());
}
this.batchSemaphore.release();
long end = System.currentTimeMillis();
this.context.summary().addTimeRange(mapping.type(), start, end);
});
}
Aggregations