3
votes

I get the following error after adding an edge in Java:

16:40:44.267 [gremlin-driver-loop-1] WARN org.apache.tinkerpop.gremlin.driver.MessageSerializer - Response [PooledUnsafeDirectByteBuf(ridx: 98, widx: 98, cap: 98)] could not be deserialized by org.apache.tinkerpop.gremlin.driver.ser.AbstractGryoMessageSerializerV3d0. org.apache.tinkerpop.shaded.kryo.KryoException: Encountered unregistered class ID: 65536 Serialization trace: id (org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceEdge) at org.apache.tinkerpop.gremlin.structure.io.gryo.AbstractGryoClassResolver.readClass(AbstractGryoClassResolver.java:148)

Janusgraph version is 0.3.0, Tinkerpop version is 3.3.3, the Janusgraph serialization configuration is as follows:

> serializers: - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV3d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }} - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV3d0, config: { serializeResultToString: true }} - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV3d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }} # Older serialization versions for backwards compatibility: - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }} - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoLiteMessageSerializerV1d0, config: {ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }} - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { serializeResultToString: true }} - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV2d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }} - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV1d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistryV1d0] }} - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistryV1d0] }}

The following error is logged on the server at about the same time and appears to be related:

> 105869 2018-11-08 06:10:44,659 [gremlin-server-worker-1] WARN io.netty.channel.DefaultChannelPipeline - An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception. java.io.IOException: Connection reset by peer at sun.nio.ch.FileDispatcherImpl.read0(Native Method)

As far as I can see I have my ducks lined up in terms of matching serializer versions but clearly must have missed something. Any assistance greatly appreciated!

The code can be seen here: https://gist.github.com/ptclarke/45472fa5c268a6e8441e4c35615194aa

1

1 Answers

6
votes

I think you need the JanusGraphIoRegistry registered on the client side:

GryoMapper.Builder builder = GryoMapper.build().
                                        addRegistry(JanusGraphIoRegistry.getInstance());

GryoMessageSerializerV3d0 serializer = new GryoMessageSerializerV3d0(builder);
Cluster cluster = Cluster.build().
                          addContactPoint(host).
                          port(port).
                          serializer(serializer).
                          create();

As some additional advice on your code. Consider avoiding lots of small updates like this:

public void updateVertex(Vertex v, Map<Object, Object> propertyMap) {
    for(Entry<Object, Object> e : propertyMap.entrySet()) {
        g.V(v).property(e.getKey(), e.getValue()).next();
    }
}

and instead do:

public void updateVertex(Vertex v, Map<Object, Object> propertyMap) {
    GraphTraversal<Vertex,Vertex> t = g.V(v);
    for(Entry<Object, Object> e : propertyMap.entrySet()) {
        t = t.property(e.getKey(), e.getValue());
    }
    t.iterate();
}

You can also simplify your "add edge" code:

public Edge addEdge(String label, Vertex from, Vertex to) {         
    return g.V(from).addE(label).to(to).next(); 
}