Search in sources :

Example 16 with MaxGraphException

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);
}
Also used : IOException(java.io.IOException) MaxGraphException(com.alibaba.maxgraph.compiler.api.exception.MaxGraphException) MaxGraphException(com.alibaba.maxgraph.compiler.api.exception.MaxGraphException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Example 17 with MaxGraphException

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;
}
Also used : Stat(org.apache.zookeeper.data.Stat) MaxGraphException(com.alibaba.maxgraph.compiler.api.exception.MaxGraphException) MaxGraphException(com.alibaba.maxgraph.compiler.api.exception.MaxGraphException) IOException(java.io.IOException)

Example 18 with MaxGraphException

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());
}
Also used : DropSchemaResponse(com.alibaba.maxgraph.proto.groot.DropSchemaResponse) CompletableFuture(java.util.concurrent.CompletableFuture) MaxGraphException(com.alibaba.maxgraph.compiler.api.exception.MaxGraphException) GraphSchema(com.alibaba.maxgraph.compiler.api.schema.GraphSchema) URISyntaxException(java.net.URISyntaxException) MaxGraphException(com.alibaba.maxgraph.compiler.api.exception.MaxGraphException) IOException(java.io.IOException)

Example 19 with MaxGraphException

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);
    }
}
Also used : Path(java.nio.file.Path) CompletableFuture(java.util.concurrent.CompletableFuture) LoadJsonSchemaResponse(com.alibaba.maxgraph.proto.groot.LoadJsonSchemaResponse) MaxGraphException(com.alibaba.maxgraph.compiler.api.exception.MaxGraphException) URISyntaxException(java.net.URISyntaxException) MaxGraphException(com.alibaba.maxgraph.compiler.api.exception.MaxGraphException) IOException(java.io.IOException)

Example 20 with MaxGraphException

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);
    }
}
Also used : MaxGraphException(com.alibaba.maxgraph.compiler.api.exception.MaxGraphException) MaxGraphException(com.alibaba.maxgraph.compiler.api.exception.MaxGraphException) IOException(java.io.IOException)

Aggregations

MaxGraphException (com.alibaba.maxgraph.compiler.api.exception.MaxGraphException)24 IOException (java.io.IOException)14 URISyntaxException (java.net.URISyntaxException)3 CompletableFuture (java.util.concurrent.CompletableFuture)3 ExecutionException (java.util.concurrent.ExecutionException)3 RoleType (com.alibaba.maxgraph.common.RoleType)2 Configs (com.alibaba.maxgraph.common.config.Configs)2 GaiaPortsResponse (com.alibaba.maxgraph.servers.jna.GaiaPortsResponse)2 FileNotFoundException (java.io.FileNotFoundException)2 HashMap (java.util.HashMap)2 LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)2 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)2 GremlinConfig (com.alibaba.maxgraph.common.config.GremlinConfig)1 RpcAddressFetcher (com.alibaba.maxgraph.common.rpc.RpcAddressFetcher)1 BackupException (com.alibaba.maxgraph.compiler.api.exception.BackupException)1 GraphSchema (com.alibaba.maxgraph.compiler.api.schema.GraphSchema)1 SchemaFetcher (com.alibaba.maxgraph.compiler.api.schema.SchemaFetcher)1 DropSchemaResponse (com.alibaba.maxgraph.proto.groot.DropSchemaResponse)1 LoadJsonSchemaResponse (com.alibaba.maxgraph.proto.groot.LoadJsonSchemaResponse)1 MaxGraphWsAndHttpSocketChannelizer (com.alibaba.maxgraph.server.MaxGraphWsAndHttpSocketChannelizer)1