远程 JanusGraph 的突变监听器事件策略抛出序列化异常
Mutation Listener Event Strategy with remote JanusGraph is throwing serialization exception
我想在 远程 JanusGraph 上收听突变,但我无法找出使其工作的正确设置。
JanusGraph 堆栈:
JanusGraph docker 图像 **0.5.2(使用 Apache TinkerPop Gremlin 3.4.6)和 cql-es 配置
Cassandra docker 图片 3.11.6
ElasticSearch docker 图片 7.3.1
gremlin-server-cql-es.yaml
的序列化程序部分更新为以下行:
- { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV3d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry, org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistryV3d0] }}
- { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV3d0, config: { serializeResultToString: true }}
Java 客户端堆栈:
基于 pluradj/janusgraph-java-example
Java8
janusgraph-核心 0.5.2
gremlin 驱动程序 3.4.6
remote-objects.yaml
看起来如下:
hosts: [127.0.0.1]
port: 8182
serializer: {
className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV3d0,
config: {
ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry, org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistryV3d0]
}
}
完整代码(不含 ConsoleMutationListener
)如下所示:
public static void main(String[] args) {
MutationListener mutationListener = new ConsoleMutationListener("Test");
EventStrategy eventStrategy = EventStrategy.build().addListener(mutationListener).create();
try (GraphTraversalSource g = AnonymousTraversalSource.traversal()
.withRemote("conf/remote-graph.properties")
.withStrategies(eventStrategy)) {
g.addV("person").property("name", "Test").next();
} catch (Exception e) {
e.printStackTrace();
}
}
ConsoleMutationListener
是 TinkerPop 示例 ConsoleMutationListener 的副本,具有修改后的构造函数以接受图形名称而不是完整图形,因为 toString()
是唯一使用的方法。
堆栈跟踪:
io.netty.handler.codec.EncoderException: org.apache.tinkerpop.gremlin.driver.exception.ResponseException: An error occurred during serialization of this request [RequestMessage{, requestId=9436b08c-7e31-4fc0-b480-40904055f491, op='bytecode', processor='traversal', args={gremlin=[[withStrategies(EventStrategy)], [addV(person), property(name, Test)]], aliases={g=g}}}] - it could not be sent to the server - Reason: org.apache.tinkerpop.gremlin.driver.ser.SerializationException: java.lang.IllegalArgumentException: Class is not registered: org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.EventStrategy
Note: To register this class use: kryo.register(org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.EventStrategy.class);
at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:107)
at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:716)
at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:708)
at io.netty.channel.AbstractChannelHandlerContext.access00(AbstractChannelHandlerContext.java:56)
at io.netty.channel.AbstractChannelHandlerContext$AbstractWriteTask.write(AbstractChannelHandlerContext.java:1102)
at io.netty.channel.AbstractChannelHandlerContext$WriteAndFlushTask.write(AbstractChannelHandlerContext.java:1149)
at io.netty.channel.AbstractChannelHandlerContext$AbstractWriteTask.run(AbstractChannelHandlerContext.java:1073)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:510)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:518)
at io.netty.util.concurrent.SingleThreadEventExecutor.run(SingleThreadEventExecutor.java:1044)
at io.netty.util.internal.ThreadExecutorMap.run(ThreadExecutorMap.java:74)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.tinkerpop.gremlin.driver.exception.ResponseException: An error occurred during serialization of this request [RequestMessage{, requestId=9436b08c-7e31-4fc0-b480-40904055f491, op='bytecode', processor='traversal', args={gremlin=[[withStrategies(EventStrategy)], [addV(person), property(name, Test)]], aliases={g=g}}}] - it could not be sent to the server - Reason: org.apache.tinkerpop.gremlin.driver.ser.SerializationException: java.lang.IllegalArgumentException: Class is not registered: org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.EventStrategy
Note: To register this class use: kryo.register(org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.EventStrategy.class);
at org.apache.tinkerpop.gremlin.driver.handler.WebSocketGremlinRequestEncoder.encode(WebSocketGremlinRequestEncoder.java:60)
at org.apache.tinkerpop.gremlin.driver.handler.WebSocketGremlinRequestEncoder.encode(WebSocketGremlinRequestEncoder.java:38)
at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:89)
... 12 more
如果我删除 withStrategies(eventStrategy)
,顶点将添加到图形中,我也可以正常查询图形。但是我无法使用 EventStrategy
.
配置 GraphTraversalSource
Q1:我在想的是,具有已定义事件策略的消息不能用 GryoMessageSerializerV3d0
或突变 Listener/Event 策略序列化,应该以某种方式注册在服务器端,但我找不到任何关于如何做到这一点的参考资料。有这样配置的例子吗?
Q2:我做错了什么?甚至可以将 TinkerPop 的 EventStrategy 与 JanusGraph 一起使用吗?
Q3:有没有其他方法可以监听远程 JanusGraph 突变?
将序列化程序更改为 GraphSONMessageSerializerV3d0
会得到:
java.util.concurrent.CompletionException: org.apache.tinkerpop.gremlin.driver.exception.ResponseException: EventStrategy does can only be constructed with instance() or create(Configuration)
at java.util.concurrent.CompletableFuture.reportJoin(CompletableFuture.java:375)
at java.util.concurrent.CompletableFuture.join(CompletableFuture.java:1947)
...
Caused by: org.apache.tinkerpop.gremlin.driver.exception.ResponseException: EventStrategy does can only be constructed with instance() or create(Configuration)
将序列化程序更改为 GraphBinaryMessageSerializerV1
会得到:
java.util.concurrent.CompletionException: io.netty.handler.codec.DecoderException: org.apache.tinkerpop.gremlin.driver.ser.SerializationException: The most significant bit should be set according to the format
at java.util.concurrent.CompletableFuture.reportJoin(CompletableFuture.java:375)
at java.util.concurrent.CompletableFuture.join(CompletableFuture.java:1947)
...
Caused by: io.netty.handler.codec.DecoderException: org.apache.tinkerpop.gremlin.driver.ser.SerializationException: The most significant bit should be set according to the format
Q1: What I'm thinking is that message with defined Event Strategy cannot be serialized with GryoMessageSerializerV3d0 or Mutation Listener/Event Strategy should somehow be registered on the server side, but I can't find any references on how to do that.
没错。 EventStrategy
不适用于远程连接。
Q2: What am I doing wrong? Is it even possible to use TinkerPop's EventStrategy with JanusGraph?
可以将它与 JanusGraph 一起使用,但只能在嵌入式模式下使用,因为 MutationListener
实现不知道如何将事件发送回客户端。驱动程序可能需要进行一些重大更改才能引入支持该功能的机制,因此这是一个重要的更改。如果解决了这一点,那么仍然存在序列化问题需要为提供自定义 MutationListeners
的用户解决(尽管也许不允许这样做)。
Q3: Is there any other approach to listen to remote JanusGraph mutations?
那里的关键词是“远程”,我认为目前不存在任何允许这样做的东西。你需要建立你自己的某种东西。一种方法可能是在服务器上使用 EventStrategy
配置“g”,然后添加 MutationListener
将这些事件发送到您可以远程使用的单独队列。您也可以考虑查看 JanusGraph Bus 并设计一个类似的方案。
我想在 远程 JanusGraph 上收听突变,但我无法找出使其工作的正确设置。
JanusGraph 堆栈:
JanusGraph docker 图像 **0.5.2(使用 Apache TinkerPop Gremlin 3.4.6)和 cql-es 配置
Cassandra docker 图片 3.11.6
ElasticSearch docker 图片 7.3.1
gremlin-server-cql-es.yaml
的序列化程序部分更新为以下行:
- { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV3d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry, org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistryV3d0] }}
- { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV3d0, config: { serializeResultToString: true }}
Java 客户端堆栈:
基于 pluradj/janusgraph-java-example
Java8
janusgraph-核心 0.5.2
gremlin 驱动程序 3.4.6
remote-objects.yaml
看起来如下:
hosts: [127.0.0.1]
port: 8182
serializer: {
className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV3d0,
config: {
ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry, org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistryV3d0]
}
}
完整代码(不含 ConsoleMutationListener
)如下所示:
public static void main(String[] args) {
MutationListener mutationListener = new ConsoleMutationListener("Test");
EventStrategy eventStrategy = EventStrategy.build().addListener(mutationListener).create();
try (GraphTraversalSource g = AnonymousTraversalSource.traversal()
.withRemote("conf/remote-graph.properties")
.withStrategies(eventStrategy)) {
g.addV("person").property("name", "Test").next();
} catch (Exception e) {
e.printStackTrace();
}
}
ConsoleMutationListener
是 TinkerPop 示例 ConsoleMutationListener 的副本,具有修改后的构造函数以接受图形名称而不是完整图形,因为 toString()
是唯一使用的方法。
堆栈跟踪:
io.netty.handler.codec.EncoderException: org.apache.tinkerpop.gremlin.driver.exception.ResponseException: An error occurred during serialization of this request [RequestMessage{, requestId=9436b08c-7e31-4fc0-b480-40904055f491, op='bytecode', processor='traversal', args={gremlin=[[withStrategies(EventStrategy)], [addV(person), property(name, Test)]], aliases={g=g}}}] - it could not be sent to the server - Reason: org.apache.tinkerpop.gremlin.driver.ser.SerializationException: java.lang.IllegalArgumentException: Class is not registered: org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.EventStrategy
Note: To register this class use: kryo.register(org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.EventStrategy.class);
at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:107)
at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:716)
at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:708)
at io.netty.channel.AbstractChannelHandlerContext.access00(AbstractChannelHandlerContext.java:56)
at io.netty.channel.AbstractChannelHandlerContext$AbstractWriteTask.write(AbstractChannelHandlerContext.java:1102)
at io.netty.channel.AbstractChannelHandlerContext$WriteAndFlushTask.write(AbstractChannelHandlerContext.java:1149)
at io.netty.channel.AbstractChannelHandlerContext$AbstractWriteTask.run(AbstractChannelHandlerContext.java:1073)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:510)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:518)
at io.netty.util.concurrent.SingleThreadEventExecutor.run(SingleThreadEventExecutor.java:1044)
at io.netty.util.internal.ThreadExecutorMap.run(ThreadExecutorMap.java:74)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.tinkerpop.gremlin.driver.exception.ResponseException: An error occurred during serialization of this request [RequestMessage{, requestId=9436b08c-7e31-4fc0-b480-40904055f491, op='bytecode', processor='traversal', args={gremlin=[[withStrategies(EventStrategy)], [addV(person), property(name, Test)]], aliases={g=g}}}] - it could not be sent to the server - Reason: org.apache.tinkerpop.gremlin.driver.ser.SerializationException: java.lang.IllegalArgumentException: Class is not registered: org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.EventStrategy
Note: To register this class use: kryo.register(org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.EventStrategy.class);
at org.apache.tinkerpop.gremlin.driver.handler.WebSocketGremlinRequestEncoder.encode(WebSocketGremlinRequestEncoder.java:60)
at org.apache.tinkerpop.gremlin.driver.handler.WebSocketGremlinRequestEncoder.encode(WebSocketGremlinRequestEncoder.java:38)
at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:89)
... 12 more
如果我删除 withStrategies(eventStrategy)
,顶点将添加到图形中,我也可以正常查询图形。但是我无法使用 EventStrategy
.
GraphTraversalSource
Q1:我在想的是,具有已定义事件策略的消息不能用 GryoMessageSerializerV3d0
或突变 Listener/Event 策略序列化,应该以某种方式注册在服务器端,但我找不到任何关于如何做到这一点的参考资料。有这样配置的例子吗?
Q2:我做错了什么?甚至可以将 TinkerPop 的 EventStrategy 与 JanusGraph 一起使用吗?
Q3:有没有其他方法可以监听远程 JanusGraph 突变?
将序列化程序更改为 GraphSONMessageSerializerV3d0
会得到:
java.util.concurrent.CompletionException: org.apache.tinkerpop.gremlin.driver.exception.ResponseException: EventStrategy does can only be constructed with instance() or create(Configuration)
at java.util.concurrent.CompletableFuture.reportJoin(CompletableFuture.java:375)
at java.util.concurrent.CompletableFuture.join(CompletableFuture.java:1947)
...
Caused by: org.apache.tinkerpop.gremlin.driver.exception.ResponseException: EventStrategy does can only be constructed with instance() or create(Configuration)
将序列化程序更改为 GraphBinaryMessageSerializerV1
会得到:
java.util.concurrent.CompletionException: io.netty.handler.codec.DecoderException: org.apache.tinkerpop.gremlin.driver.ser.SerializationException: The most significant bit should be set according to the format
at java.util.concurrent.CompletableFuture.reportJoin(CompletableFuture.java:375)
at java.util.concurrent.CompletableFuture.join(CompletableFuture.java:1947)
...
Caused by: io.netty.handler.codec.DecoderException: org.apache.tinkerpop.gremlin.driver.ser.SerializationException: The most significant bit should be set according to the format
Q1: What I'm thinking is that message with defined Event Strategy cannot be serialized with GryoMessageSerializerV3d0 or Mutation Listener/Event Strategy should somehow be registered on the server side, but I can't find any references on how to do that.
没错。 EventStrategy
不适用于远程连接。
Q2: What am I doing wrong? Is it even possible to use TinkerPop's EventStrategy with JanusGraph?
可以将它与 JanusGraph 一起使用,但只能在嵌入式模式下使用,因为 MutationListener
实现不知道如何将事件发送回客户端。驱动程序可能需要进行一些重大更改才能引入支持该功能的机制,因此这是一个重要的更改。如果解决了这一点,那么仍然存在序列化问题需要为提供自定义 MutationListeners
的用户解决(尽管也许不允许这样做)。
Q3: Is there any other approach to listen to remote JanusGraph mutations?
那里的关键词是“远程”,我认为目前不存在任何允许这样做的东西。你需要建立你自己的某种东西。一种方法可能是在服务器上使用 EventStrategy
配置“g”,然后添加 MutationListener
将这些事件发送到您可以远程使用的单独队列。您也可以考虑查看 JanusGraph Bus 并设计一个类似的方案。