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("token", ASTRA_APP_TOKEN)
  .withKeyspace("keyspace_name")
  .build();
However, JanusGraph does not expose this functionality so you will need to manually unpack the secure connect bundle and use its contents to configure JanusGraph which you will obtain in the Prerequisites.

Prerequisites

This article assumes you have a running installation of JanusGraph server. This was written and tested on JanusGraph v0.6.0. 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

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, unpack your secure bundle. For example:

$ cd /path/to/scb
$ unzip secure-connect-janusgraph.zip
Here is an example file listing after unpacking the bundle:

/
  path/
    to/
      scb/
        ca.crt
        cert
        cert.pfx
        config.json
        cqlshrc
        identity.jks
        key
        trustStore.jks
Obtain information about your database from the config.json file. Here is an example:

{
  "host": "70bf8560-105f-11ec-a3ea-0800200c9a66-us-west1.db.astra.datastax.com",
  "port": 98765,
  "cql_port": 34567,
  "keyspace": "janusgraph",
  "localDC": "us-west1",
  "caCertLocation": "./ca.crt",
  "keyLocation": "./key",
  "certLocation": "./cert",
  "keyStoreLocation": "./identity.jks",
  "keyStorePassword": "Kga1OJ83EF2oBQYR5",
  "trustStoreLocation": "./trustStore.jks",
  "trustStorePassword": "n8F9ptJO3H7YRxTW1",
  "csvLocation": "./data",
  "pfxCertPassword": "9b3HgFChtY60m4nfJ"
}

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

✅ Step 2: Graph Storage

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

$ cd janusgraph-0.6.0
$ vi conf/janusgraph-cql.properties
Make the necessary changes using this template:
# basic CQL settings
gremlin.graph=org.janusgraph.core.JanusGraphFactory
storage.backend=cql
storage.hostname=CONFIG-JSON-HOST
storage.port=CONFIG-JSON-CQL-PORT
storage.username=token               <----- do NOT change this
storage.password=ASTRA_APP_TOKEN
storage.cql.keyspace=GRAPH_KEYSPACE
storage.cql.local-datacenter=CONFIG-JSON-LOCALDC

# SSL related settings
storage.cql.ssl.enabled=true
storage.cql.ssl.truststore.location=/path/to/scb/trustStore.jks
storage.cql.ssl.truststore.password=CONFIG-JSON-TRUSTSTOREPASSWORD
storage.cql.ssl.keystore.location=/path/to/scb/identity.jks
storage.cql.ssl.keystore.keypassword=CONFIG-JSON-KEYSTOREPASSWORD
storage.cql.ssl.keystore.storepassword=CONFIG-JSON-KEYSTOREPASSWORD
storage.cql.ssl.client-authentication-enabled=true

# consistency settings
storage.cql.read-consistency-level=LOCAL_QUORUM
storage.cql.write-consistency-level=LOCAL_QUORUM

WARNING

The username to connect to Astra is the literal string token. Do NOT set this value to your DB's client ID.

IMPORTANT

The ASTRA_APP_TOKEN is from the token you generated in the Prerequisites section above.

Using the example values in the config.json above, my conf/janusgraph-cql.properties would contain:

# basic CQL settings
gremlin.graph=org.janusgraph.core.JanusGraphFactory
storage.backend=cql
storage.hostname=70bf8560-105f-11ec-a3ea-0800200c9a66-us-west1.db.astra.datastax.com
storage.port=34567
storage.username=token
storage.password=AstraCS:AbCwZYOKqvXHZWRvpbvHqXYz:47820923e5be3b7b9e689bc18614c631d5fdd8b435e68613433651fd20fexyz0
storage.cql.keyspace=janusgraph
storage.cql.local-datacenter=us-west1

# SSL related settings
storage.cql.ssl.enabled=true
storage.cql.ssl.truststore.location=/path/to/scb/trustStore.jks
storage.cql.ssl.truststore.password=n8F9ptJO3H7YRxTW1
storage.cql.ssl.keystore.location=/path/to/scb/identity.jks
storage.cql.ssl.keystore.keypassword=Kga1OJ83EF2oBQYR5
storage.cql.ssl.keystore.storepassword=Kga1OJ83EF2oBQYR5
storage.cql.ssl.client-authentication-enabled=true

# consistency settings
storage.cql.read-consistency-level=LOCAL_QUORUM
storage.cql.write-consistency-level=LOCAL_QUORUM

✅ 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: 2023-01-31