Gremlin 远程JanusGraph的变异侦听器事件策略引发序列化异常

Gremlin 远程JanusGraph的变异侦听器事件策略引发序列化异常,gremlin,tinkerpop,janusgraph,tinkerpop3,gremlin-server,Gremlin,Tinkerpop,Janusgraph,Tinkerpop3,Gremlin Server,我想在远程JanusGraph上收听突变,但我无法找出正确的设置使其正常工作 JanusGraph堆栈: JanusGraphdocker image**0.5.2(使用Apache TinkerPop Gremlin 3.4.6)和cql es配置 Cassandradocker image3.11.6 ElasticSearchdocker image7.3.1 gremlin服务器cql es.yaml的序列化程序部分更新为以下行: - { className: org.apache.ti

我想在远程JanusGraph上收听突变,但我无法找出正确的设置使其正常工作

JanusGraph堆栈:
JanusGraphdocker image**0.5.2(使用Apache TinkerPop Gremlin 3.4.6)和cql es配置
Cassandradocker image3.11.6
ElasticSearchdocker image7.3.1
gremlin服务器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客户端堆栈: 基于
Java8
janusgraph核心0.5.2
小精灵驱动程序3.4.6
远程对象。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]
  }
}
完整的代码(不含
ConsolidateListener
)如下所示:

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示例的副本,修改了构造函数以接受图名而不是完整图,因为
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.access$1700(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$6.run(SingleThreadEventExecutor.java:1044)
    at io.netty.util.internal.ThreadExecutorMap$2.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

如果我使用Strategies(eventStrategy)删除
,顶点将添加到图形中,并且我也能够正常查询图形。但是,我无法使用
EventStrategy
配置
GraphTraversalSource

Q1:我的想法是,具有已定义事件策略的消息不能用
GryoMessageSerializerV3d0
序列化,或者应该以某种方式在服务器端注册变异侦听器/事件策略,但我找不到任何关于如何执行该操作的参考。有这种配置的例子吗

Q2:我做错了什么?甚至可以将TinkerPop的事件策略用于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)
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

将序列化程序更改为
GraphBinaryMessageSerializerV1
将提供:

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)
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

问题1:我的想法是,具有已定义事件策略的消息不能用GryoMessageSerializerV3d0序列化,或者应该以某种方式在服务器端注册变异侦听器/事件策略,但我找不到任何关于如何执行该操作的参考

这是正确的<代码>事件策略
无法跨远程连接工作

问题2:我做错了什么?甚至可以将TinkerPop的事件策略用于JanusGraph吗

可以将它与JanusGraph一起使用,但只能在嵌入式模式下使用,因为
MutationListener
实现不知道如何将事件发送回客户端。驱动程序可能需要一些重要的更改来引入一种机制来支持这一点,因此这是一个非常重要的更改。如果解决了这个问题,那么对于提供自定义
MutationListeners
的用户来说,仍然有序列化问题需要解决(尽管可能这是不允许的)

问题3:有没有其他方法可以监听远程JanusGraph突变


这里的关键词是“远程”,我认为目前没有任何东西允许这样做。你需要建立你自己的某种类型。一种方法可能是在服务器上用
EventStrategy
配置“g”,然后添加一个
MutationListener
,将这些事件发送到一个单独的队列,您可以远程使用该队列。你也可以考虑查看并设计一个类似的方案。

谢谢你,stephen mallette。您证实了我的怀疑,因为所有带有EventStrategy的文档/示例都非常简单,并且没有远程图形。因此,如果我理解正确,我实际上需要使用定制的变异侦听器扩展服务器端代码,该侦听器将向(比方说)Kafka发送事件?我会看一看JanusGraph总线,但第一眼看来我也会遇到同样的问题。由于触发器日志与已识别的事务一起工作,并且在远程连接的情况下,您实际上无法控制事务。是的-我想您应该将自定义
MutationListener
放入服务器,并将其写入Kafka之类的内容。