在同一个图上绑定两个实例 Janusgraph 时出错

Error when binding two instances Janusgraph on same graph

所以我正在尝试部署 2 个 Janusgraph (v 0.3.1) 实例以将数据插入到 ScyllaDb 后端的相同键空间中。为此,我使用 docker 部署了 2 个 janusgraph 容器。第一个开始时没有错误,并在我的 ScyllaDb 中创建了键空间,但第二个显示了一些错误。

所以我的 Janusgraph 容器在一个集群上工作,而我的后端在另一个集群上工作。实际上,当我的密钥空间 Scylla 已经创建并且我遇到同样的问题时,我尝试只使用一个容器来重新启动它。 我还发现了一个脚本 clean.groovy,它允许强制关闭打开的图形实例。但是没有任何效果...

5316 [main] INFO  org.janusgraph.diskstorage.Backend  - Initiated backend operations thread pool of size 8
5648 [main] WARN  org.apache.tinkerpop.gremlin.server.GremlinServer  - Graph [graph] configured at [/janusgraph-config/janusgraph.properties] could not be instantiated and will not be available in Gremlin Server.  GraphFactory message: GraphFactory could not instantiate this Graph implementation [class org.janusgraph.core.JanusGraphFactory]
java.lang.RuntimeException: GraphFactory could not instantiate this Graph implementation [class org.janusgraph.core.JanusGraphFactory]
        at org.apache.tinkerpop.gremlin.structure.util.GraphFactory.open(GraphFactory.java:82)
        at org.apache.tinkerpop.gremlin.structure.util.GraphFactory.open(GraphFactory.java:70)
        at org.apache.tinkerpop.gremlin.structure.util.GraphFactory.open(GraphFactory.java:104)
        at org.apache.tinkerpop.gremlin.server.util.DefaultGraphManager.lambda$new[=10=](DefaultGraphManager.java:57)
        at java.util.LinkedHashMap$LinkedEntrySet.forEach(LinkedHashMap.java:671)
        at org.apache.tinkerpop.gremlin.server.util.DefaultGraphManager.<init>(DefaultGraphManager.java:55)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at org.apache.tinkerpop.gremlin.server.util.ServerGremlinExecutor.<init>(ServerGremlinExecutor.java:80)
        at org.apache.tinkerpop.gremlin.server.GremlinServer.<init>(GremlinServer.java:120)
        at org.apache.tinkerpop.gremlin.server.GremlinServer.<init>(GremlinServer.java:84)
        at org.apache.tinkerpop.gremlin.server.GremlinServer.main(GremlinServer.java:343)
Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.tinkerpop.gremlin.structure.util.GraphFactory.open(GraphFactory.java:78)
        ... 13 more
Caused by: org.janusgraph.core.JanusGraphException: A JanusGraph graph with the same instance id [0a0a01657-node11] is already open. Might required forced shutdown.
        at org.janusgraph.graphdb.database.StandardJanusGraph.<init>(StandardJanusGraph.java:165)
        at org.janusgraph.core.JanusGraphFactory.open(JanusGraphFactory.java:160)
        at org.janusgraph.core.JanusGraphFactory.open(JanusGraphFactory.java:131)
        at org.janusgraph.core.JanusGraphFactory.open(JanusGraphFactory.java:111)
        ... 18 more
5651 [main] INFO  org.apache.tinkerpop.gremlin.server.util.ServerGremlinExecutor  - Initialized Gremlin thread pool.  Threads in pool named with pattern gremlin-*
5800 [main] INFO  org.apache.tinkerpop.gremlin.server.util.ServerGremlinExecutor  - Initialized GremlinExecutor and preparing GremlinScriptEngines instances.
7837 [gremlin-server-exec-1] ERROR org.apache.tinkerpop.gremlin.jsr223.DefaultGremlinScriptEngineManager  - Could not create GremlinScriptEngine for gremlin-groovy
java.lang.IllegalStateException: javax.script.ScriptException: javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: graph for class: Script1
        at org.apache.tinkerpop.gremlin.jsr223.DefaultGremlinScriptEngineManager.lambda$createGremlinScriptEngine(DefaultGremlinScriptEngineManager.java:464)
        at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
        at java.util.stream.ReferencePipeline.accept(ReferencePipeline.java:193)
        at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
        at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
        at java.util.stream.ReferencePipeline.accept(ReferencePipeline.java:270)
        at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
        at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
        at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
        at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
        at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
        at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
        at org.apache.tinkerpop.gremlin.jsr223.DefaultGremlinScriptEngineManager.createGremlinScriptEngine(DefaultGremlinScriptEngineManager.java:450)
        at org.apache.tinkerpop.gremlin.jsr223.DefaultGremlinScriptEngineManager.getEngineByName(DefaultGremlinScriptEngineManager.java:219)
        at org.apache.tinkerpop.gremlin.jsr223.CachedGremlinScriptEngineManager.lambda$getEngineByName[=10=](CachedGremlinScriptEngineManager.java:57)
        at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660)
        at org.apache.tinkerpop.gremlin.jsr223.CachedGremlinScriptEngineManager.getEngineByName(CachedGremlinScriptEngineManager.java:57)
        at org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor.lambda$eval[=10=](GremlinExecutor.java:263)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        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)
