在 IDEA 中配置 HugeGraph

您所在的位置:网站首页 idea配置springboot启动 在 IDEA 中配置 HugeGraph

在 IDEA 中配置 HugeGraph

2024-07-18 00:04:00| 来源: 网络整理| 查看: 265

在 IDEA 中配置 HugeGraph-Server 开发环境

注意:下述配置仅供参考,基于这个版本,在 Linux 和 macOS 平台下进行了测试。

背景

在 Quick Start 部分已经介绍了使用脚本启停 HugeGraphServer 的流程。下面以 Linux 平台为例,介绍使用 IntelliJ IDEA 运行与调试 HugeGraph-Server 的流程。

本地启动的核心与脚本启动是一样的:

初始化数据库后端,执行 InitStore 类初始化图启动 HugeGraphServer,执行 HugeGraphServer 类加载初始化的图信息启动

在执行下述流程之前,请确保已经克隆了 HugeGraph 的源代码,并且已经配置了 JDK 11 等开发环境。

git clone https://github.com/apache/hugegraph.git 步骤1. 配置文件拷贝

为了避免配置文件的更改影响 Git 的追踪,建议将所需的配置文件拷贝到一个单独的文件夹中:

cp -r hugegraph-dist/src/assembly/static/scripts hugegraph-dist/src/assembly/static/conf path-to-your-directory

将 path-to-your-directory 替换为你创建的文件夹的路径。

2. InitStore 类初始化图

首先,需要在配置文件中配置数据库后端。以 RocksDB 为例,在 path-to-your-directory/conf/graphs/hugegraph.properties 文件中进行以下配置:

backend=rocksdb serializer=binary rocksdb.data_path=. rocksdb.wal_path=.

然后,打开 IntelliJ IDEA 的 Run/Debug Configurations 面板,创建一个新的 Application 配置,按照以下步骤进行配置:

在 Use classpath of module 中选择 hugegraph-dist将 Main class 设置为 org.apache.hugegraph.cmd.InitStore设置运行参数为 conf/graphs/hugegraph.properties,这里的路径是相对于工作路径的,需要将工作路径设置为 path-to-your-directory

配置完成后运行,如果运行成功,将会输出以下类似运行日志:

2023-06-05 00:43:37 [main] [INFO] o.a.h.u.ConfigUtil - Scanning option 'graphs' directory './conf/graphs' 2023-06-05 00:43:37 [main] [INFO] o.a.h.c.InitStore - Init graph with config file: ./conf/graphs/hugegraph.properties ...... 2023-06-05 00:43:39 [main] [INFO] o.a.h.b.s.r.RocksDBStore - Write down the backend version: 1.11 2023-06-05 00:43:39 [main] [INFO] o.a.h.StandardHugeGraph - Graph 'hugegraph' has been initialized 2023-06-05 00:43:39 [main] [INFO] o.a.h.StandardHugeGraph - Close graph standardhugegraph[hugegraph] 2023-06-05 00:43:39 [db-open-1] [INFO] o.a.h.b.s.r.RocksDBStore - Opening RocksDB with data path: ./m 2023-06-05 00:43:39 [db-open-1] [INFO] o.a.h.b.s.r.RocksDBStore - Opening RocksDB with data path: ./s 2023-06-05 00:43:39 [db-open-1] [INFO] o.a.h.b.s.r.RocksDBStore - Opening RocksDB with data path: ./g 2023-06-05 00:43:39 [main] [INFO] o.a.h.HugeFactory - HugeFactory shutdown 2023-06-05 00:43:39 [hugegraph-shutdown] [INFO] o.a.h.HugeFactory - HugeGraph is shutting down 3. 运行 HugeGraphServer

类似地,打开 IntelliJ IDEA 的 Run/Debug Configurations 面板,创建一个新的 Application 配置,按照以下步骤进行配置:

在 Use classpath of module 中选择 hugegraph-dist将 Main class 设置为 org.apache.hugegraph.dist.HugeGraphServer设置运行参数为 conf/gremlin-server.yaml conf/rest-server.properties,同样地,这里的路径是相对于工作路径的,需要将工作路径设置为 path-to-your-directory

配置完成后运行,如果看到以下类似日志,表示 HugeGraphServer 已经成功启动:

...... 2023-06-05 00:51:56 [gremlin-server-boss-1] [INFO] o.a.t.g.s.GremlinServer - Gremlin Server configured with worker thread pool of 1, gremlin pool of 8 and boss thread pool of 1. 2023-06-05 00:51:56 [gremlin-server-boss-1] [INFO] o.a.t.g.s.GremlinServer - Channel started at port 8182. 4. 调试 HugeGraphServer (可选)

在完成上述配置后,可以尝试对 HugeGraphServer 进行调试。在调试模式下运行 HugeGraphServer,并在以下位置设置断点:

public String list(@Context GraphManager manager, @PathParam("graph") String graph, @QueryParam("label") String label, @QueryParam("properties") String properties, ......) { // ignore log Map props = parseProperties(properties);

然后,使用 RESTful API 请求 HugeGraphServer:

curl "http://localhost:8080/graphs/hugegraph/graph/vertices" | gunzip

此时,可以在调试器中查看详细的变量信息。

可能遇到的问题

*** java: package sun.misc does not exist ***

原因可能是在使用 Java 11 编译时触发了交叉编译,导致项目中使用的 sun.misc.Unsafe 找不到符号。有两种解决方案可供选择:

在 IntelliJ IDEA 的 Preferences/Settings 中找到 Java Compiler 面板,然后关闭 --release 选项 (推荐)或者将项目的 SDK 版本设置为 8参考HugeGraph-Server Quick Starthugegraph-server 本地调试文档 (Win/Unix)“package sun.misc does not exist” compilation errorCannot compile: java: package sun.misc does not existLast modified June 6, 2023: doc: add hugegraph server setup guide for IDEA (#262) (93d394c5)


【本文地址】

公司简介

联系我们

今日新闻


点击排行

实验室常用的仪器、试剂和
说到实验室常用到的东西,主要就分为仪器、试剂和耗
不用再找了,全球10大实验
01、赛默飞世尔科技(热电)Thermo Fisher Scientif
三代水柜的量产巅峰T-72坦
作者:寞寒最近,西边闹腾挺大,本来小寞以为忙完这
通风柜跟实验室通风系统有
说到通风柜跟实验室通风,不少人都纠结二者到底是不
集消毒杀菌、烘干收纳为一
厨房是家里细菌较多的地方,潮湿的环境、没有完全密
实验室设备之全钢实验台如
全钢实验台是实验室家具中较为重要的家具之一,很多

推荐新闻


图片新闻

实验室药品柜的特性有哪些
实验室药品柜是实验室家具的重要组成部分之一,主要
小学科学实验中有哪些教学
计算机 计算器 一般 打孔器 打气筒 仪器车 显微镜
实验室各种仪器原理动图讲
1.紫外分光光谱UV分析原理:吸收紫外光能量,引起分
高中化学常见仪器及实验装
1、可加热仪器:2、计量仪器:(1)仪器A的名称:量
微生物操作主要设备和器具
今天盘点一下微生物操作主要设备和器具,别嫌我啰嗦
浅谈通风柜使用基本常识
 众所周知,通风柜功能中最主要的就是排气功能。在

专题文章

    CopyRight 2018-2019 实验室设备网 版权所有 win10的实时保护怎么永久关闭