Search in sources :

Example 21 with MaxGraphException

use of com.alibaba.maxgraph.compiler.api.exception.MaxGraphException in project GraphScope by alibaba.

the class StoreService method start.

public void start() throws IOException {
    logger.info("starting StoreService...");
    List<Integer> partitionIds = this.metaService.getPartitionsByStoreId(this.storeId);
    this.idToPartition = new HashMap<>(partitionIds.size());
    for (int partitionId : partitionIds) {
        try {
            GraphPartition partition = makeGraphPartition(this.configs, partitionId);
            this.idToPartition.put(partitionId, partition);
        } catch (IOException e) {
            throw new MaxGraphException(e);
        }
    }
    initMetrics();
    this.shouldStop = false;
    this.writeExecutor = new ThreadPoolExecutor(writeThreadCount, writeThreadCount, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(), ThreadFactoryUtils.daemonThreadFactoryWithLogExceptionHandler("store-write", logger));
    this.ingestExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1), ThreadFactoryUtils.daemonThreadFactoryWithLogExceptionHandler("store-ingest", logger));
    this.garbageCollectExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(), ThreadFactoryUtils.daemonThreadFactoryWithLogExceptionHandler("store-garbage-collect", logger));
    logger.info("StoreService started. storeId [" + this.storeId + "]");
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) IOException(java.io.IOException) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) MaxGraphException(com.alibaba.maxgraph.compiler.api.exception.MaxGraphException)

Example 22 with MaxGraphException

use of com.alibaba.maxgraph.compiler.api.exception.MaxGraphException in project GraphScope by alibaba.

the class KafkaLogService method init.

@Override
public void init() {
    AdminClient admin = getAdmin();
    NewTopic newTopic = new NewTopic(this.topic, this.queueCount, this.replicationFactor);
    Map<String, String> configs = new HashMap<>();
    configs.put("retention.ms", "-1");
    configs.put("retention.bytes", "-1");
    configs.put("max.message.bytes", String.valueOf(this.maxMessageMb * 1024 * 1024));
    newTopic.configs(configs);
    try {
        admin.createTopics(Collections.singleton(newTopic)).all().get();
    } catch (InterruptedException | ExecutionException e) {
        throw new MaxGraphException("create topics [" + this.topic + "] failed", e);
    }
}
Also used : HashMap(java.util.HashMap) NewTopic(org.apache.kafka.clients.admin.NewTopic) ExecutionException(java.util.concurrent.ExecutionException) MaxGraphException(com.alibaba.maxgraph.compiler.api.exception.MaxGraphException) AdminClient(org.apache.kafka.clients.admin.AdminClient)

Example 23 with MaxGraphException

use of com.alibaba.maxgraph.compiler.api.exception.MaxGraphException in project GraphScope by alibaba.

the class ReadOnlyGraphServer method start.

