How to verify a remote graph connection?

574 views
Skip to first unread message

Philip Graff

unread,
Jul 3, 2019, 5:32:04 PM7/3/19
to Gremlin-users
Hello all,

Is there a way I can test a remote graph connection to see if it actually connects to a valid gremlin server? I have tried just calling g.V().hasNext() and catching the Exception, but then my code keeps logging this warning without end:

2019-07-03 17:29:05,297  WARN [gremlin-driver-worker-4] (Host.java:74) - Marking Host{address=localhost/127.0.0.1:1234, hostUri=ws://localhost:1234/gremlin} as unavailable. Trying to reconnect.

 2019-07-03 17:29:05,297  WARN [gremlin-driver-worker-11] (Host.java:74) - Marking Host{address=localhost/127.0.0.1:1234, hostUri=ws://localhost:1234/gremlin} as unavailable. Trying to reconnect.

 2019-07-03 17:29:08,299  WARN [gremlin-driver-worker-2] (Host.java:74) - Marking Host{address=localhost/127.0.0.1:1234, hostUri=ws://localhost:1234/gremlin} as unavailable. Trying to reconnect.

 2019-07-03 17:29:08,300  WARN [gremlin-driver-worker-20] (Host.java:74) - Marking Host{address=localhost/127.0.0.1:1234, hostUri=ws://localhost:1234/gremlin} as unavailable. Trying to reconnect.

 2019-07-03 17:29:08,300  WARN [gremlin-driver-worker-19] (Host.java:74) - Marking Host{address=localhost/127.0.0.1:1234, hostUri=ws://localhost:1234/gremlin} as unavailable. Trying to reconnect.


Is there a better way or some way to get this to stop?

Thanks,
Phil

Stephen Mallette

unread,
Jul 4, 2019, 7:46:12 AM7/4/19
to gremli...@googlegroups.com
Interesting that this issue hasn't come up before. I can't think of a way to check for that. The driver is a bit optimistic in it's work, figuring it will eventually get a connection so it doesn't provide a clear API for doing that. I did an experiment though and I think that you can get what you want from the Cluster object itself:

gremlin> cluster = Cluster.open()   
==>localhost/127.0.0.1:8182
gremlin> cluster.availableHosts()   // connections don't get created just because you created a Cluster
gremlin> client = cluster.connect()       
==>org.apache.tinkerpop.gremlin.driver.Client$ClusteredClient@7d0614f
gremlin> cluster.availableHosts()   // connections don't get created just because you created a Client
gremlin> client.init()              // connections get initialized by sending a request or calling init()
==>org.apache.tinkerpop.gremlin.driver.Client$ClusteredClient@7d0614f
gremlin> cluster.availableHosts()   
==>ws://localhost:8182/gremlin


availableHosts() will continue to return a non-empty list of hosts it thinks are available, but it really doesn't know for sure unfortunately until it perceives a problem. I was a bit surprised by the behavior in some of the more advanced tests I did, like thinking keep-alive would properly mark the host as dead and that an orderly server shutdown would result in the client being made aware of the host disappearance. Anyway, availableHosts() is the best we have at the moment for detecting situations where the driver simply can't send a request anywhere, but it's not perfect. I've created this issue for further discussion:


If you happen to test availableHosts() at all and find other inconsistencies please feel free to comment on the issue.



--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/fa5becd5-1730-4498-b2c7-3cb5c7cb6242%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages