连接到从Java编写Janusgraph远程遍历

时间:2019-02-02 12:29:55

标签: java janusgraph compose

我正在尝试连接到远程compose-janusgraph服务器以创建图形并添加顶点。需要注意的是我没有访问服务器配置或有能力改变服务器设置。

我能够有这样做在我的本地小鬼控制台

:remote connect tinkerpop.server conf/compose.yaml session
:remote console
graph=ConfiguredGraphFactory.create("mygraph")
graph=ConfiguredGraphFactory.open("mygraph")
g.addV("pat")
g.tx().commit()

我想要做同样的使用GraphTraversalSource Java客户端。从Java,我能够使用Cluser-> Client-> submit选项成功提交常规字符串。但是我使用GraphTraversalSource失败,出现了各种错误。

我用于配置gremlin控制台的conf / compose.yaml如下所示,与我在远程图形gremlin.remote.driver.clusterFile config中使用的

hosts: [portal-xxx.composedb.com] 
port: 15290 
username: admin 
password: pass 
connectionPool: { enableSsl: true } 
serializer: { className: 
    org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, 
    config: { serializeResultToString: true } }

远程图形属性看起来像

gremlin.remote.remoteConnectionClass=org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteConnection
# cluster file has the remote server configuration
#gremlin.remote.driver.clusterFile=gremlin-console.yaml
gremlin.remote.driver.clusterFile=/Users/julian.stephen/ibm.github/privacy-secbu/Privacy-DataViz/src/main/resources/gremlin-console.yaml
# source name is the global graph traversal source defined on the server
gremlin.remote.driver.sourceName=mygraph

如果我尝试

Graph graph = EmptyGraph.instance();
GraphTraversalSource g = graph.traversal().withRemote(conf);
g.addV("Java Remote Test");
g.close();

代码无例外运行,但未在图形中创建顶点。我以为是因为tx()没有提交。因此,我尝试获取ConfiguredGraphFactory而不是Empty graph,但是下面的所有选项都会导致异常。

JanusGraph graph = ConfiguredGraphFactory.open("mygraph");

代替EmptyGraph导致错误的(与一个下一个描述)。当我创建一个配置ConfiguredGraphFactory.createConfiguration(new MapConfiguration(map));,然后尝试打开图形时,遇到了类似Please add a key named "ConfigurationManagementGraph" to the "graphs" property in your YAML file and restart the server to be able to use the functionality of the ConfigurationManagementGraph class. 的错误,我没有访问服务器的权限,如前所述。

我还尝试了使用JanusGraphFactory的各种变体,但无济于事。

有人可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

结果表明,这是Janusgraph服务器中channelizer设置的错误配置,该服务器没有为使用GraphConfiguration Factory创建的新图形创建动态遍历绑定。服务器团队纠正了这一错误并更新了部署后,动态遍历就受到限制,代码开始工作。