使用JanusGraph ConfiguredGraphFactory()创建新图形时,出现以下错误。
179262 [gremlin-server-session-1] WARN org.apache.tinkerpop.gremlin.driver.MessageSerializer - Response [ResponseMessage{requestId=9cdb34da-2033-4d08-9636-724743f0b798, status=ResponseStatus{code=SUCCESS, message='', attributes={}}, result=ResponseResult{data=[standardjanusgraph[hbase:[127.0.0.1]]], meta={}}}] could not be serialized by org.apache.tinkerpop.gremlin.driver.ser.AbstractGryoMessageSerializerV1d0.
java.lang.IllegalArgumentException: Class is not registered: org.janusgraph.graphdb.database.StandardJanusGraph
Note: To register this class use: kryo.register(org.janusgraph.graphdb.database.StandardJanusGraph.class);
当我从gremlin客户端运行此命令时,就会发生
ConfiguredGraphFactory.create("graph");
我可以知道如何在YAML中注册org.janusgraph.graphdb.database.StandardJanusGraph吗?
gremlin-server.yaml的定义如下。我相信我应该在序列化程序部分添加一些内容?
host: 127.0.0.1
port: 8182
scriptEvaluationTimeout: 30000
channelizer: org.janusgraph.channelizers.JanusGraphWebSocketChannelizer
graphManager: org.janusgraph.graphdb.management.JanusGraphManager
graphs: {
ConfigurationManagementGraph: conf/gremlin-server/janusgraph-hbase-configurationgraph.properties
}
scriptEngines: {
gremlin-groovy: {
plugins: { org.janusgraph.graphdb.tinkerpop.plugin.JanusGraphGremlinPlugin: {},
org.apache.tinkerpop.gremlin.server.jsr223.GremlinServerGremlinPlugin: {},
org.apache.tinkerpop.gremlin.tinkergraph.jsr223.TinkerGraphGremlinPlugin: {},
org.apache.tinkerpop.gremlin.jsr223.ImportGremlinPlugin: {classImports: [java.lang.Math], methodImports: [java.lang.Math#*]},
org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin: {files: []}}}}
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] }}
processors:
- { className: org.apache.tinkerpop.gremlin.server.op.session.SessionOpProcessor, config: { sessionTimeout: 28800000 }}
- { className: org.apache.tinkerpop.gremlin.server.op.traversal.TraversalOpProcessor, config: { cacheExpirationTime: 600000, cacheMaxSize: 1000 }}
metrics: {
consoleReporter: {enabled: true, interval: 180000},
csvReporter: {enabled: true, interval: 180000, fileName: /tmp/gremlin-server-metrics.csv},
jmxReporter: {enabled: true},
slf4jReporter: {enabled: true, interval: 180000},
gangliaReporter: {enabled: false, interval: 180000, addressingMode: MULTICAST},
graphiteReporter: {enabled: false, interval: 180000}}
maxInitialLineLength: 4096
maxHeaderSize: 8192
maxChunkSize: 8192
maxContentLength: 65536
maxAccumulationBufferComponents: 1024
resultIterationBatchSize: 64
writeBufferLowWaterMark: 32768
writeBufferHighWaterMark: 65536
答案 0 :(得分:1)
我假设您有一台运行有您提供的配置的服务器,现在您想从一个普通的脚本连接到该服务器。那是我遇到同样问题的地方。 解决方法如下:
cluster = Cluster.open("../conf/remote.yaml")
client = cluster.connect()
client.init()
client.submit('kryo.register(org.janusgraph.graphdb.database.StandardJanusGraph.class)\n'+
'ConfiguredGraphFactory.open("mygraph")')
GraphTraversalSource g = EmptyGraph.instance().traversal().withRemote(
DriverRemoteConnection.using(cluster, "mygraph_traversal"))
这在没有gremlin控制台的情况下有效,因此您可以直接编译并执行该groovy脚本(给定必要的依赖项)。
答案 1 :(得分:0)
GryoMessageSerializerV3d0已被弃用。 使用GraphBinaryMessageSerializerV1
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 }}