Pistacchio
Pistacchio

Reputation: 465

Gremlin Java 3.4 withRemote deprecated

So prior to gremlin java 3.4 I used the following code to connect to a remote graph:

Cluster.Builder builder = Cluster.build();
builder.addContactPoint(GREMLIN_SERVER);
builder.port(GREMLIN_PORT);
builder.serializer(new GryoMessageSerializerV1d0());
cluster = builder.create();
g = EmptyGraph.instance().traversal().withRemote(DriverRemoteConnection.using(cluster, GRAPH_NAME));
return g;

I've updated JanusGraph to version 0.4.0 and tried to use gremlin java 3.4.3 and I see every withRemote method is now deprecated.

The gremlin server is configured to use the JanusGraphManager with the ConfigurationManagementGraph. And at startup it runs the following script:

def globals = [:]


def getGraph() {
    def graphNames =  ConfiguredGraphFactory.getGraphNames();
    def graphMaps = [:];
    for (graphName in graphNames) {
        def g = ConfiguredGraphFactory.open(graphName);
        graphMaps.put(graphName, g.traversal())
    }
    return graphMaps;
}

globals << getGraph()

I can't seem to find the new correct way to get a traversal source from java.

Upvotes: 3

Views: 985

Answers (1)

stephen mallette
stephen mallette

Reputation: 46216

It's always helpful to review the TinkerPop Upgrade Documentation when you upgrade your graph database dependencies. TinkerPop usually tries to point out deprecation and revised way to do things. In your case, this point here in the upgrade docs is what you need. Specifically, you need to use the new AnonymousTraversalSource rather than EmptyGraph to spawn your GraphTraversalSource:

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

Note that the javadoc would also have helped point you in this direction.

Upvotes: 3

Related Questions