本文整理汇总了Java中com.datastax.driver.core.PoolingOptions.setNewConnectionThreshold方法的典型用法代码示例。如果您正苦于以下问题:Java PoolingOptions.setNewConnectionThreshold方法的具体用法?Java PoolingOptions.setNewConnectionThreshold怎么用?Java PoolingOptions.setNewConnectionThreshold使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.datastax.driver.core.PoolingOptions
的用法示例。
在下文中一共展示了PoolingOptions.setNewConnectionThreshold方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getReadPoolingOptions
import com.datastax.driver.core.PoolingOptions; //导入方法依赖的package包/类
private static PoolingOptions getReadPoolingOptions(Configuration conf)
{
Optional<Integer> coreConnections = getInputCoreConnections(conf);
Optional<Integer> maxConnections = getInputMaxConnections(conf);
Optional<Integer> maxSimultaneousRequests = getInputMaxSimultReqPerConnections(conf);
PoolingOptions poolingOptions = new PoolingOptions();
for (HostDistance hostDistance : Arrays.asList(HostDistance.LOCAL, HostDistance.REMOTE))
{
if (coreConnections.isPresent())
poolingOptions.setCoreConnectionsPerHost(hostDistance, coreConnections.get());
if (maxConnections.isPresent())
poolingOptions.setMaxConnectionsPerHost(hostDistance, maxConnections.get());
if (maxSimultaneousRequests.isPresent())
poolingOptions.setNewConnectionThreshold(hostDistance, maxSimultaneousRequests.get());
}
return poolingOptions;
}
示例2: setPoolingOptions
import com.datastax.driver.core.PoolingOptions; //导入方法依赖的package包/类
private void setPoolingOptions(PoolingOptions poolingOptions, HostDistance hostDistance, HostDistanceOptions options) {
if (options.getCoreConnections() != null) {
poolingOptions.setCoreConnectionsPerHost(hostDistance, options.getCoreConnections());
}
if (options.getMaxConnections() != null) {
poolingOptions.setMaxConnectionsPerHost(hostDistance, options.getMaxConnections());
}
if (options.getMaxRequestsPerConnection() != null) {
poolingOptions.setMaxRequestsPerConnection(hostDistance, options.getMaxRequestsPerConnection());
}
if (options.getNewConnectionThreshold() != null) {
poolingOptions.setNewConnectionThreshold(hostDistance, options.getNewConnectionThreshold());
}
}
示例3: populatePoolingSettings
import com.datastax.driver.core.PoolingOptions; //导入方法依赖的package包/类
private Cluster.Builder populatePoolingSettings(Properties properties, Cluster.Builder builder) {
String localCoreConnectionsPerHost = properties.getProperty(CassandraStoreParameters.LOCAL_CORE_CONNECTIONS_PER_HOST);
String remoteCoreConnectionsPerHost = properties.getProperty(CassandraStoreParameters.REMOTE_CORE_CONNECTIONS_PER_HOST);
String localMaxConnectionsPerHost = properties.getProperty(CassandraStoreParameters.LOCAL_MAX_CONNECTIONS_PER_HOST);
String remoteMaxConnectionsPerHost = properties.getProperty(CassandraStoreParameters.REMOTE_MAX_CONNECTIONS_PER_HOST);
String localNewConnectionThreshold = properties.getProperty(CassandraStoreParameters.LOCAL_NEW_CONNECTION_THRESHOLD);
String remoteNewConnectionThreshold = properties.getProperty(CassandraStoreParameters.REMOTE_NEW_CONNECTION_THRESHOLD);
String localMaxRequestsPerConnection = properties.getProperty(CassandraStoreParameters.LOCAL_MAX_REQUESTS_PER_CONNECTION);
String remoteMaxRequestsPerConnection = properties.getProperty(CassandraStoreParameters.REMOTE_MAX_REQUESTS_PER_CONNECTION);
PoolingOptions options = new PoolingOptions();
if (localCoreConnectionsPerHost != null) {
options.setCoreConnectionsPerHost(HostDistance.LOCAL, Integer.parseInt(localCoreConnectionsPerHost));
}
if (remoteCoreConnectionsPerHost != null) {
options.setCoreConnectionsPerHost(HostDistance.REMOTE, Integer.parseInt(remoteCoreConnectionsPerHost));
}
if (localMaxConnectionsPerHost != null) {
options.setMaxConnectionsPerHost(HostDistance.LOCAL, Integer.parseInt(localMaxConnectionsPerHost));
}
if (remoteMaxConnectionsPerHost != null) {
options.setMaxConnectionsPerHost(HostDistance.REMOTE, Integer.parseInt(remoteMaxConnectionsPerHost));
}
if (localNewConnectionThreshold != null) {
options.setNewConnectionThreshold(HostDistance.LOCAL, Integer.parseInt(localNewConnectionThreshold));
}
if (remoteNewConnectionThreshold != null) {
options.setNewConnectionThreshold(HostDistance.REMOTE, Integer.parseInt(remoteNewConnectionThreshold));
}
if (localMaxRequestsPerConnection != null) {
options.setMaxRequestsPerConnection(HostDistance.LOCAL, Integer.parseInt(localMaxRequestsPerConnection));
}
if (remoteMaxRequestsPerConnection != null) {
options.setMaxRequestsPerConnection(HostDistance.REMOTE, Integer.parseInt(remoteMaxRequestsPerConnection));
}
builder = builder.withPoolingOptions(options);
return builder;
}
示例4: populatePoolingSettings
import com.datastax.driver.core.PoolingOptions; //导入方法依赖的package包/类
private Builder populatePoolingSettings(Map<String, String> properties, Builder builder) {
String localCoreConnectionsPerHost = properties.get(DBConstants.Cassandra.LOCAL_CORE_CONNECTIONS_PER_HOST);
String remoteCoreConnectionsPerHost = properties.get(DBConstants.Cassandra.REMOTE_CORE_CONNECTIONS_PER_HOST);
String localMaxConnectionsPerHost = properties.get(DBConstants.Cassandra.LOCAL_MAX_CONNECTIONS_PER_HOST);
String remoteMaxConnectionsPerHost = properties.get(DBConstants.Cassandra.REMOTE_MAX_CONNECTIONS_PER_HOST);
String localNewConnectionThreshold = properties.get(DBConstants.Cassandra.LOCAL_NEW_CONNECTION_THRESHOLD);
String remoteNewConnectionThreshold = properties.get(DBConstants.Cassandra.REMOTE_NEW_CONNECTION_THRESHOLD);
String localMaxRequestsPerConnection = properties.get(DBConstants.Cassandra.LOCAL_MAX_REQUESTS_PER_CONNECTION);
String remoteMaxRequestsPerConnection = properties.get(DBConstants.Cassandra.REMOTE_MAX_REQUESTS_PER_CONNECTION);
PoolingOptions options = new PoolingOptions();
if (localCoreConnectionsPerHost != null) {
options.setCoreConnectionsPerHost(HostDistance.LOCAL, Integer.parseInt(localCoreConnectionsPerHost));
}
if (remoteCoreConnectionsPerHost != null) {
options.setCoreConnectionsPerHost(HostDistance.REMOTE, Integer.parseInt(remoteCoreConnectionsPerHost));
}
if (localMaxConnectionsPerHost != null) {
options.setMaxConnectionsPerHost(HostDistance.LOCAL, Integer.parseInt(localMaxConnectionsPerHost));
}
if (remoteMaxConnectionsPerHost != null) {
options.setMaxConnectionsPerHost(HostDistance.REMOTE, Integer.parseInt(remoteMaxConnectionsPerHost));
}
if (localNewConnectionThreshold != null) {
options.setNewConnectionThreshold(HostDistance.LOCAL, Integer.parseInt(localNewConnectionThreshold));
}
if (remoteNewConnectionThreshold != null) {
options.setNewConnectionThreshold(HostDistance.REMOTE, Integer.parseInt(remoteNewConnectionThreshold));
}
if (localMaxRequestsPerConnection != null) {
options.setMaxRequestsPerConnection(HostDistance.LOCAL, Integer.parseInt(localMaxRequestsPerConnection));
}
if (remoteMaxRequestsPerConnection != null) {
options.setMaxRequestsPerConnection(HostDistance.REMOTE, Integer.parseInt(remoteMaxRequestsPerConnection));
}
builder = builder.withPoolingOptions(options);
return builder;
}