找不到 org.janusgraph.graphdb.relations.RelationIdentifier 类型的序列化程序

时间:2021-03-31 03:04:02

标签: serialization gremlin janusgraph tinkerpop3

从 Java 客户端检索边时,JanusGraph v0.5.3 服务器日志中出现以下错误

12277786 [gremlin-server-exec-7] WARN  org.apache.tinkerpop.gremlin.server.op.AbstractEvalOpProcessor  - The result [[e[ofncw-iyo-4avp-374][24576-hasTag->4144]]] in the request 098dc551-6558-497a-a066-b293edd29833 could not be serialized and returned.
org.apache.tinkerpop.gremlin.driver.ser.SerializationException: java.io.IOException: Serializer for type org.janusgraph.graphdb.relations.RelationIdentifier not found
    at org.apache.tinkerpop.gremlin.driver.ser.binary.ResponseMessageSerializer.writeValue(ResponseMessageSerializer.java:86)
    at org.apache.tinkerpop.gremlin.driver.ser.GraphBinaryMessageSerializerV1.serializeResponseAsBinary(GraphBinaryMessageSerializerV1.java:143)
    at org.apache.tinkerpop.gremlin.server.op.AbstractOpProcessor.makeFrame(AbstractOpProcessor.java:335)
    at org.apache.tinkerpop.gremlin.server.op.traversal.TraversalOpProcessor.handleIterator(TraversalOpProcessor.java:580)
    at org.apache.tinkerpop.gremlin.server.op.traversal.TraversalOpProcessor.lambda$iterateBytecodeTraversal$4(TraversalOpProcessor.java:411)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.IOException: Serializer for type org.janusgraph.graphdb.relations.RelationIdentifier not found
    at org.apache.tinkerpop.gremlin.structure.io.binary.TypeSerializerRegistry.validateInstance(TypeSerializerRegistry.java:392)
    at org.apache.tinkerpop.gremlin.structure.io.binary.TypeSerializerRegistry.getSerializer(TypeSerializerRegistry.java:361)
    at org.apache.tinkerpop.gremlin.structure.io.binary.GraphBinaryWriter.write(GraphBinaryWriter.java:90)
    at org.apache.tinkerpop.gremlin.structure.io.binary.types.EdgeSerializer.writeValue(EdgeSerializer.java:63)
    at org.apache.tinkerpop.gremlin.structure.io.binary.types.EdgeSerializer.writeValue(EdgeSerializer.java:34)
    at org.apache.tinkerpop.gremlin.structure.io.binary.types.SimpleTypeSerializer.writeValue(SimpleTypeSerializer.java:91)
    at org.apache.tinkerpop.gremlin.structure.io.binary.types.SimpleTypeSerializer.write(SimpleTypeSerializer.java:73)
    at org.apache.tinkerpop.gremlin.structure.io.binary.GraphBinaryWriter.write(GraphBinaryWriter.java:112)
    at org.apache.tinkerpop.gremlin.structure.io.binary.types.TraverserSerializer.writeValue(TraverserSerializer.java:49)
    at org.apache.tinkerpop.gremlin.structure.io.binary.types.TraverserSerializer.writeValue(TraverserSerializer.java:33)
    at org.apache.tinkerpop.gremlin.structure.io.binary.types.SimpleTypeSerializer.writeValue(SimpleTypeSerializer.java:91)
    at org.apache.tinkerpop.gremlin.structure.io.binary.types.SimpleTypeSerializer.write(SimpleTypeSerializer.java:73)
    at org.apache.tinkerpop.gremlin.structure.io.binary.GraphBinaryWriter.write(GraphBinaryWriter.java:112)
    at org.apache.tinkerpop.gremlin.structure.io.binary.types.CollectionSerializer.writeValue(CollectionSerializer.java:52)
    at org.apache.tinkerpop.gremlin.structure.io.binary.types.ListSerializer.writeValue(ListSerializer.java:44)
    at org.apache.tinkerpop.gremlin.structure.io.binary.types.ListSerializer.writeValue(ListSerializer.java:29)
    at org.apache.tinkerpop.gremlin.structure.io.binary.types.SimpleTypeSerializer.writeValue(SimpleTypeSerializer.java:91)
    at org.apache.tinkerpop.gremlin.structure.io.binary.types.SimpleTypeSerializer.write(SimpleTypeSerializer.java:73)
    at org.apache.tinkerpop.gremlin.structure.io.binary.GraphBinaryWriter.write(GraphBinaryWriter.java:112)
    at org.apache.tinkerpop.gremlin.driver.ser.binary.ResponseMessageSerializer.writeValue(ResponseMessageSerializer.java:84)
    ... 10 more

Java 客户端中使用的序列化程序

Map config = new HashMap();
config.put("ioRegistries", Arrays.asList("org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry"));
MessageSerializer serializer = new GraphBinaryMessageSerializerV1();
serializer.configure(config, null);

Cluster.Builder builder = Cluster.build().port(port)
        .serializer(serializer).addContactPoints(hosts)
        .loadBalancingStrategy(new LoadBalancingStrategy.RoundRobin());

服务器端序列化器

serializers:
  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphBinaryMessageSerializerV1, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }}
  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphBinaryMessageSerializerV1, config: { serializeResultToString: true }}
  - { 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.GraphSONMessageSerializerV2d0, 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] }}

为什么 GraphBinaryMessageSerializerV1 无法序列化 RelationIdentifier,即使它的 ioRegistries 是用 org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry 初始化的,RelationIdentifier 在这里注册 - https://github.com/JanusGraph/janusgraph/blob/v0.5.3/janusgraph-driver/src/main/java/org/janusgraph/graphdb/tinkerpop/JanusGraphIoRegistry.java#L35< /p>

1 个答案:

答案 0 :(得分:1)

我相信一些允许 IORegistry 挂钩 GraphBinary 序列化程序的修复程序尚未发布,尽管我确实看到了主要 JanusGraph 分支上的工作。 [1] 我遇到了与您报告的相同的问题,但能够使用 GraphSONMessageSerialializerV3d0 序列化程序使事情正常工作。

[1] https://github.com/JanusGraph/janusgraph/commit/1cb4b6e849e3f9c2802722fe7f84c760cd471429

此设置代码适用于我:

private Cluster cluster;
private GraphTraversalSource gts;
private DriverRemoteConnection drc; 

public GraphTraversalSource createConnection()
  {
    Map config = new HashMap();
    config.put("ioRegistries", Arrays.asList("org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry"));
    MessageSerializer serializer = new GraphSONMessageSerializerV3d0();
    serializer.configure(config, null);

    Cluster.Builder builder = Cluster.build();
    builder.addContactPoint("localhost");
    builder.port(8182);
    builder.enableSsl(false);
    builder.serializer(serializer);
    this.cluster = builder.create();
    this.drc = DriverRemoteConnection.using(cluster);
    this.gts = traversal().withRemote(drc);

    return(gts);
  }

使用该配置,我可以返回边。例如:

 public void runTests()
  {
    GraphTraversalSource g = createConnection();
    List<Edge> edge = g.E().limit(1).toList();
    System.out.println(edge);
    closeConnection();
  }

为了使其正常工作,我禁用了 Gremlin 服务器上的 Graph Binary 序列化程序,而只保留了 GraphSON 序列化程序。