Search in sources :

Example 1 with HostDistance

use of com.datastax.driver.core.HostDistance in project cassandra by apache.

the class CqlConfigHelper method getReadPoolingOptions.

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;
}
Also used : HostDistance(com.datastax.driver.core.HostDistance) PoolingOptions(com.datastax.driver.core.PoolingOptions)

Aggregations

HostDistance (com.datastax.driver.core.HostDistance)1 PoolingOptions (com.datastax.driver.core.PoolingOptions)1