Search code examples
javagremlingremlin-serverjanusgraph

Loading data into a remote Gremlin graph


I've been ingesting GraphML data into Gremlin/Tinkerpop with the following Java code:

graph.io(IoCore.graphml()).reader().create().readGraph(inputStream, graph);

This works great for an in-memory graph, but I'd now like ingest the same GraphML data into a remote JanusGraph that's sitting behind a Gremlin Server. This seems to me to be an obvious and straight forward thing to do, but I can't work out how to get a remote graph instance (only a traversal).

Is this possible, and if not what workarounds are there for ingesting data remotely?


Solution

  • Currently, in TinkerPop compliant graph systems, it is not possible to get a local reference to a remote graph object. However, you shouldn't need one to perform the command graph.io(IoCore.graphml()).reader().create().readGraph(inputStream, graph);. First you grab access to the graph reference in your remote scripts, i.e. can be that the variable "graph" is bound to a graph reference on the remote server, or perhaps you are using the JanusGraphFactory (which would be weird because that would open the remote file system) or the ConfiguredGraphFactory. Then you submit a gremlin script to the remote server, and as long as you bind "graph" to the correct graph object on the remote server and ensure "inputStream" is properly defined (i.e. as a string, through the remote local file system (again weird), or through a URL), then you should be able to perform this command with no problem. The exact way you complete the action depends on your specific situation, i.e. how you access graphs, how you can access an input stream remotely, the remote server's sandbox settings, etc.