if (coreConnections != null) { cluster.getConfiguration().getPoolingOptions() .setCoreConnectionsPerHost(HostDistance.LOCAL, Integer.valueOf(coreConnections));
.setCoreConnectionsPerHost(HostDistance.LOCAL, cassandraConfig.getConnections()) .setMaxConnectionsPerHost(HostDistance.LOCAL, cassandraConfig.getConnections()) .setIdleTimeoutSeconds( cassandraConfig.getPoolTimeout() / 1000 )
if (!StringUtils.isBlank(coreConnections)) options.setCoreConnectionsPerHost(HostDistance.LOCAL, new Integer(coreConnections));
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); }
@Test(groups = "unit") public void should_enforce_invariants_once_protocol_version_known() { // OK for v2 (default max = 8) PoolingOptions options = new PoolingOptions().setCoreConnectionsPerHost(LOCAL, 3); options.setCoreConnectionsPerHost(LOCAL, 3); options.setProtocolVersion(ProtocolVersion.V2); assertThat(options.getCoreConnectionsPerHost(LOCAL)).isEqualTo(3); assertThat(options.getMaxConnectionsPerHost(LOCAL)).isEqualTo(8); // KO for v3 (default max = 1) options = new PoolingOptions().setCoreConnectionsPerHost(LOCAL, 3); try { options.setProtocolVersion(ProtocolVersion.V3); fail("Expected an IllegalArgumentException"); } catch (IllegalArgumentException e) { /*expected*/ } // OK for v3 (up to 32K stream ids) options = new PoolingOptions().setMaxRequestsPerConnection(LOCAL, 5000); options.setProtocolVersion(ProtocolVersion.V3); assertThat(options.getMaxRequestsPerConnection(LOCAL)).isEqualTo(5000); // KO for v2 (up to 128) options = new PoolingOptions().setMaxRequestsPerConnection(LOCAL, 5000); try { options.setProtocolVersion(ProtocolVersion.V2); fail("Expected an IllegalArgumentException"); } catch (IllegalArgumentException e) { /*expected*/ } }
public JavaDriverConfigBuilder withCoreConnsPerHost(HostDistance distance, int coreConnections) { this.poolingOptions.setCoreConnectionsPerHost(distance, coreConnections); 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)); }
.withPort(ccm().getBinaryPort()) .withPoolingOptions( new PoolingOptions().setCoreConnectionsPerHost(HostDistance.LOCAL, 1)) .withNettyOptions(channelMonitor.nettyOptions()) .build();
void setCoreConnectionsPerHost(PoolingOptions poolingOptions) { if (coreConnectionsPerHost != null) { poolingOptions.setCoreConnectionsPerHost(getHostDistance(), coreConnectionsPerHost); } }
PoolingOptions setCoreConnectionsPerHost(PoolingOptions poolingOptions) { if (coreConnectionsPerHost != null) { poolingOptions.setCoreConnectionsPerHost(getHostDistance(), coreConnectionsPerHost); } return poolingOptions; }
CreateClusterAndCheckConnections(CountDownLatch startSignal) { this.startSignal = startSignal; this.cluster = Cluster.builder() .addContactPoints(getContactPoints()) .withPort(ccm().getBinaryPort()) .withPoolingOptions( new PoolingOptions().setCoreConnectionsPerHost(HostDistance.LOCAL, 1)) .withNettyOptions(channelMonitor.nettyOptions()) .build(); }
.withPoolingOptions( new PoolingOptions() .setCoreConnectionsPerHost(HostDistance.LOCAL, 1) .setMaxConnectionsPerHost(HostDistance.LOCAL, 1) .setHeartbeatIntervalSeconds(0))
.withPoolingOptions( new PoolingOptions() .setCoreConnectionsPerHost(HostDistance.LOCAL, 1) .setMaxConnectionsPerHost(HostDistance.LOCAL, 1)) .build();
options.setCoreConnectionsPerHost(LOCAL, -1); fail("expected an IllegalArgumentException"); } catch (IllegalArgumentException e) {
@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 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); }
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)); }
CreateClusterAndCheckConnections(CountDownLatch startSignal) { this.startSignal = startSignal; this.cluster = Cluster.builder() .addContactPoints(getContactPoints()) .withPort(ccm().getBinaryPort()) .withPoolingOptions( new PoolingOptions().setCoreConnectionsPerHost(HostDistance.LOCAL, 1)) .withNettyOptions(channelMonitor.nettyOptions()) .build(); }