Search code examples
c#.netgremlinjanusgraphgremlin-server

Cannot see my graph on JanusGraph Server with BerkeleyDB storage from .NET client


Can someone help me to understand why I don't see the graph from JanusGraph.Net client?

I'm running the latest Docker image for JanusGraph from Docker Hub. After connecting to the JanusGraph using the built-in console I created a sample Graph of the Gods and was able to query it using the following commands:

graph = JanusGraphFactory.open('conf/janusgraph-berkeleyje-lucene.properties')
GraphOfTheGodsFactory.load(graph)
g = graph.traversal()
g.V().count()

Because the graph remained across container restarts (was able to query it again without GraphOfTheGodsFactory.load(graph) command) and some files were created inside the /opt/janusgraph/db/berkeley/ folder I assume that everything works.

Then I updated the graphs.graph property of the /opt/janusgraph/conf/gremlin-server/gremlin-server.yaml (path taken from docker-entrypoint.sh) to this value:

graphs: {
  graph: conf/janusgraph-berkeleyje-lucene.properties
}

and restarted container.

After that I created a simple .NET console application using JanusGraph.Net from with the following code:

static void Main(string[] args)
{
    var client = JanusGraphClientBuilder
       .BuildClientForServer(new GremlinServer("localhost", 8182))
       .Create();

    var g = AnonymousTraversalSource
       .Traversal()
       .WithRemote(new DriverRemoteConnection(client));

    var count = g.V().Count().Next();
}

and the count variable is always zero. It looks like that my .NET application connected to some another (probably in-memory) empty graph on this server.

What else should I change or update? Please help to figure this out.


Solution

  • OK, it was not very obvious, but JanusGraph Docker image is pre-configured to use BerkeleyDB by default (BTW according to the documentation it should be Cassandra). I found it taking a look at the Gremlin Server logs. Gremlin Server is configured to use /etc/opt/janusgraph/janusgraph.properties on startup. This file contains a completely different configuration for BerkeleyDB than, for example, conf/janusgraph-berkeleyje.properties - different folders, etc. That is why my .NET application hasn't seen any data - it was connected (through Gremlin Server) to the different BerkeleyDB database.

    I also wasn't able to load this file to the Gremlin console via graph = JanusGraphFactory.open('/etc/opt/janusgraph/janusgraph.properties') - got access issues. After I copied this file to the conf directory (and changed the access rights) - I got another error: Could not instantiate implementation: org.janusgraph.diskstorage.berkeleyje.BerkeleyJEStoreManager probably because the BerkeleyDB already exists.

    So the only way I've figured out how to connect to the existing database via the Gremlin Console is to use the :remote connect command. I was able to load a sample "Graph of the Gods" database and later access it from my .NET application using the following commands:

    :remote connect tinkerpop.server conf/remote.yaml
    :> GraphOfTheGodsFactory.load(graph)
    :> g.V().count()
    ==>12