.withPoolingOptions(new PoolingOptions().setConnectionsPerHost(HostDistance.LOCAL, m_clusterConfiguration.getConnectionsLocalCore(), m_clusterConfiguration.getConnectionsLocalMax()) .setConnectionsPerHost(HostDistance.REMOTE, m_clusterConfiguration.getConnectionsRemoteCore(), m_clusterConfiguration.getConnectionsRemoteMax()) .setMaxRequestsPerConnection(HostDistance.LOCAL, m_clusterConfiguration.getRequestsPerConnectionLocal())
@Test(groups = "unit") public void should_set_core_and_max_connections_simultaneously() { PoolingOptions options = new PoolingOptions(); options.setProtocolVersion(ProtocolVersion.V2); options.setConnectionsPerHost(LOCAL, 10, 15); assertThat(options.getCoreConnectionsPerHost(LOCAL)).isEqualTo(10); assertThat(options.getMaxConnectionsPerHost(LOCAL)).isEqualTo(15); }
.withPoolingOptions( new PoolingOptions() .setConnectionsPerHost( HostDistance.LOCAL, coreConnections, coreConnections)) .withNettyOptions(nettyOptions)
createClusterBuilder() .withPoolingOptions( new PoolingOptions().setConnectionsPerHost(HostDistance.LOCAL, 1, 1)) .withReconnectionPolicy(new ConstantReconnectionPolicy(100)) .withThreadingOptions(spy)
options.setConnectionsPerHost(LOCAL, -1, 1); fail("expected an IllegalArgumentException"); } catch (IllegalArgumentException e) { options.setConnectionsPerHost(LOCAL, -2, -1); fail("expected an IllegalArgumentException"); } catch (IllegalArgumentException e) {
new PoolingOptions() .setHeartbeatIntervalSeconds(3) .setConnectionsPerHost(HostDistance.LOCAL, 1, 1)) .build();
@Override public Cluster.Builder createClusterBuilder() { channelMonitor = register(new SocketChannelMonitor()); PoolingOptions poolingOptions = new PoolingOptions().setConnectionsPerHost(HostDistance.LOCAL, 8, 8); return Cluster.builder() .withPoolingOptions(poolingOptions) .withNettyOptions(channelMonitor.nettyOptions()) .withReconnectionPolicy(new ConstantReconnectionPolicy(1000)); }
private void createCluster(int core, int max) { PoolingOptions poolingOptions = new PoolingOptions().setConnectionsPerHost(LOCAL, core, max); SocketOptions socketOptions = new SocketOptions().setReadTimeoutMillis(1000); cluster = Cluster.builder() .addContactPoints(scassandra.address(1).getAddress()) .withPort(scassandra.getBinaryPort()) .withQueryOptions(nonDebouncingQueryOptions()) .withPoolingOptions(poolingOptions) .withSocketOptions(socketOptions) .withReconnectionPolicy(new ConstantReconnectionPolicy(1000)) .build(); cluster.connect(); }
PoolingOptions poolingOptions = new PoolingOptions().setConnectionsPerHost(LOCAL, 1, 1);
.setConnectionsPerHost(HostDistance.LOCAL, getConfiguration().getCoreConnectionsPerHostLocal(), getConfiguration().getMaxConnectionsPerHostLocal()) .setConnectionsPerHost(HostDistance.REMOTE, getConfiguration().getCoreConnectionsPerHostRemote(), getConfiguration().getMaxConnectionsPerHostRemote())
public CassandraController(JSONConfig config) { Cluster.Builder builder = Cluster.builder().withClusterName("FlareBot Nodes") .withCredentials(config.getString("cassandra.username").get(), config.getString("cassandra.password").get()) .withPoolingOptions(new PoolingOptions().setConnectionsPerHost(HostDistance.LOCAL, 2, 4).setConnectionsPerHost(HostDistance.REMOTE, 2, 4)); config.getArray("cassandra.nodes").ifPresent(array -> array.forEach(ip -> builder.addContactPoint(ip.getAsString()))); cluster = builder.build(); session = cluster.connect(); }
@Test(groups = "unit") public void should_set_core_and_max_connections_simultaneously() { PoolingOptions options = new PoolingOptions(); options.setProtocolVersion(ProtocolVersion.V2); options.setConnectionsPerHost(LOCAL, 10, 15); assertThat(options.getCoreConnectionsPerHost(LOCAL)).isEqualTo(10); assertThat(options.getMaxConnectionsPerHost(LOCAL)).isEqualTo(15); }
private void init() { Cluster.Builder clusterBuilder = Cluster.builder(); clusterBuilder.addContactPoint(contactpoints).withPort(Integer.valueOf(port)); if (username != null && password != null) { clusterBuilder.withCredentials(username, password); } cluster = clusterBuilder.build(); PoolingOptions poolingOptions = cluster.getConfiguration().getPoolingOptions(); poolingOptions.setConnectionsPerHost(HostDistance.LOCAL, 5, 12) .setConnectionsPerHost(HostDistance.REMOTE, 2, 4); poolingOptions.setMaxRequestsPerConnection(HostDistance.LOCAL, 2048) .setMaxRequestsPerConnection(HostDistance.REMOTE, 512); session = cluster.connect(keyspace); mappingManager = new MappingManager(session, getProtocolVersion()); }
private void init() { Cluster.Builder clusterBuilder = Cluster.builder(); clusterBuilder.addContactPoint(contactpoints).withPort(Integer.valueOf(port)); if (username != null && password != null) { clusterBuilder.withCredentials(username, password); } cluster = clusterBuilder.build(); PoolingOptions poolingOptions = cluster.getConfiguration().getPoolingOptions(); poolingOptions.setConnectionsPerHost(HostDistance.LOCAL, 5, 12) .setConnectionsPerHost(HostDistance.REMOTE, 2, 4); poolingOptions.setMaxRequestsPerConnection(HostDistance.LOCAL, 2048) .setMaxRequestsPerConnection(HostDistance.REMOTE, 512); session = cluster.connect(keyspace); mappingManager = new MappingManager(session, getProtocolVersion()); }
public void init() { LOG.info("Starting Cassandra connector initialization."); Cluster.Builder builder = Cluster.builder() .addContactPoints(hosts) .withReconnectionPolicy(new ConstantReconnectionPolicy(reconnectionDelayMs)) .withRetryPolicy(DefaultRetryPolicy.INSTANCE) .withCompression(ProtocolOptions.Compression.LZ4) .withSocketOptions(new SocketOptions() .setReceiveBufferSize(receiverBufferSize) .setSendBufferSize(senderBufferSize)) .withPort(port); if (poolingOptions != null) { int procs = Runtime.getRuntime().availableProcessors(); poolingOptions .setConnectionsPerHost(HostDistance.LOCAL, procs, procs * 2) .setConnectionsPerHost(HostDistance.REMOTE, (procs / 2), procs * 2) .setPoolTimeoutMillis(poolTimeoutMillis) .setMaxRequestsPerConnection(HostDistance.LOCAL, maxRequestsPerConnection) .setMaxRequestsPerConnection(HostDistance.REMOTE, maxRequestsPerConnection); builder.withPoolingOptions(poolingOptions); } if (!Strings.isNullOrEmpty(username)) { builder.withCredentials(username, password); } cluster = builder.build(); session = cluster.connect(keyspace); }
@Override public Cluster registerCluster(String clName, String contactPoint, int connections, int port, String username, String password) { PoolingOptions poolingOpts = new PoolingOptions() .setConnectionsPerHost(HostDistance.LOCAL, connections, connections) .setMaxRequestsPerConnection(HostDistance.LOCAL, 32768); Cluster.Builder clusterBuilder = Cluster.builder() .withClusterName(clName) .addContactPoint(contactPoint) .withPoolingOptions(poolingOpts) .withPort(port) .withLoadBalancingPolicy( new TokenAwarePolicy( new RoundRobinPolicy() ) ); if ((username != null) && (password != null)) { clusterBuilder = clusterBuilder.withCredentials(username, password); } cluster = clusterBuilder.build(); return cluster; }
@Override public Cluster registerCluster(String clName, String contactPoint, int connections, int port, String username, String password) { PoolingOptions poolingOpts = new PoolingOptions() .setConnectionsPerHost(HostDistance.LOCAL, connections, connections) .setMaxRequestsPerConnection(HostDistance.LOCAL, 32768); Cluster.Builder clusterBuilder = Cluster.builder() .withClusterName(clName) .addContactPoint(contactPoint) .withPoolingOptions(poolingOpts) .withPort(port) .withLoadBalancingPolicy( new TokenAwarePolicy( new RoundRobinPolicy() ) ); if ((username != null) && (password != null)) { clusterBuilder = clusterBuilder.withCredentials(username, password); } cluster = clusterBuilder.build(); return cluster; }
options.setConnectionsPerHost(LOCAL, -1, 1); fail("expected an IllegalArgumentException"); } catch (IllegalArgumentException e) { options.setConnectionsPerHost(LOCAL, -2, -1); fail("expected an IllegalArgumentException"); } catch (IllegalArgumentException e) {
@Override public Cluster.Builder createClusterBuilder() { channelMonitor = register(new SocketChannelMonitor()); PoolingOptions poolingOptions = new PoolingOptions().setConnectionsPerHost(HostDistance.LOCAL, 8, 8); return Cluster.builder() .withPoolingOptions(poolingOptions) .withNettyOptions(channelMonitor.nettyOptions()) .withReconnectionPolicy(new ConstantReconnectionPolicy(1000)); }
private void createCluster(int core, int max) { PoolingOptions poolingOptions = new PoolingOptions().setConnectionsPerHost(LOCAL, core, max); SocketOptions socketOptions = new SocketOptions().setReadTimeoutMillis(1000); cluster = Cluster.builder() .addContactPoints(scassandra.address(1).getAddress()) .withPort(scassandra.getBinaryPort()) .withQueryOptions(nonDebouncingQueryOptions()) .withPoolingOptions(poolingOptions) .withSocketOptions(socketOptions) .withReconnectionPolicy(new ConstantReconnectionPolicy(1000)) .build(); cluster.connect(); }