Caused by: javax.script.ScriptException: javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: graph for class: Script1
        at org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine.eval(GremlinGroovyScriptEngine.java:397)
        at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)
        at org.apache.tinkerpop.gremlin.jsr223.DefaultGremlinScriptEngineManager.lambda$createGremlinScriptEngine(DefaultGremlinScriptEngineManager.java:460)
        ... 24 more
Caused by: javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: graph for class: Script1
        at org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine.eval(GremlinGroovyScriptEngine.java:713)
        at org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine.eval(GremlinGroovyScriptEngine.java:395)
        ... 26 more
Caused by: groovy.lang.MissingPropertyException: No such property: graph for class: Script1
        at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:66)
        at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:51)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:310)
        at Script1.run(Script1.groovy:16)
        at org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine.eval(GremlinGroovyScriptEngine.java:690)
        ... 27 more
7841 [main] WARN  org.apache.tinkerpop.gremlin.server.util.ServerGremlinExecutor  - Could not initialize gremlin-groovy GremlinScriptEngine as init script could not be evaluated
java.util.concurrent.CompletionException: java.lang.IllegalArgumentException: gremlin-groovy is not an available GremlinScriptEngine
        at java.util.concurrent.CompletableFuture.reportJoin(CompletableFuture.java:375)
        at java.util.concurrent.CompletableFuture.join(CompletableFuture.java:1934)
        at org.apache.tinkerpop.gremlin.server.util.ServerGremlinExecutor.lambda$new(ServerGremlinExecutor.java:141)
        at java.util.LinkedHashMap$LinkedKeySet.forEach(LinkedHashMap.java:559)
        at org.apache.tinkerpop.gremlin.server.util.ServerGremlinExecutor.<init>(ServerGremlinExecutor.java:136)
        at org.apache.tinkerpop.gremlin.server.GremlinServer.<init>(GremlinServer.java:120)
        at org.apache.tinkerpop.gremlin.server.GremlinServer.<init>(GremlinServer.java:84)
        at org.apache.tinkerpop.gremlin.server.GremlinServer.main(GremlinServer.java:343)
Caused by: java.lang.IllegalArgumentException: gremlin-groovy is not an available GremlinScriptEngine
        at org.apache.tinkerpop.gremlin.jsr223.CachedGremlinScriptEngineManager.registerLookUpInfo(CachedGremlinScriptEngineManager.java:95)
        at org.apache.tinkerpop.gremlin.jsr223.CachedGremlinScriptEngineManager.getEngineByName(CachedGremlinScriptEngineManager.java:58)
        at org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor.lambda$eval[=10=](GremlinExecutor.java:263)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        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)

我认为所有这些错误都是由此造成的:

Caused by: org.janusgraph.core.JanusGraphException: A JanusGraph graph with the same instance id [0a0a01657-node11] is already open. Might required forced shutdown.

这是脚本 clean.groovy

graph = JanusGraphFactory.open('janusgraph.properties') 
mgmt = graph.openManagement() 
instances = mgmt.getOpenInstances()

instances.iterator().findAll {
  !it.contains('current')
}.each { 
  mgmt.forceCloseInstance(it)
}

mgmt.commit()

那么有人解决了这个图形问题吗? 提前致谢。

我终于得到答案了!所以你可以使用 ConfiguredGraphFactory 但它对我来说失败了。因此,对于第一个容器,我正常启动了它,但第二个容器,我在 janusgraph.properties 文件中添加了另一个配置:

graph.replace-instance-if-exists=true`

而且效果很好!