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);
}
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();
}
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());
}
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);
}
}
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);
}
}
Aggregations