无法在远程模式下将SparkGraphComputer与Tinkerpop 3.2.3和Janusgraph 0.1.1一起使用

时间:2017-07-26 10:01:42

标签: apache-spark tinkerpop3 gremlin-server janusgraph

我已经设置了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)

以上代码在本地模式下运行正常,任何人都可以帮助我解释我在这里缺少的内容。

1 个答案:

答案 0 :(得分:4)

您需要在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服务器后,使用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]}