【问题标题】:How to disable connection pooling in Gremlin server如何在 Gremlin 服务器中禁用连接池
【发布时间】:2017-05-08 09:36:06
【问题描述】:

我正在使用带有 hbase 作为 storage.bakend 的 gremlin 服务器。

当我尝试从我的 spark 代码连接到 gremlin 服务器时,会记录以下消息,并在一段时间后超时。

Host{address = 'ip:8182' ,, hostUri=ws:/ip:8182/gremlin} 上打开连接池,核心大小为 2

以下代码用于获取每个分区的客户端实例:

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;
}

【问题讨论】:

    标签: java apache-spark gremlin gremlin-server


    【解决方案1】:

    您可以将连接池的最小和最大大小设置为 1:

    Cluster cluster = Cluster.build().maxConnectionPoolSize(1)
                                      minConnectionPoolSize(1).create();
    

    这应该强制客户端使用单个连接。

    【讨论】:

    • 现在我得到了,在 Host{address = 'ip:8182' 上打开连接池,hostUri=ws:/ip:8182/gremlin} 核心大小为 1 并在一段时间后再次打开超时
    • 您的问题是关于如何禁用池。使用我提供的设置,您现在拥有一个实际上没有池的连接。为什么您的连接超时是另一回事。也许你只需要增加一些here描述的超时相关设置。
    猜你喜欢
    • 1970-01-01
    • 2016-02-19
    • 2015-12-26
    • 1970-01-01
    • 2016-10-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多