gremlin> :> graph.addVertex("name", "stephen")
==>v[256]
gremlin> :> g.V().values('name')
==>stephen2
==>stephen28
==>stephen
==>stephen
Now, I am trying to execute the same query using the gremlin-driver for java from my local m/c. For this, I referred your code on Github (where you create a graph using groovy and then query it) and only used the code to create the web-socket connection and submitting a task. The Code is as follows:
----------------------------------
import org.apache.tinkerpop.gremlin.driver.Client;
import org.apache.tinkerpop.gremlin.driver.Cluster;
import org.apache.tinkerpop.gremlin.driver.ResultSet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static java.util.stream.Collectors.toList;
public class TitanConnector {
private static final Logger logger = LoggerFactory.getLogger(TitanConnector.class);
public static void main(String[] args) {
Cluster cluster;
Client client;
try {
cluster = Cluster.build(new File("conf/driver-settings.yaml")).channelizer("WebSocketChannelizer").create();
client = cluster.connect();
// System.out.println("Connected"+client.getSettings().toString());
logger.info("Connected"+client.getSettings().toString());
ResultSet results = client.submit("g.V().values('name')");
logger.info("Connected"+client.getSettings().toString());
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
----------------------------------
And the contents of the driver-settings.yaml file are as follows:
----------------------------------
hosts: [public ip of the vm]
port: 8182
serializer: { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { serializeResultToString: true }}
----------------------------------
When I run this code I get the following exception while submitting the query on this line client.submit("g.V().values('name')");
java.lang.RuntimeException: java.util.concurrent.TimeoutException: Timed out while waiting for an available host - check the client configuration and connectivity to the server if this message persists
The yaml file used by the running Gremlin server, conf/gremlin-server/gremlin-server.yaml has all the default settings I haven't changed them.
Is there anything I am missing in the client configuration (change the serializer) in the java code? or which server configuration should I change (increase the timeout value) to get the response from Gremlin?
Regards,
Ambarish