gremlin - Gremlin:AbstractGryoMessageSerializerV3d0。org.apache.tinkerpop.shaded.kryo.KravyoException:遇到未注册的类 ID:65536
问题描述
我正在使用 gremlin 使用 Java 对 JanusGraph 进行查询。我的 Java 代码正在使用 Cluster client.submit(query) 触发 g.addV(...) 查询。cluster = Cluster.build() .addContactPoint("localhost") .port(8182)
.serializer(Serializers.GRAPHSON_V3D0) .maxInProcessPerConnection(32) .maxSimultaneousUsagePerConnection(32) .maxContentLength(1000000) .maxWaitForConnection(10) .minConnectionPoolSize(5 ) .maxConnectionPoolSize(20) .create();
出现以下错误:21:23:05.890 WARN - 响应 [PooledUnsafeDirectByteBuf(ridx: 393, widx: 393, cap: 393)] 无法被 org.apache.tinkerpop.gremlin.driver.ser.AbstractGryoMessageSerializerV3d0 反序列化。org.apache.tinkerpop.shaded.kryo.KryoException:在 org.apache.tinkerpop.gremlin.structure.io.gryo.AbstractGryoClassResolver.readClass(AbstractGryoClassResolver.java:148) 处遇到未注册的类 ID:65536。 shaded.kryo.Kryo.readClass(Kryo.java:670) 在 org.apache.tinkerpop.shaded.kryo.Kryo.readClassAndObject(Kryo.java:781) 在 org.apache.tinkerpop.gremlin.structure.io.gryo。 kryoshim.shaded.ShadedKryoAdapter.readClassAndObject(ShadedKryoAdapter.java:39) 在 org.apache.tinkerpop.gremlin.structure.io.gryo.kryohim.shaded.ShadedKryoAdapter.readClassAndObject(ShadedKryoAdapter.java:24) 在 org.apache.tinkerpop。
但我可以看到 Vertex 已添加到我的 Janus 中。但代码返回错误。
任何指导都会有所帮助。
谢谢
解决方案
这个问题的变体之前已经出现过(这里和这里在 StackOverflow 和TINKERPOP-2372上),但一般来说,这意味着服务器上有一个序列化程序在客户端上不可用(或者相反的方式可能是不常见)。在您的情况下,您可能只需要添加JanusGraphIoRegistry
到您的驱动程序配置中,如这些链接中所示,但为了方便并直接回答您的问题版本,我将使用您的Cluster
构建器设置:
GryoMapper mapper = GryoMapper.build().addRegistry(JanusGraphIoRegistry.INSTANCE).create();
Cluster cluster = Cluster.build().
addContactPoint("localhost").port(8182).
serializer(new GryoMessageSerializerV1d0(mapper)).
maxInProcessPerConnection(32).
maxSimultaneousUsagePerConnection(32).
maxContentLength(1000000).
maxWaitForConnection(10).
minConnectionPoolSize(5).
maxConnectionPoolSize(20).create();
我确实觉得奇怪的是你得到了基于 Gryo 的错误,但在你的代码片段中使用了 GraphSON 序列化程序。我假设这可能只是一个糟糕的复制/粘贴情况。请注意,您可能希望查看有关配置驱动程序这一方面的 JanusGraph 文档:7.4.2.1。通过 Gremlin 服务器连接到 JanusGraph
推荐阅读
- python - 在 VS Code 笔记本中动画/更新 matplotlib 图
- java - spring 与junit一起使用时的不同行为
- c - 在 C 中传递动态结构后无法写入内存
- java - 此版本中使用了弃用的 Gradle 功能,使其与带有 Minecraft Forge 1.12.2 的 Gradle 5.0 不兼容
- java - 不允许使用数组初始化器(扫雷的副本)
- opencv - 恢复具有已知 3d 和 2d 点的投影矩阵
- java - 使 Kafka ConcurrentMessageListenerContainer 作为一个批处理工作
- amazon-web-services - 如何使用从 Amazon EC2 下载的新密钥对?
- javascript - 待处理的任务和量角器
- python - 如何将这些 Python 代码转换为 rstudio?