无法从 .NET 客户端看到我在 JanusGraph 服务器上使用 BerkeleyDB 存储的图形

Cannot see my graph on JanusGraph Server with BerkeleyDB storage from .NET client

谁能帮我理解为什么我看不到来自 JanusGraph.Net 客户端的图表?

我是 运行 来自 Docker Hub 的最新 Docker image JanusGraph。使用内置控制台连接到 JanusGraph 后,我创建了一个示例 Graph of the Gods 并能够使用以下命令查询它:

graph = JanusGraphFactory.open('conf/janusgraph-berkeleyje-lucene.properties')
GraphOfTheGodsFactory.load(graph)
g = graph.traversal()
g.V().count()

因为图表在容器重启后仍然存在(能够再次查询它 没有 GraphOfTheGodsFactory.load(graph) 命令)并且一些文件是在 /opt/janusgraph/db/berkeley/ 文件夹中创建的我假设一切正常。

然后我将 /opt/janusgraph/conf/gremlin-server/gremlin-server.yamlgraphs.graph 属性(取自 docker-entrypoint.sh 的路径)更新为这个值:

graphs: {
  graph: conf/janusgraph-berkeleyje-lucene.properties
}

并重新启动了容器。

之后,我使用 JanusGraph.Net 创建了一个简单的 .NET 控制台应用程序,代码如下:

static void Main(string[] args)
{
    var client = JanusGraphClientBuilder
       .BuildClientForServer(new GremlinServer("localhost", 8182))
       .Create();

    var g = AnonymousTraversalSource
       .Traversal()
       .WithRemote(new DriverRemoteConnection(client));

    var count = g.V().Count().Next();
}

并且 count 变量始终为零。看起来我的 .NET 应用程序连接到此服务器上的另一个(可能在内存中)空图形。

我还应该更改或更新什么?请帮助解决这个问题。

好的,不是很明显,但是 JanusGraph Docker 图像默认预配置为使用 BerkeleyDB(顺便说一句,根据 documentation 应该是 Cassandra)。我发现它查看了 Gremlin 服务器日志。 Gremlin 服务器配置为在启动时使用 /etc/opt/janusgraph/janusgraph.properties。此文件包含与 conf/janusgraph-berkeleyje.properties 等完全不同的 BerkeleyDB 配置 - 不同的文件夹等。这就是为什么我的 .NET 应用程序没有看到任何数据 - 它已连接(通过 Gremlin 服务器)到不同的BerkeleyDB 数据库。

我也无法通过 graph = JanusGraphFactory.open('/etc/opt/janusgraph/janusgraph.properties') 将此文件加载到 Gremlin 控制台 - 出现访问问题。在我将此文件复制到 conf 目录(并更改访问权限)后 - 我收到另一个错误:Could not instantiate implementation: org.janusgraph.diskstorage.berkeleyje.BerkeleyJEStoreManager 可能是因为 BerkeleyDB 已经存在。

所以我想出如何通过 Gremlin 控制台连接到现有数据库的唯一方法是使用 :remote connect 命令。我能够加载示例 "Graph of the Gods" 数据库,然后使用以下命令从我的 .NET 应用程序访问它:

:remote connect tinkerpop.server conf/remote.yaml
:> GraphOfTheGodsFactory.load(graph)
:> g.V().count()
==>12