【发布时间】:2021-05-18 12:43:07
【问题描述】:
我正在使用 Gremlin Java 驱动程序连接到本地 gremlin 服务器。
简单的代码流程
创建客户端
Cluster cluster = Cluster.build().addContactPoint(<endp>).port(<port>).enableSsl(false).create()
Client client = cluster.connect();
提交脚本
client.submit("g.V().count()");
如果我第一次提交时 Gremlin 服务器已关闭,在恢复 gremlin 服务器后的后续重试时,仍然无法创建连接。
Gremlin 服务器关闭时的第一次尝试:
org.apache.tinkerpop.gremlin.driver.exception.NoHostAvailableException: All hosts are considered unavailable due to previous exceptions. Check the error log to find the actual reason
Gremlin 服务器恢复后异常:
tinkerpop.gremlin.driver.exception.NoHostAvailableException: All hosts are considered unavailable due to previous exceptions
需要注意的一点是,我不会在重试时创建客户端,只是这样做 提交脚本
client.submit("g.V().count()");
Gremlin 服务器很有可能随时宕机,在这种情况下如何恢复。基本上是
NoHostAvailableExceptio
可以恢复吗?
【问题讨论】:
-
事实证明,如果我在重试中创建一个客户端它可以工作,但不确定最佳实践是什么