2017-05-08 110 views
1

我正在使用带有hbase作为storage.bakend的gremlin服务器。如何在Gremlin服务器中禁用连接池

当我尝试从我的spark代码连接到gremlin服务器时,下面的消息被记录下来,并在某段时间后超时。在主机{ ':8182 IP' ,, 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; 
} 

回答

2

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

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

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

+0

现在我正在打开连接池上的主机{地址='ip:8182',hostUri = ws:/ ip:8182/gremlin}核心大小为1,并在一段时间后超时 –

+1

您的问题是关于如何禁用池。与我提供的设置你现在有一个单一的连接,实际上是没有游泳池。为什么你的连接超时是一个不同的故事。也许你只需要增加[这里]描述的一些超时相关设置(http://tinkerpop.apache.org/docs/current/reference/#_configuration)。 –