我正在使用带有 hbase 作为 storage.bakend 的 gremlin 服务器。
当我尝试从我的 spark 代码连接到 gremlin 服务器时,下面的消息被记录下来,并在一段时间后超时。
在核心大小为 2 的 Host{address = 'ip:8182' ,, hostUri=ws:/ip:8182/gremlin}
上打开连接池
以下代码用于获取每个分区的客户端实例:
private static Cluster cluster;
private static Client client;
Logger logger = LoggerFactory.getLogger(GremlinSeverConnection.class);
public Client getGraph(GraphConf conf) {
if (client == null) {
try {
// cluster = Cluster.build(new File(conf)).create();
cluster = Cluster.build(conf.getGraphHost()).port(Integer.parseInt(conf.getGraphPort()))
.serializer(getserializer(conf.getGraphSerializer())).create();
client = cluster.connect();
logger.info("connected to graph database");
} finally {
//cluster.close();
//client.close();
}
}
return client;
}
public Serializers getserializer(String serializer) {
return Serializers.GRAPHSON;
}
最佳答案
您可以将连接池的最小和最大大小设置为 1:
Cluster cluster = Cluster.build().maxConnectionPoolSize(1)
minConnectionPoolSize(1).create();
这应该强制客户端使用单个连接。
关于java - 如何在 Gremlin 服务器中禁用连接池,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43844309/