@Override
public void start() {
    this.loadSettings();
    logger.info(GremlinServer.getHeader());
    this.settings.port = GremlinConfig.GREMLIN_PORT.get(this.configs);
    this.settings.host = "0.0.0.0";
    if (settings.gremlinPool == 0) {
        settings.gremlinPool = Runtime.getRuntime().availableProcessors();
    }
    if (StringUtils.equals(settings.channelizer, WsAndHttpChannelizer.class.getName())) {
        settings.channelizer = MaxGraphWsAndHttpSocketChannelizer.class.getName();
    } else {
        throw new IllegalArgumentException("Not support for channelizer=>" + settings.channelizer);
    }
    settings.writeBufferHighWaterMark = GremlinConfig.SERVER_WRITE_BUFFER_HIGH_WATER.get(this.configs);
    settings.writeBufferLowWaterMark = GremlinConfig.SERVER_WRITE_BUFFER_LOW_WATER.get(this.configs);
    this.server = new GremlinServer(settings);
    ServerGremlinExecutor serverGremlinExecutor = Utils.getFieldValue(GremlinServer.class, this.server, "serverGremlinExecutor");
    serverGremlinExecutor.getGraphManager().putGraph("graph", graph);
    serverGremlinExecutor.getGraphManager().putTraversalSource("g", graph.traversal());
    GremlinExecutor gremlinExecutor = Utils.getFieldValue(ServerGremlinExecutor.class, serverGremlinExecutor, "gremlinExecutor");
    Bindings globalBindings = Utils.getFieldValue(GremlinExecutor.class, gremlinExecutor, "globalBindings");
    globalBindings.put("graph", graph);
    globalBindings.put("g", graph.traversal());
    ProcessorLoader processorLoader = new ReadOnlyMaxGraphProcessorLoader(this.configs, this.graph, this.schemaFetcher, this.rpcAddressFetcher);
    try {
        processorLoader.loadProcessor(settings);
    } catch (Exception e) {
        throw new MaxGraphException(e);
    }
    try {
        this.server.start().exceptionally(t -> {
            logger.error("Gremlin Server was unable to start and will now begin" + " shutdown: {}", t.getMessage());
            this.server.stop().join();
            return null;
        }).join();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    logger.info("Gremlin Server started....");
}
Also used : Configs(com.alibaba.maxgraph.common.config.Configs) SocketAddress(java.net.SocketAddress) Bindings(javax.script.Bindings) TinkerMaxGraph(com.alibaba.maxgraph.structure.graph.TinkerMaxGraph) Settings(org.apache.tinkerpop.gremlin.server.Settings) LoggerFactory(org.slf4j.LoggerFactory) WsAndHttpChannelizer(org.apache.tinkerpop.gremlin.server.channel.WsAndHttpChannelizer) StringUtils(org.apache.commons.lang3.StringUtils) GremlinServer(org.apache.tinkerpop.gremlin.server.GremlinServer) Utils(com.alibaba.maxgraph.tinkerpop.Utils) GremlinConfig(com.alibaba.maxgraph.common.config.GremlinConfig) RpcAddressFetcher(com.alibaba.maxgraph.common.rpc.RpcAddressFetcher) MaxGraphException(com.alibaba.maxgraph.compiler.api.exception.MaxGraphException) ServerGremlinExecutor(org.apache.tinkerpop.gremlin.server.util.ServerGremlinExecutor) Logger(org.slf4j.Logger) SchemaFetcher(com.alibaba.maxgraph.compiler.api.schema.SchemaFetcher) Files(java.nio.file.Files) AbstractService(com.alibaba.maxgraph.servers.AbstractService) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) IOException(java.io.IOException) Field(java.lang.reflect.Field) InetSocketAddress(java.net.InetSocketAddress) File(java.io.File) Channel(io.netty.channel.Channel) ProcessorLoader(com.alibaba.maxgraph.server.ProcessorLoader) IOUtils(org.apache.commons.io.IOUtils) List(java.util.List) MaxGraphWsAndHttpSocketChannelizer(com.alibaba.maxgraph.server.MaxGraphWsAndHttpSocketChannelizer) Paths(java.nio.file.Paths) GremlinExecutor(org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor) InputStream(java.io.InputStream) GremlinServer(org.apache.tinkerpop.gremlin.server.GremlinServer) ServerGremlinExecutor(org.apache.tinkerpop.gremlin.server.util.ServerGremlinExecutor) GremlinExecutor(org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor) Bindings(javax.script.Bindings) MaxGraphException(com.alibaba.maxgraph.compiler.api.exception.MaxGraphException) MaxGraphException(com.alibaba.maxgraph.compiler.api.exception.MaxGraphException) IOException(java.io.IOException) ServerGremlinExecutor(org.apache.tinkerpop.gremlin.server.util.ServerGremlinExecutor) MaxGraphWsAndHttpSocketChannelizer(com.alibaba.maxgraph.server.MaxGraphWsAndHttpSocketChannelizer) ProcessorLoader(com.alibaba.maxgraph.server.ProcessorLoader) WsAndHttpChannelizer(org.apache.tinkerpop.gremlin.server.channel.WsAndHttpChannelizer)

Example 24 with MaxGraphException

use of com.alibaba.maxgraph.compiler.api.exception.MaxGraphException in project GraphScope by alibaba.

the class NodeLauncher method start.

public void start() {
    Runtime.getRuntime().addShutdownHook(new Thread(() -> {
        try {
            this.node.close();
        } catch (Exception e) {
            logger.error("failed to stop node", e);
        }
    }));
    Runtime.getRuntime().addShutdownHook(new Thread(() -> keepAliveLatch.countDown()));
    try {
        this.node.start();
    } catch (Exception e) {
        logger.error("start node failed", e);
        throw new MaxGraphException(e);
    }
    this.keepAliveThread.start();
}
Also used : MaxGraphException(com.alibaba.maxgraph.compiler.api.exception.MaxGraphException) MaxGraphException(com.alibaba.maxgraph.compiler.api.exception.MaxGraphException)

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