Loading Graphson into janusgraph server -> java example

498 views
Skip to first unread message

Stefan Stiene

unread,
Jul 31, 2018, 5:06:18 AM7/31/18
to JanusGraph users
Hi,
I already posted this message on the gremlin user mailing list. And there it was suggested to ask it here. So hopefully you can help me:


I try to load a local graphson file (<20k Vertices and Edges) into a remote Janusgraph server using a java client. I hoped that I can just do:

graph.io(IoCore.graphson()).readGraph("data/janus_graph.json");

where graph is the remote graph but I get the error:

java.lang.UnsupportedOperationException: The default implementation is not capable of validating custom ids - please override


My next guess would be to load the graphson into a local inmemory graph and iterate over the local graph and call for each vertex addVertex on the remote graph. But this seems a little bit inelegant to me.

Is there a better option? Has someone a minimal java example for me as this is more or less a standard problem?

Best Regards
Stefan

Stefan Stiene

unread,
Jul 31, 2018, 10:58:58 AM7/31/18
to JanusGraph users
some additional information:

the test graphson file I use is as simple as this
{"id":{"@type":"g:Int64","@value":1},"label":"test"}

also with

{"id":1,"label":"test"}

I get the UnsupportedOperationException

with

{"_id":1,"label":"test"}

I get:

at org.apache.tinkerpop.gremlin.structure.Property$Exceptions.propertyValueCanNotBeNull(Property.java:143) ~[gremlin-core-3.3.3.jar:3.3.3]

I create the connection to the janusgraph server with

conf = new PropertiesConfiguration(propFileName);

// using the remote driver for schema
try {
cluster = Cluster.open(conf.getString("gremlin.remote.driver.clusterFile"));
client = cluster.connect();
} catch (Exception e) {
throw new ConfigurationException(e);
}

// using the remote graph for queries
graph = EmptyGraph.instance();
g = graph.traversal().withRemote(conf);

and my properties file looks like this:

gremlin.remote.remoteConnectionClass=org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteConnection
gremlin.remote.driver.clusterFile=conf/remote-objects.yaml
gremlin.remote.driver.sourceName=g

and the remote-objects.yaml like this:

hosts: [localhost]
port: 8182
serializer: { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { bufferSize: 8192, ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }}

general connection between java client and janusgraph server is available as
g.addV("titan").property("name", "saturn3").property("age", 10000);
works.

Regards
Stefan

Jason Plurad

unread,
Jul 31, 2018, 12:07:22 PM7/31/18
to JanusGraph users
Your second post says that you're using gremlin-core-3.3.3.jar. So it sounds like you might have a mismatch on the GraphSON version. If you're using the latest JanusGraph 0.2.1, it packages gremlin-core-3.2.9.jar which uses an earlier GraphSON format, so you should make sure you align on the same version that your JanusGraph uses.

Then read up in the TinkerPop 3.2.9 docs on GraphSON types embedding. There are some good code examples in there to make sure you configure your reader/writer with the correct mapper for the GraphSON version.

thuany...@gmail.com

unread,
Aug 27, 2019, 8:10:22 AM8/27/19
to JanusGraph users
Stefan, have you had any developments on this matter? I'm facing the same issue.
Reply all
Reply to author
Forward
0 new messages