简体   繁体   English

使用Gremlin GraphFactory连接到AWS Neptune

[英]Connecting to AWS Neptune with Gremlin GraphFactory

The examples on the AWS documentation show how to connect to AWS Neptune using Gremlin as follows: AWS文档上的示例显示了如何使用Gremlin连接到AWS Neptune,如下所示:

Cluster.Builder builder = Cluster.build();
builder.addContactPoint("your-neptune-endpoint");
builder.port(8182);
builder.enableSsl(true);
builder.keyCertChainFile("SFSRootCAG2.pem");

Cluster cluster = builder.create();

GraphTraversalSource g = EmptyGraph.instance().traversal().withRemote(DriverRemoteConnection.using(cluster));

However, my current code to connect to a generic Gremlin graph looks like: 但是,我当前连接到通用Gremlin图的代码如下:

Configuration conf = new PropertiesConfiguration(...);
...    //Set configuration
Graph graph = GraphFactory.open(conf);

Does anyone know how to use this second approach with a GraphFactory to connect to Neptune? 有谁知道如何将第二种方法与GraphFactory一起使用以连接到Neptune? I haven't been able to find any examples anywhere. 我在任何地方都找不到任何示例。

Neptune does not provide a Graph instance as Gremlin is executed remotely not locally. Neptune不提供Graph实例,因为Gremlin是在本地而不是远程执行的。 GraphFactory is really only for situations where you have a Graph instance you want to create. GraphFactory实际上仅适用于您具有要创建的Graph实例的情况。 There used to be a RemoteGraph that allowed for this (though still used in the TinkerPop test suite), but that approach has long since been abandoned and is no longer recommended. 曾经有一个RemoteGraph允许这样做(尽管在TinkerPop测试套件中仍然使用),但是这种方法早已被放弃,不再推荐使用。

The method for connecting to Remote Gremlin Providers like Neptune that you initially presented is the recommended way to establish the GraphTraversalSource . 最初介绍的用于连接到Neptune等远程Gremlin Provider的方法是建立GraphTraversalSource的推荐方法。 It is worth noting however that as of 3.3.5 the preferred method gets rid of EmptyGraph and allows you to instantiate the GraphTraversalSource anonymously as follows: 但是,值得注意的是,从3.3.5开始,首选方法摆脱了EmptyGraph并允许您匿名实例化GraphTraversalSource ,如下所示:

import static org.apache.tinkerpop.gremlin.process.traversal.AnonymousTraversalSource.traversal;

GraphTraversalSource g = traversal().withRemote('conf/remote-graph.properties');

There are other overloads for withRemote() that should look familiar as well. withRemote()其他重载也应该看起来很熟悉。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM