The documentation I've found suggests to create an EmtpyGraph and get a remote traversal from that one:
EmptyGraph.instance().traversal().withRemote(config);
where config is your a configuration object with the remote properties, e.g:
config.setProperty("clusterConfiguration.hosts", HOST);
config.setProperty("clusterConfiguration.port", PORT);
config.setProperty("clusterConfiguration.serializer.className", "org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0");
config.setProperty("clusterConfiguration.serializer.config.ioRegistries", ioRegistries); // (e.g. [ org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry) ]
config.setProperty("gremlin.remote.remoteConnectionClass", "org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteConnection");
config.setProperty("gremlin.remote.driver.sourceName", "g");
However, I've run into issues using JanusGraph specific features (for example committing a transaction) with this since the graph instance is the EmptyGraph itself, not a JanusGraph. So, try:
GraphTraversalSource g = JanusGraphFactory.open("inmemory").traversal().withRemote(config);
This will give you a traversal source to the remote gremlin-server, and you can do things like g.addV("vertexLabel")....; , g.tx().commit(); and so on.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…