Search in sources :

Example 11 with MaxGraphException

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

the class MaxGraphNode method createGraphNode.

public static MaxGraphNode createGraphNode(RoleType role, Configs configs, int port) {
    int idx = CommonConfig.NODE_IDX.get(configs);
    String host = CommonConfig.RPC_HOST.get(configs);
    if (host.isEmpty()) {
        try {
            host = InetAddress.getLocalHost().getHostAddress();
        } catch (UnknownHostException e) {
            throw new MaxGraphException(e);
        }
    }
    return new MaxGraphNode(role.getName(), idx, host, port);
}
Also used : UnknownHostException(java.net.UnknownHostException) MaxGraphException(com.alibaba.maxgraph.compiler.api.exception.MaxGraphException)

Example 12 with MaxGraphException

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

the class KafkaLogWriter method append.

@Override
public long append(LogEntry logEntry) throws IOException {
    Future<RecordMetadata> future = producer.send(new ProducerRecord<>(this.topicName, this.partitionId, null, logEntry));
    RecordMetadata recordMetadata;
    try {
        recordMetadata = future.get();
    } catch (InterruptedException | ExecutionException e) {
        logger.error("append kafka failed", e);
        throw new MaxGraphException(e);
    }
    return recordMetadata.offset();
}
Also used : RecordMetadata(org.apache.kafka.clients.producer.RecordMetadata) ExecutionException(java.util.concurrent.ExecutionException) MaxGraphException(com.alibaba.maxgraph.compiler.api.exception.MaxGraphException)

Example 13 with MaxGraphException

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

the class RemoteTestGraphProvider method loadGraphData.

@Override
public void loadGraphData(Graph graph, LoadGraphWith loadGraphWith, Class testClass, String testName) {
    try {
        ((RemoteTestGraph) graph).loadSchema(null == loadGraphWith ? LoadGraphWith.GraphData.CLASSIC : loadGraphWith.value());
    } catch (Exception e) {
        logger.error("load schema failed", e);
        throw new MaxGraphException(e);
    }
    super.loadGraphData(graph, loadGraphWith, testClass, testName);
    logger.info("vertex value map list: " + graph.traversal().V().valueMap().toList());
    logger.info("edge value map list: " + graph.traversal().E().valueMap().toList());
}
Also used : MaxGraphException(com.alibaba.maxgraph.compiler.api.exception.MaxGraphException) MaxGraphException(com.alibaba.maxgraph.compiler.api.exception.MaxGraphException)

Example 14 with MaxGraphException

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

the class BackupManager method start.

public void start() {
    if (!this.backupEnable) {
        logger.info("backup manager is disable");
        return;
    }
    try {
        recover();
    } catch (IOException e) {
        throw new MaxGraphException(e);
    }
    this.localListener = new LocalSnapshotListener(this.schemaManager, this.localSnapshotCache);
    this.snapshotManager.addListener(this.localListener);
    this.backupCreationBuffer = new ArrayBlockingQueue<>(backupCreationBufferMaxSize);
    this.backupCreationExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(), ThreadFactoryUtils.daemonThreadFactoryWithLogExceptionHandler("backup-creation-executor", logger));
    this.backupGcScheduler = Executors.newSingleThreadScheduledExecutor(ThreadFactoryUtils.daemonThreadFactoryWithLogExceptionHandler("backup-gc-scheduler", logger));
    this.backupGcScheduler.scheduleWithFixedDelay(this::clearUnavailableBackups, backupGcIntervalHours, backupGcIntervalHours, TimeUnit.HOURS);
    if (autoSubmit) {
        this.autoCommitScheduler = Executors.newSingleThreadScheduledExecutor(ThreadFactoryUtils.daemonThreadFactoryWithLogExceptionHandler("backup-autocommit-scheduler", logger));
        this.autoCommitScheduler.scheduleWithFixedDelay(() -> {
            try {
                int newGlobalBackupId = createNewBackup();
                logger.info("backup creation auto submitted with backupId #[" + newGlobalBackupId + "]");
            } catch (Exception e) {
                logger.error("backup creation auto submit failed, ignore");
            }
        }, autoSubmitIntervalHours, autoSubmitIntervalHours, TimeUnit.HOURS);
    }
}
Also used : IOException(java.io.IOException) MaxGraphException(com.alibaba.maxgraph.compiler.api.exception.MaxGraphException) BackupException(com.alibaba.maxgraph.compiler.api.exception.BackupException) MaxGraphException(com.alibaba.maxgraph.compiler.api.exception.MaxGraphException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Example 15 with MaxGraphException

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

the class ZkDiscovery method start.

@Override
public void start() {
    try {
        MaxGraphNode localNode = localNodeProvider.get();
        this.currentNodesRef = new AtomicReference<>(new HashMap<>());
        this.singleThreadExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(), ThreadFactoryUtils.daemonThreadFactoryWithLogExceptionHandler("zk-discovery", logger));
        ServiceInstance<MaxGraphNode> instance = ServiceInstance.<MaxGraphNode>builder().name(localNode.getRoleName()).id(String.valueOf(localNode.getIdx())).payload(localNode).build();
        JsonInstanceSerializer<MaxGraphNode> serializer = new JsonInstanceSerializer<>(MaxGraphNode.class);
        this.serviceDiscovery = ServiceDiscoveryBuilder.builder(MaxGraphNode.class).client(curator).basePath(discoveryBasePath).serializer(serializer).thisInstance(instance).build();
        logger.debug("Start to add node " + localNode + " to discovery with base path " + discoveryBasePath);
        this.serviceDiscovery.start();
        RoleType[] roleTypes = RoleType.values();
        this.serviceCaches = new ArrayList<>(roleTypes.length);
        for (RoleType role : roleTypes) {
            ServiceCache<MaxGraphNode> serviceCache = this.serviceDiscovery.serviceCacheBuilder().name(role.getName()).build();
            NodeChangeListener listener = new NodeChangeListener(role, serviceCache);
            serviceCache.addListener(listener, this.singleThreadExecutor);
            serviceCache.start();
            listener.cacheChanged();
            this.serviceCaches.add(serviceCache);
        }
        logger.info("ZkDiscovery started");
    } catch (Exception e) {
        throw new MaxGraphException(e);
    }
}
Also used : HashMap(java.util.HashMap) RoleType(com.alibaba.maxgraph.common.RoleType) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) MaxGraphException(com.alibaba.maxgraph.compiler.api.exception.MaxGraphException) MaxGraphException(com.alibaba.maxgraph.compiler.api.exception.MaxGraphException) JsonInstanceSerializer(org.apache.curator.x.discovery.details.JsonInstanceSerializer) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor)

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