3

我已经设置了 Tinkerpop Gremlin Server 3.2.3 和 Tinkerpop Gremlin Console 3.2.3,并将 janusgraph 0.1.1 作为插件添加到两者。

我在远程模式下运行以下代码,最终出现下面列出的异常

:remote connect tinkerpop.server conf/remote.yaml
:> graph = GraphFactory.open('conf/hadoop-graph/hadoop-load.properties')
:> blvp = BulkLoaderVertexProgram.build().writeGraph('conf/connection.properties').create(graph)
:> graph.compute(SparkGraphComputer).program(blvp).submit().get()

例外

java.lang.IllegalArgumentException: Graph does not support the provided graph computer: SparkGraphComputer
        at org.apache.tinkerpop.gremlin.structure.Graph$Exceptions.graphDoesNotSupportProvidedGraphComputer(Graph.java:1140)
        at org.janusgraph.graphdb.tinkerpop.JanusGraphBlueprintsGraph.compute(JanusGraphBlueprintsGraph.java:145)
        at org.apache.tinkerpop.gremlin.structure.Graph$compute$0.call(Unknown Source)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
        at Script4.run(Script4.groovy:1)
        at org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine.eval(GremlinGroovyScriptEngine.java:619)
        at org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine.eval(GremlinGroovyScriptEngine.java:448)
        at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:233)
        at org.apache.tinkerpop.gremlin.groovy.engine.ScriptEngines.eval(ScriptEngines.java:119)
        at org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor.lambda$eval$2(GremlinExecutor.java:287)
        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)

上面的代码在本地模式下运行良好,任何人都可以帮我解决我在这里遗漏的问题。

4

1 回答 1

6

您需要在 Gremlin Server 配置中定义 OLAP 图,并为 OLAP 图遍历源添加脚本绑定。

例如在 中conf/gremlin-server/gremlin-server.yaml,将 更新graphs为如下内容:

graphs: {
  graph: conf/gremlin-server/janusgraph-cassandra-es-server.properties,
  olapgraph: conf/hadoop-graph/read-cassandra.properties
}

稍后在 中conf/gremlin-server/gremlin-server.yaml,默认配置用于scripts/empty-sample.groovy配置图遍历源。

scriptEngines: {
  gremlin-groovy: {
    imports: [java.lang.Math],
    staticImports: [java.lang.Math.PI],
    scripts: [scripts/empty-sample.groovy]}}

因此scripts/empty.groovy,在 OLAP 遍历源中添加一个绑定og,它将使用SparkGraphComputer

globals << [g : graph.traversal(), og : olapgraph.traversal().withComputer(org.apache.tinkerpop.gremlin.spark.process.computer.SparkGraphComputer)]

重新启动 Gremlin Server 后,使用 Gremlin Console 连接到它,您会发现图形和图形遍历源都可用:

gremlin> :remote connect tinkerpop.server conf/remote.yaml
==>Configured localhost/127.0.0.1:8182
gremlin> :> graph
==>standardjanusgraph[cassandrathrift:[127.0.0.1]]
gremlin> :> g
==>graphtraversalsource[standardjanusgraph[cassandrathrift:[127.0.0.1]], standard]
gremlin> :> olapgraph
==>hadoopgraph[cassandrainputformat->gryooutputformat]
gremlin> :> og
==>graphtraversalsource[hadoopgraph[cassandrainputformat->gryooutputformat], sparkgraphcomputer]
gremlin> :> og.V().valueMap(true)
==>{label=software, name=[ripple], lang=[java], id=4328}
==>{label=software, name=[lop], lang=[java], id=4240}
==>{label=person, name=[josh], id=8216, age=[32]}
==>{label=person, name=[marko], id=4120, age=[29]}
==>{label=person, name=[vadas], id=4176, age=[27]}
==>{label=person, name=[peter], id=4296, age=[35]}
于 2017-08-03T18:59:24.297 回答