NOTE: The following configuration is for reference purposes only, and has been tested on Linux and macOS platforms based on this version.
The Quick Start section provides instructions on how to start and stop HugeGraphServer using scripts. In this guide, we will explain how to run and debug HugeGraph-Server on the Linux platform using IntelliJ IDEA.
The core steps for local startup are the same as starting with scripts:
InitStore
class to initialize the graph.HugeGraphServer
class to load the initialized graph information and start the server.Before proceeding with the following process, make sure that you have cloned the source code of HugeGraph and have configured the development environment, such as JDK 11.
git clone https://github.com/apache/hugegraph.git
To avoid the impact of configuration file changes on Git tracking, it is recommended to copy the required configuration files to a separate folder. Run the following command to copy the files:
cp -r hugegraph-dist/src/assembly/static/scripts hugegraph-dist/src/assembly/static/conf path-to-your-directory
Replace path-to-your-directory
with the path to the directory where you want to copy the files.
InitStore
to initialize the graphFirst, you need to configure the database backend in the configuration files. In this example, we will use RocksDB. Open path-to-your-directory/conf/graphs/hugegraph.properties
and configure it as follows:
backend=rocksdb serializer=binary rocksdb.data_path=. rocksdb.wal_path=.
Next, open the Run/Debug Configurations
panel in IntelliJ IDEA and create a new Application configuration. Follow these steps for the configuration:
hugegraph-dist
as the Use classpath of module
.Main class
to org.apache.hugegraph.cmd.InitStore
.conf/graphs/hugegraph.properties
. Note that the path here is relative to the working directory, so make sure to set the working directory to path-to-your-directory
.Once the configuration is completed, run it. If the execution is successful, the following runtime logs will be displayed:
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
HugeGraphServer
Similarly, open the Run/Debug Configurations
panel in IntelliJ IDEA and create a new Application
configuration. Follow these steps for the configuration:
hugegraph-dist
as the Use classpath of module
.Main class
to org.apache.hugegraph.dist.HugeGraphServer
.conf/gremlin-server.yaml conf/rest-server.properties
. Similarly, note that the path here is relative to the working directory, so make sure to set the working directory to path-to-your-directory
.Once the configuration is completed, run it. If you see the following logs, it means that HugeGraphServer
has been successfully started:
...... 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.
HugeGraphServer
(optional)After completing the above configuration, you can try debugging HugeGraphServer
. Run HugeGraphServer
in debug mode and set a breakpoint at the following location:
public String list(@Context GraphManager manager, @PathParam("graph") String graph, @QueryParam("label") String label, @QueryParam("properties") String properties, ......) { // ignore log Map<String, Object> props = parseProperties(properties);
Then use the RESTful API to request HugeGraphServer
:
curl "http://localhost:8080/graphs/hugegraph/graph/vertices" | gunzip
At this point, you can view detailed variable information in the debugger.
The reason may be that cross-compilation is triggered when using Java 11 to compile, causing the symbol of sun.misc.Unsafe
used in the project to not be found. There are two possible solutions:
Preferences/Settings
and find the Java Compiler
panel. Then, disable the --release
option (recommended).