2

我正在使用 apache-tinkerpop-gremlin-server-3.2.5 尝试连接到 orientdb-community-tp3-3.0.0m2。

我已经为 gremlin 安装了 orientdb 插件,如下所示: bin/gremlin-server.sh -i com.orientechnologies orientdb-gremlin 3.0.0m2

然后像这样编辑 gremlin-server.yaml 配置:

graphs: {
  graph: conf/orientdb-demodb.properties}
plugins:
  - tinkerpop.orientdb

我用以下内容创建了 orientdb-demodb.properties:

gremlin.graph=org.apache.tinkerpop.gremlin.orientdb.OrientGraph
orient-url=remote:localhost/demodb
orient-user=root
orient-pass=root

然后我使用 gremlinpython 尝试像这样连接到 gremlin-server:

from gremlin_python import statics
from gremlin_python.process.graph_traversal import __
from gremlin_python.process.strategies import *
from gremlin_python.driver.driver_remote_connection import (
    DriverRemoteConnection)
from gremlin_python.structure.graph import Graph


conn = DriverRemoteConnection(
    'ws://localhost:8182/gremlin', 'g', pool_size=4)
g = Graph().traversal().withRemote(conn)
g.V().promise().result().toList()

当我运行 gremlin-server 时,它会启动并连接到 orientdb:

[INFO] GremlinServer - 
         \,,,/
         (o o)
-----oOOo-(3)-oOOo-----

[INFO] GremlinServer - Configuring Gremlin Server from conf/gremlin-server-orientdb.yaml
[INFO] MetricManager - Configured Metrics ConsoleReporter configured with report interval=180000ms
[INFO] MetricManager - Configured Metrics CsvReporter configured with report interval=180000ms to fileName=/tmp/gremlin-server-metrics.csv
[INFO] MetricManager - Configured Metrics JmxReporter configured with domain= and agentId=
[INFO] MetricManager - Configured Metrics Slf4jReporter configured with interval=180000ms and loggerName=org.apache.tinkerpop.gremlin.server.Settings$Slf4jReporterMetrics
[INFO] DefaultGraphManager - Graph [graph] was successfully configured via [conf/orientdb-demodb.properties].
[INFO] ServerGremlinExecutor - Initialized Gremlin thread pool.  Threads in pool named with pattern gremlin-*
[INFO] ScriptEngines - Loaded gremlin-groovy ScriptEngine
[INFO] GremlinExecutor - Initialized gremlin-groovy ScriptEngine with scripts/empty-sample.groovy
[INFO] ServerGremlinExecutor - Initialized GremlinExecutor and preparing GremlinScriptEngines instances.
[INFO] ServerGremlinExecutor - Initialized gremlin-groovy GremlinScriptEngine and registered metrics
[INFO] ServerGremlinExecutor - A GraphTraversalSource is now bound to [g] with graphtraversalsource[orientgraph[remote:localhost/demodb], standard]
[INFO] OpLoader - Adding the standard OpProcessor.
[INFO] OpLoader - Adding the control OpProcessor.
[INFO] OpLoader - Adding the session OpProcessor.
[INFO] OpLoader - Adding the traversal OpProcessor.
[INFO] TraversalOpProcessor - Initialized cache for TraversalOpProcessor with size 1000 and expiration time of 600000 ms
[INFO] GremlinServer - Executing start up LifeCycleHook
[INFO] Logger$info - Executed once at startup of Gremlin Server.
[INFO] AbstractChannelizer - Configured application/vnd.gremlin-v1.0+gryo with org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0
[INFO] AbstractChannelizer - Configured application/vnd.gremlin-v1.0+gryo-lite with org.apache.tinkerpop.gremlin.driver.ser.GryoLiteMessageSerializerV1d0
[INFO] AbstractChannelizer - Configured application/vnd.gremlin-v1.0+gryo-stringd with org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0
[INFO] AbstractChannelizer - Configured application/vnd.gremlin-v1.0+json with org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV1d0
[INFO] AbstractChannelizer - Configured application/vnd.gremlin-v2.0+json with org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV2d0
[INFO] AbstractChannelizer - Configured application/json with org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0
[INFO] GremlinServer$1 - Gremlin Server configured with worker thread pool of 1, gremlin pool of 8 and boss thread pool of 1.
[INFO] GremlinServer$1 - Channel started at port 8182.

当我运行 python 脚本时,它会出错,并且在 gremlin-server 控制台中出现以下错误:

[WARN] TraversalOpProcessor - Exception processing a Traversal on iteration for request [9b736255-42da-4688-935e-a1e2f2f9cd93].
com.orientechnologies.orient.core.exception.ODatabaseException: The database instance is not set in the current thread. Be sure to set it with: ODatabaseRecordThreadLocal.INSTANCE.set(db);
    at com.orientechnologies.orient.core.db.ODatabaseRecordThreadLocal.get(ODatabaseRecordThreadLocal.java:51)
    at com.orientechnologies.orient.core.index.OIndexManagerAbstract.getDatabase(OIndexManagerAbstract.java:438)
    at com.orientechnologies.orient.core.index.OIndexManagerAbstract.getStorage(OIndexManagerAbstract.java:442)
    at com.orientechnologies.orient.core.index.OIndexManagerAbstract.getServerLocale(OIndexManagerAbstract.java:531)
    at com.orientechnologies.orient.core.index.OIndexManagerAbstract.getIndexOnProperty(OIndexManagerAbstract.java:537)
    at com.orientechnologies.orient.core.index.OIndexManagerAbstract.getClassIndexes(OIndexManagerAbstract.java:347)
4

1 回答 1

0

鉴于我对以下内容的阅读,OrientDB 和 Gremlin Server 之间可能存在一些不兼容:

http://orientdb.com/docs/2.2/Java-Multi-Threading.html

问题是 OrientDB 不是线程安全的。它需要每个线程一个实例。这种方法与 TinkerPop 的事务模型有些冲突,该模型假设Graph实例可以跨线程使用。

我似乎想不出一个 TinkerPop 方面的解决方法,在看了一点代码之后,我不确定我是否看到了问题。您可能想对此问题发表评论:

https://github.com/orientechnologies/orientdb-gremlin/issues/114

并参考这个问题,看看您是否可以从 OrientDB 开发人员那里获得一些帮助。

于 2017-08-17T11:25:14.443 回答