默认Pelops will have 20 connections per node
-
我正在考虑将其修改为大约 40 connections per node
。那么我怎样才能在 Pelops 中做到这一点呢?目前,我正在创建这样的池-
private void createPool() {
Pelops.addPool(getPoolName(), getCluster(), getKeyspace());
}
/**
* Gets the cluster information
*
* @return
*/
private Cluster getCluster() {
Config casconf = new Config(ModelConstants.CASSANDRA_PORT, true, 0);
Cluster cluster= new Cluster(nodes, casconf, ModelConstants.NODE_DISCOVERY);
return cluster;
}
/**
* Get the keyspace name
*
* @return
*/
public String getKeyspace() {
return keyspace;
}
/**
* Get the pool name
*
* @return
*/
public String getPoolName() {
return poolName;
}
任何人都可以提供一个示例,以便我可以修改它以保持每个节点 40 个连接吗?感谢您的帮助。
更新的代码:-
CommonsBackedPool.Policy pt = new Policy();
pt.setMaxActivePerNode(40);
OperandPolicy op = new OperandPolicy();
Pelops.addPool(getPoolName(), getCluster(), getKeyspace(), pt, op);
我不确定我上面的做法是否正确?让我知道它是否正确。
最佳答案
查看JavaDocs for Pelops您可以使用其他 Pelops.addPool()
方法来提供 CommonsBackedPool.Policy 的实例这就是控制它的因素。
关于java - 如何使用 Pelops 客户端让每个节点与 Cassandra 数据库有 40 个连接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16347867/