use of com.alibaba.maxgraph.compiler.api.exception.MaxGraphException in project GraphScope by alibaba.
the class SnapshotManager method start.
public void start() {
try {
recover();
} catch (IOException e) {
throw new MaxGraphException(e);
}
this.increaseWriteSnapshotIdScheduler = Executors.newSingleThreadScheduledExecutor(ThreadFactoryUtils.daemonThreadFactoryWithLogExceptionHandler("increase-write-snapshot-scheduler", logger));
this.increaseWriteSnapshotIdScheduler.scheduleWithFixedDelay(() -> {
try {
long snapshotId = increaseWriteSnapshotId();
logger.debug("writeSnapshotId updated to [" + snapshotId + "]");
} catch (Exception e) {
logger.error("error in increaseWriteSnapshotId, ignore", e);
}
}, 0L, snapshotIncreaseIntervalMs, TimeUnit.MILLISECONDS);
this.persistOffsetsScheduler = Executors.newSingleThreadScheduledExecutor(ThreadFactoryUtils.daemonThreadFactoryWithLogExceptionHandler("persist-offsets-scheduler", logger));
this.persistOffsetsScheduler.scheduleWithFixedDelay(() -> {
try {
updateQueueOffsets();
} catch (Exception e) {
logger.error("error in updateQueueOffsets, ignore", e);
}
}, offsetsPersistIntervalMs, offsetsPersistIntervalMs, TimeUnit.MILLISECONDS);
}
use of com.alibaba.maxgraph.compiler.api.exception.MaxGraphException in project GraphScope by alibaba.
the class ZkMetaStore method exists.
@Override
public boolean exists(String path) {
String fullPath = ZKPaths.makePath(this.metaBasePath, path);
Stat stat;
try {
stat = this.curator.checkExists().forPath(fullPath);
} catch (Exception e) {
throw new MaxGraphException(e);
}
return stat != null;
}
use of com.alibaba.maxgraph.compiler.api.exception.MaxGraphException in project GraphScope by alibaba.
the class MaxTestGraph method dropData.
private void dropData() {
CompletableFuture<GraphSchema> future = new CompletableFuture<>();
this.clientService.dropSchema(DropSchemaRequest.newBuilder().build(), new StreamObserver<DropSchemaResponse>() {
@Override
public void onNext(DropSchemaResponse value) {
future.complete(GraphDef.parseProto(value.getGraphDef()));
}
@Override
public void onError(Throwable t) {
future.completeExceptionally(t);
}
@Override
public void onCompleted() {
}
});
GraphSchema schema;
try {
schema = future.get();
} catch (Exception e) {
throw new MaxGraphException(e);
}
logger.info("drop schema: " + ((GraphDef) schema).toProto().toString());
}
use of com.alibaba.maxgraph.compiler.api.exception.MaxGraphException in project GraphScope by alibaba.
the class MaxTestGraph method loadSchema.
public void loadSchema(LoadGraphWith.GraphData graphData) throws URISyntaxException, IOException {
String schemaResource = graphData.name().toLowerCase() + ".schema";
Path path = Paths.get(Thread.currentThread().getContextClassLoader().getResource(schemaResource).toURI());
String json = new String(Files.readAllBytes(path), StandardCharsets.UTF_8);
CompletableFuture<String> future = new CompletableFuture<>();
clientService.loadJsonSchema(LoadJsonSchemaRequest.newBuilder().setSchemaJson(json).build(), new StreamObserver<LoadJsonSchemaResponse>() {
@Override
public void onNext(LoadJsonSchemaResponse value) {
future.complete(value.getGraphDef().toString());
}
@Override
public void onError(Throwable t) {
future.completeExceptionally(t);
}
@Override
public void onCompleted() {
}
});
try {
String schemaString = future.get();
logger.info("load json schema: " + schemaString);
} catch (Exception e) {
throw new MaxGraphException(e);
}
}
use of com.alibaba.maxgraph.compiler.api.exception.MaxGraphException in project GraphScope by alibaba.
the class GraphInitializer method initializeIfNeeded.
public void initializeIfNeeded() {
initializeLogServiceIfNeeded();
try {
initializeZkIfNeeded();
initializeMetaIfNeeded();
} catch (Exception e) {
throw new MaxGraphException(e);
}
}
Aggregations