我正在使用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)
答案 0 :(得分: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开发者那里获得一些帮助。