Creating a JanusGraph using Gremlin Console

JanusGraph is new community project under the Linux foundation. It is forked from TitanDB code. JanusGraph incorporates support for the property graph model with Apache TinkerPop (the open source graph computing framework) and its Gremlin graph traversal language. According to JanusGraph website:

JanusGraph is a scalable graph database optimized for storing and querying graphs containing hundreds of billions of vertices and edges distributed across a multi-machine cluster. JanusGraph is a transactional database that can support thousands of concurrent users executing complex graph traversals in real time.

I will show how you can run JanusGraph locally so that you can try out yourself since it might become the de-facto implementation of TinkerPop. I will be using Cassandra and Elasticsearch for backend databases.

Procedure

  1. Start Gremlin console as per Starting with Gremlin Console
  2. Define your connection properties in properties file to connect to Cassandra and Elasticsearch docker images as follows. (hostname of Cassandra and Elasticsearch might change on your machine).
  3. storage.backend=cassandrathrift
    storage.hostname=localhost
    cache.db-cache=true
    cache.db-cache-clean-wait=20
    cache.db-cache-time=180000
    cache.db-cache-size=0.25
    index.search.backend=elasticsearch
    index.search.hostname=localhost
    index.search.elasticsearch.client-only=true

  4. Run docker pull cassandra:2.1.9 command to pull cassandra from Docker Hub. It is using old version of cassandra.
  5. Run docker pull elasticsearch:2.4.4 command to pull elasticsearch from Docker Hub.
  6. After successful pull, run following command to run cassandra docker image. docker run -e CASSANDRA_START_RPC=true --name cassandra-latest -p 7000:7000 -p 7001:7001 -p 7199:7199 -p 9042:9042 -p 9160:9160 -t -d cassandra:2.1.9
  7. Look for following message
    Screenshot 2017-04-11 19.07.04
  8. Run docker run –name elasticsearch-2.4.4 -p 9300:9300 -p 9200:9200 -t -d elasticsearch:2.4.4 command run run elasticsearch docker image.
    Screenshot 2017-04-11 19.13.10
  9. Check both images are running by running docker ps command and see both images are running or not.
    Screenshot 2017-04-11 20.37.07
  10. Run following command to connect to your backend using Gremlin console.
    gremlin> graph = JanusGraphFactory.open('.../website/janusgraph.properties')
    ==> standardjanusgraph[cassandrathrift:[localhost]]
  11. Once a graph exists, a graph traversal g is configured that will allow graph traversal. Graph traversal is used to query the graph data and returns results. A graph traversal is bound to specific traversal source that is the standard Janus traversal engine.

  12. Create traversal instance so that we can query our graph database. We can also use traversal instance to create vertices.
    gremlin> g = graph.traversal()
    ==>graphtraversalsource[standardjanusgraph[cassandrathrift:[localhost]], standard]
  13. The graph commands usually add vertices and edges to database or get other graph information. the g commands generally do queries to obtain results.

  14. Load some vertices and start playing with JanusGraph.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s