Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 719
Pistacchio Avatar asked Mar 21 '26 09:03

Pistacchio


1 Answers

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.

like image 129
stephen mallette Avatar answered Mar 25 '26 00:03

stephen mallette



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!