Skip to content

JanusGraph

Overview

JanusGraph is designed to support the processing of graphs so large that they require storage and computational capacities beyond those that a single machine can provide. Scaling graph data processing for real time traversals and analytical queries is JanusGraph’s foundational benefit. This section will discuss the various specific benefits of JanusGraph and its underlying, supported persistence solutions.

JanusGraph uses the Java driver to connect to Cassandra as the storage backend. The Java driver itself supports connections to Astra DB natively. For example:

CqlSession session = CqlSession.builder()
  .withCloudSecureConnectBundle(Paths.get("/path/to/secure-connect-db_name.zip"))
  .withAuthCredentials("CLIENT_ID", "CLIENT_SECRET")
  .withKeyspace("keyspace_name")
  .build();

Prerequisites

This article assumes you have a running installation of JanusGraph server. This was written and tested on JanusGraph v0.6.2. If JanusGraph v0.6.0 is used instead, refer to this article. It has not been tested on older versions of JanusGraph.

You will need to choose which keyspace to use to store your graph. If it doesn't exist, you will need to create the keyspace on the Astra UI. For simplicity, the keyspace is created as janusgraph.

IMPORTANT

If you want to connect JanusGraph server to ZDM, it is recommended to use the Internal Configuration File to avoid any credentials issues. Just comment out the secure bundle path part from the external file.

Installation and Setup

Note: For simplicity, the secure connect bundle has been placed in /path/to/scb

✅ Step 1: DB Information

On the JanusGraph server, move your secure bundle using secure copy or other techniques. For example:

$ cd /path/to/scb
$ ls -l secure-connect-janusgraph.zip

We will use this information to configure Astra DB as the storage backend for JanusGraph.

✅ Step 2: Graph Storage

While connecting to Astra DB from JanusGraph, it is preferred to make use of the secure connect bundle file as-is without extracting it. There are multiple ways in which a secure connect bundle file can be passed on to the JanusGraph configuration to connect to Astra DB using the DataStax driver.

On the JanusGraph server, modify the CQL storage configuration file:

$ cd janusgraph-0.6.2
$ vi conf/janusgraph-cql.properties
Make the necessary changes using one of the two templates:

✅ Step 2a: Internal String Configuration

Set the property storage.cql.internal.string-configuration to datastax-java-driver { basic.cloud.secure-connect-bundle=/path/to/scb/secure-connect-janusgraph.zip } and set the username, password and keyspace details.

For example:

gremlin.graph=org.janusgraph.core.JanusGraphFactory
storage.backend=cql
storage.cql.keyspace=<keyspace name which was created in AstraDB>
storage.username=<clientID>
storage.password=<clientSecret>
storage.cql.internal.string-configuration=datastax-java-driver { basic.cloud.secure-connect-bundle=/path/to/scb/secure-connect-janusgraph.zip }

Also, you can set a JVM argument to pass the secure connect bundle file as shown below and remove that property (storage.cql.internal.string-configuration) from the list above.

-Ddatastax-java-driver.basic.cloud.secure-connect-bundle=/path/to/scb/secure-connect-janusgraph.zip

✅ Step 2b: Internal File Configuration

Set the property storage.cql.internal.file-configuration to an external configuration file if you would like to externalize the astra connection related properties to a separate file and specify the secure bundle and credentials information on that file.

For example:

gremlin.graph=org.janusgraph.core.JanusGraphFactory
storage.backend=cql
storage.cql.keyspace=janusgraph
# Link to the external file that DataStax driver understands
storage.cql.internal.file-configuration=/path/to/scb/astra.conf

astra.conf (external file) to contain:

datastax-java-driver {
  basic.cloud {
    secure-connect-bundle = "/path/to/scb/secure-connect-janusgraph.zip"
  }
  basic.request {
    timeout = "10 seconds"
  }
  advanced.auth-provider {
    class = PlainTextAuthProvider
    username = "<ClientID>"
    password = "<ClientSecret>"
  }
}

IMPORTANT

The ClientID and ClientSecret are from the token you generated in the Prerequisites section above.

✅ Step 3: Final Test

Start a Gremlin console:

$ bin/gremlin.sh

         \,,,/
         (o o)
-----oOOo-(3)-oOOo-----
gremlin>

Load a graph using Astra as the storage backend with:

gremlin> graph = JanusGraphFactory.open('conf/janusgraph-cql.properties')
==>standardjanusgraph[cql:[70bf8560-105f-11ec-a3ea-0800200c9a66-us-west1.db.astra.datastax.com]]

Note

It is normal to see some warnings on the Gremlin console. I have attached a text file with a sample output so you know what to expect.

In the Astra CQL Console, I can see JanusGraph created the following tables in the janusgraph keyspace:

token@cqlsh> USE janusgraph;
token@cqlsh:janusgraph> DESCRIBE TABLES;

edgestore_lock_  graphindex_lock_         janusgraph_ids   
txlog            systemlog                graphindex       
edgestore        system_properties_lock_  system_properties

Last update: 2024-05-31