本文整理了Java中com.datastax.driver.core.Configuration.getPoolingOptions()
方法的一些代码示例,展示了Configuration.getPoolingOptions()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Configuration.getPoolingOptions()
方法的具体详情如下:
包路径:com.datastax.driver.core.Configuration
类名称:Configuration
方法名:getPoolingOptions
[英]Returns the connection pooling configuration.
[中]返回连接池配置。
代码示例来源:origin: apache/storm
public void prepare() {
LOG.info("Preparing state for {}", options.toString());
Preconditions.checkNotNull(options.getMapper, "CassandraBackingMap.Options should have getMapper");
Preconditions.checkNotNull(options.putMapper, "CassandraBackingMap.Options should have putMapper");
client = options.clientProvider.getClient(conf);
session = client.connect();
if (options.maxParallelism == null || options.maxParallelism <= 0) {
PoolingOptions po = session.getCluster().getConfiguration().getPoolingOptions();
Integer maxRequestsPerHost = Math.min(
po.getMaxConnectionsPerHost(HostDistance.LOCAL) * po.getMaxRequestsPerConnection(HostDistance.LOCAL),
po.getMaxConnectionsPerHost(HostDistance.REMOTE) * po.getMaxRequestsPerConnection(HostDistance.REMOTE)
);
options.maxParallelism = maxRequestsPerHost / 2;
LOG.info("Parallelism default set to {}", options.maxParallelism);
}
throttle = new Semaphore(options.maxParallelism, false);
this.getResultMapper = new TridentAyncCQLResultSetValuesMapper(options.stateMapper.getStateFields(), throttle);
this.putResultMapper = new TridentAyncCQLResultSetValuesMapper(null, throttle);
}
代码示例来源:origin: apache/usergrid
@Inject
public DataStaxClusterImpl(final CassandraConfig cassandraFig ) throws Exception {
this.cassandraConfig = cassandraFig;
this.cluster = getCluster();
logger.info("Initialized datastax cluster client. Hosts={}, Idle Timeout={}s, Pool Timeout={}s",
getCluster().getMetadata().getAllHosts().toString(),
getCluster().getConfiguration().getPoolingOptions().getIdleTimeoutSeconds(),
getCluster().getConfiguration().getPoolingOptions().getPoolTimeoutMillis() / 1000);
// always initialize the keyspaces
this.createApplicationKeyspace(false);
this.createApplicationLocalKeyspace(false);
}
代码示例来源:origin: brianfrankcooper/YCSB
MAX_CONNECTIONS_PROPERTY);
if (maxConnections != null) {
cluster.getConfiguration().getPoolingOptions()
.setMaxConnectionsPerHost(HostDistance.LOCAL,
Integer.valueOf(maxConnections));
CORE_CONNECTIONS_PROPERTY);
if (coreConnections != null) {
cluster.getConfiguration().getPoolingOptions()
.setCoreConnectionsPerHost(HostDistance.LOCAL,
Integer.valueOf(coreConnections));
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
private PoolingOptions options() {
return manager.configuration().getPoolingOptions();
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
if (isInitialized
&& !isClosed()
&& evt instanceof IdleStateEvent
&& ((IdleStateEvent) evt).state() == READER_IDLE) {
logger.debug(
"{} was inactive for {} seconds, sending heartbeat",
Connection.this,
factory.configuration.getPoolingOptions().getHeartbeatIntervalSeconds());
write(HEARTBEAT_CALLBACK);
}
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
public void changeTheHost(Host theNewHost) {
this.theHost = theNewHost;
cluster.getConfiguration().getPoolingOptions().refreshConnectedHosts();
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
public static int numberOfLocalCoreConnections(Cluster cluster) {
Configuration configuration = cluster.getConfiguration();
return configuration.getPoolingOptions().getCoreConnectionsPerHost(HostDistance.LOCAL);
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
private void updateChosenHosts() {
if (chosenHosts.size() > maxHosts - threshold || liveHosts.size() == 0) return;
// We lock to prevent two events from triggering this simultaneously.
updateLock.lock();
try {
int missing = maxHosts - chosenHosts.size();
if (missing < threshold || liveHosts.size() == 0) return;
Set<Host> newlyChosen = new HashSet<Host>();
for (Host host : liveHosts) {
// Note that this picks hosts whatever their distance is.
// We can't reliably call childPolicy.distance() here, because the childPolicy
// might require hosts to be already added to compute their distance properly
// (this is the case for DCAware policy).
newlyChosen.add(host);
missing -= 1;
if (missing == 0) break;
}
chosenHosts.addAll(newlyChosen);
liveHosts.removeAll(newlyChosen);
for (Host host : newlyChosen) {
delegate.onAdd(host);
// delegate should have updated the distance, inform the driver so that it can
// recreate the pool.
cluster.getConfiguration().getPoolingOptions().refreshConnectedHost(host);
}
} finally {
updateLock.unlock();
}
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
scheduleExecution(speculativeExecutionPlan.nextExecution(host));
PoolingOptions poolingOptions = manager.configuration().getPoolingOptions();
ListenableFuture<Connection> connectionFuture =
pool.borrowConnection(
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
factory.manager.configuration.getPoolingOptions().getInitializationExecutor());
代码示例来源:origin: Impetus/Kundera
Assert.assertEquals(configuration.getSocketOptions().getTcpNoDelay().booleanValue(), true);
Assert.assertEquals(configuration.getPoolingOptions().getCoreConnectionsPerHost(distance), 5);
Assert.assertEquals(configuration.getPoolingOptions().getMaxConnectionsPerHost(distance), 12);
Assert.assertEquals(configuration.getPoolingOptions()
.getMaxRequestsPerConnection(distance), 128);
Assert.assertEquals(configuration.getPolicies().getLoadBalancingPolicy().getClass().getName(), TAP);
代码示例来源:origin: Impetus/Kundera
Assert.assertEquals(configuration.getSocketOptions().getTcpNoDelay().booleanValue(), true);
Assert.assertEquals(configuration.getPoolingOptions().getCoreConnectionsPerHost(distance), 5);
Assert.assertEquals(configuration.getPoolingOptions().getMaxConnectionsPerHost(distance), 12);
Assert.assertEquals(configuration.getPoolingOptions()
.getMaxRequestsPerConnection(distance), 128);
Assert.assertEquals(configuration.getPolicies().getLoadBalancingPolicy().getClass().getName(),
代码示例来源:origin: Impetus/Kundera
Assert.assertEquals(configuration.getSocketOptions().getTcpNoDelay().booleanValue(), true);
Assert.assertEquals(configuration.getPoolingOptions().getCoreConnectionsPerHost(distance), 5);
Assert.assertEquals(configuration.getPoolingOptions().getMaxConnectionsPerHost(distance), 12);
Assert.assertEquals(configuration.getPoolingOptions()
.getMaxRequestsPerConnection(distance), 128);
代码示例来源:origin: Impetus/Kundera
Assert.assertEquals(configuration.getSocketOptions().getTcpNoDelay().booleanValue(), true);
Assert.assertEquals(configuration.getPoolingOptions().getCoreConnectionsPerHost(distance), 5);
Assert.assertEquals(configuration.getPoolingOptions().getMaxConnectionsPerHost(distance), 12);
Assert.assertEquals(configuration.getPoolingOptions()
.getMaxRequestsPerConnection(distance), 128);
代码示例来源:origin: Impetus/Kundera
Assert.assertEquals(configuration.getSocketOptions().getTcpNoDelay().booleanValue(), true);
Assert.assertEquals(configuration.getPoolingOptions().getCoreConnectionsPerHost(distance), 5);
Assert.assertEquals(configuration.getPoolingOptions().getMaxConnectionsPerHost(distance), 12);
Assert.assertEquals(configuration.getPoolingOptions()
.getMaxRequestsPerConnection(distance), 128);
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
/**
* Copy constructor.
*
* @param toCopy the object to copy from.
*/
protected Configuration(Configuration toCopy) {
this(
toCopy.getPolicies(),
toCopy.getProtocolOptions(),
toCopy.getPoolingOptions(),
toCopy.getSocketOptions(),
toCopy.getMetricsOptions(),
toCopy.getQueryOptions(),
toCopy.getThreadingOptions(),
toCopy.getNettyOptions(),
toCopy.getCodecRegistry());
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
cluster()
.getConfiguration()
.getPoolingOptions()
.setMaxRequestsPerConnection(HostDistance.LOCAL, maxRequests);
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
private HostConnectionPool createPool(Cluster cluster, int coreConnections, int maxConnections) {
cluster
.getConfiguration()
.getPoolingOptions()
.setNewConnectionThreshold(HostDistance.LOCAL, 100)
.setMaxRequestsPerConnection(HostDistance.LOCAL, 128)
.setMaxConnectionsPerHost(HostDistance.LOCAL, maxConnections)
.setCoreConnectionsPerHost(HostDistance.LOCAL, coreConnections);
Session session = cluster.connect();
Host host = TestUtils.findHost(cluster, 1);
// Replace the existing pool with a spy pool and return it.
SessionManager sm = ((SessionManager) session);
return sm.pools.get(host);
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
.getPoolingOptions()
.setMaxRequestsPerConnection(HostDistance.LOCAL, 100);
int maxQueueSize = 256;
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
.build();
cluster.getConfiguration().getPoolingOptions().setPoolTimeoutMillis(500);
try {
Session session = cluster.connect();
内容来源于网络,如有侵权,请联系作者删除!