首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用gremlin服务器连接到Orientdb时,“当前线程中未设置数据库实例”

使用gremlin服务器连接到Orientdb时,“当前线程中未设置数据库实例”
EN

Stack Overflow用户
提问于 2017-08-17 16:29:46
回答 1查看 491关注 0票数 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配置:

代码语言:javascript
复制
graphs: {
  graph: conf/orientdb-demodb.properties}
plugins:
  - tinkerpop.orientdb

我创建了orientdb-demodb.properties,内容如下:

代码语言:javascript
复制
gremlin.graph=org.apache.tinkerpop.gremlin.orientdb.OrientGraph
orient-url=remote:localhost/demodb
orient-user=root
orient-pass=root

然后我使用gremlinpython尝试连接到gremlin-server,如下所示:

代码语言:javascript
复制
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:

代码语言:javascript
复制
[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控制台中得到以下错误:

代码语言:javascript
复制
[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)
EN

回答 1

Stack Overflow用户

发布于 2017-08-17 19:25:14

根据我的阅读,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开发人员那里获得一些帮助。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45730131

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档