if (maxConnections != null) { cluster.getConfiguration().getPoolingOptions() .setMaxConnectionsPerHost(HostDistance.LOCAL, Integer.valueOf(maxConnections));
.setMaxConnectionsPerHost(HostDistance.LOCAL, cassandraConfig.getConnections()) .setIdleTimeoutSeconds( cassandraConfig.getPoolTimeout() / 1000 ) .setPoolTimeoutMillis( cassandraConfig.getPoolTimeout());
options.setMaxConnectionsPerHost(hostDist, new Integer(maxConnectionsPerHost));
private void copyPoolingOptions(Builder builder) { PoolingOptions opts = new PoolingOptions(); opts.setCoreConnectionsPerHost(HostDistance.REMOTE, remoteCoreConnectionsPerHost); opts.setCoreConnectionsPerHost(HostDistance.LOCAL, localCoreConnectionsPerHost); opts.setMaxConnectionsPerHost(HostDistance.REMOTE, remoteMaxConnectionsPerHost); opts.setMaxConnectionsPerHost(HostDistance.LOCAL, localMaxConnectionsPerHost); opts.setMaxSimultaneousRequestsPerConnectionThreshold( HostDistance.REMOTE, remoteMaxSimultaneousRequestsPerConnectionThreshold); opts.setMaxSimultaneousRequestsPerConnectionThreshold( HostDistance.LOCAL, localMaxSimultaneousRequestsPerConnectionThreshold); opts.setMinSimultaneousRequestsPerConnectionThreshold( HostDistance.REMOTE, remoteMinSimultaneousRequestsPerConnectionThreshold); opts.setMinSimultaneousRequestsPerConnectionThreshold( HostDistance.LOCAL, localMinSimultaneousRequestsPerConnectionThreshold); builder.withPoolingOptions(opts); }
public JavaDriverConfigBuilder withMaxConnsPerHost(HostDistance distance, int maxConnections) { this.poolingOptions.setMaxConnectionsPerHost(distance, maxConnections); return this; }
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); }
protected Cluster.Builder createClusterBuilder() { return Cluster.builder() .withPort(scassandra.getBinaryPort()) .addContactPoints(hostAddress.getAddress()) .withPort(scassandra.getBinaryPort()) .withPoolingOptions( new PoolingOptions() .setCoreConnectionsPerHost(HostDistance.LOCAL, 1) .setMaxConnectionsPerHost(HostDistance.LOCAL, 1) .setHeartbeatIntervalSeconds(0)); }
void setMaxConnectionsPerHost(PoolingOptions poolingOptions) { if (maxConnectionsPerHost != null) { poolingOptions.setMaxConnectionsPerHost(getHostDistance(), maxConnectionsPerHost); } }
/** Max pooled connections per datacenter-local host. Defaults to 8 */ public final Builder maxConnections(int maxConnections) { poolingOptions().setMaxConnectionsPerHost(HostDistance.LOCAL, maxConnections); return this; }
PoolingOptions setMaxConnectionsPerHost(PoolingOptions poolingOptions) { if (maxConnectionsPerHost != null) { poolingOptions.setMaxConnectionsPerHost(getHostDistance(), maxConnectionsPerHost); } return poolingOptions; }
new PoolingOptions() .setCoreConnectionsPerHost(HostDistance.LOCAL, 1) .setMaxConnectionsPerHost(HostDistance.LOCAL, 1) .setHeartbeatIntervalSeconds(0)) .build();
new PoolingOptions() .setCoreConnectionsPerHost(HostDistance.LOCAL, 1) .setMaxConnectionsPerHost(HostDistance.LOCAL, 1)) .build();
options.setMaxConnectionsPerHost(LOCAL, -1); fail("expected an IllegalArgumentException"); } catch (IllegalArgumentException e) {
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; }
@BeforeMethod(groups = "short") public void beforeMethod() { scassandras = ScassandraCluster.builder().withNodes(3).build(); scassandras.init(); cluster = Cluster.builder() .addContactPoints(scassandras.address(1).getAddress()) .withPort(scassandras.getBinaryPort()) .withRetryPolicy(retryPolicy) .withLoadBalancingPolicy(new SortingLoadBalancingPolicy()) .withPoolingOptions( new PoolingOptions() .setCoreConnectionsPerHost(HostDistance.LOCAL, 1) .setMaxConnectionsPerHost(HostDistance.LOCAL, 1) .setHeartbeatIntervalSeconds(0)) .withNettyOptions(nonQuietClusterCloseOptions) // Mark everything as idempotent by default so RetryPolicy is exercised. .withQueryOptions(new QueryOptions().setDefaultIdempotence(true)) .build(); session = cluster.connect(); host1 = TestUtils.findHost(cluster, 1); host2 = TestUtils.findHost(cluster, 2); host3 = TestUtils.findHost(cluster, 3); errors = cluster.getMetrics().getErrorMetrics(); Mockito.reset(retryPolicy); for (Scassandra node : scassandras.nodes()) { node.activityClient().clearAllRecordedActivity(); } }
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; }
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()); } }
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); }
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()); } }
protected Cluster.Builder createClusterBuilder() { return Cluster.builder() .withPort(scassandra.getBinaryPort()) .addContactPoints(hostAddress.getAddress()) .withPort(scassandra.getBinaryPort()) .withPoolingOptions( new PoolingOptions() .setCoreConnectionsPerHost(HostDistance.LOCAL, 1) .setMaxConnectionsPerHost(HostDistance.LOCAL, 1) .setHeartbeatIntervalSeconds(0)); }