我不明白如何从使用ConfiguredGraphFactory创建的图形中获取JanusGraphManagement示例。
我试着这样做:
JanusGraphFactory.Builder config = JanusGraphFactory.build();
config.set("storage.hostname", storageHostname);
config.set("storage.port", storagePort);
config.set("storage.backend", STORAGE_BACKEND);
config.set("index.search.backend", SEARCH_BACKEND);
config.set("index.search.hostname", indexHostname);
config.set("index.search.port", indexPort);
config.set("graph.graphname", graphName);
JanusGraph graph = config.open();
JanusGraphManagement mgmt = graph.openManagement();
但它会产生下列例外状况:
java.lang.NullPointerException:Gremlin服务器必须配置为使用JanusGraphManager。
gremlin-server正在使用以下配置进行破坏:
host: 0.0.0.0
port: 8182
scriptEvaluationTimeout: 180000
# channelizer: org.apache.tinkerpop.gremlin.server.channel.WebSocketChannelizer
channelizer: org.janusgraph.channelizers.JanusGraphWebSocketChannelizer
graphManager: org.janusgraph.graphdb.management.JanusGraphManager
graphs: {
#graph: conf/gremlin-server/janusgraph-cql-es-server.properties,
ConfigurationManagementGraph: conf/gremlin-server/janusgraph-cql-es-server-configured.properties
}
.....
JanusGraph的一个是这样的:
gremlin.graph=org.janusgraph.core.ConfiguredGraphFactory
graph.graphname=ConfigurationManagementGraph
storage.backend=cql
storage.hostname=127.0.0.1
storage.cql.keyspace=janusgraph
cache.db-cache = true
cache.db-cache-time = 180000
cache.db-cache-size = 0.25
index.search.backend=elasticsearch
index.search.hostname=127.0.0.1
index.search.elasticsearch.client-only=true
我想做的是直接从Java代码中定义图形模式,这就是为什么我需要一个管理示例和一个遍历源是不够的
1条答案
按热度按时间8yparm6h1#
他们似乎真的不希望您从Java中执行此操作。请检查我构建的示例repo的初始提交。
一般来说,这是一个内部的魔术。你需要为
ConfigurationManagementGraph
创建一个新的嵌入式示例,并做一些其他的事情。启动和运行ConfiguredGraphFactory
的步骤如下:不要忘记,您仍然需要首先创建模板配置。
现在,您可以在应用程序中的任何地方使用singleton
ConfiguredGraphFactory
,就像文档中所说的那样。请记住,您可能不需要这样做。
Client.submit()
函数在大多数情况下都很方便。例如:编辑:
正如@FlorianHockmann在JanusGraph discord服务器上指出的那样,最好 * 不要 * 直接从Java中使用这些对象。
既然已经建立了会话,现在就可以在服务器上保存和重用变量了。
完成后别忘了打电话给
session.close()
!看看我举的这个例子