com.datastax.driver.core.PoolingOptions Java Examples
The following examples show how to use
com.datastax.driver.core.PoolingOptions.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TraceDaoIT.java From glowroot with Apache License 2.0 | 6 votes |
@BeforeClass public static void setUp() throws Exception { SharedSetupRunListener.startCassandra(); cluster = Clusters.newCluster(); session = new Session(cluster.newSession(), "glowroot_unit_tests", null, PoolingOptions.DEFAULT_MAX_QUEUE_SIZE); clusterManager = ClusterManager.create(); ConfigRepositoryImpl configRepository = mock(ConfigRepositoryImpl.class); when(configRepository.getCentralStorageConfig()) .thenReturn(ImmutableCentralStorageConfig.builder().build()); Clock clock = mock(Clock.class); when(clock.currentTimeMillis()).thenReturn(200L); traceDao = new TraceDaoWithV09Support(ImmutableSet.of(), 0, 0, clock, new TraceDaoImpl(session, mock(TransactionTypeDao.class), mock(FullQueryTextDao.class), mock(TraceAttributeNameDao.class), configRepository, clock)); }
Example #2
Source File: SyntheticResultDaoIT.java From glowroot with Apache License 2.0 | 6 votes |
@BeforeClass public static void setUp() throws Exception { SharedSetupRunListener.startCassandra(); clusterManager = ClusterManager.create(); cluster = Clusters.newCluster(); session = new Session(cluster.newSession(), "glowroot_unit_tests", null, PoolingOptions.DEFAULT_MAX_QUEUE_SIZE); asyncExecutor = Executors.newCachedThreadPool(); CentralConfigDao centralConfigDao = new CentralConfigDao(session, clusterManager); AgentDisplayDao agentDisplayDao = new AgentDisplayDao(session, clusterManager, asyncExecutor, 10); AgentConfigDao agentConfigDao = new AgentConfigDao(session, agentDisplayDao, clusterManager, 10); UserDao userDao = new UserDao(session, clusterManager); RoleDao roleDao = new RoleDao(session, clusterManager); ConfigRepositoryImpl configRepository = new ConfigRepositoryImpl(centralConfigDao, agentConfigDao, userDao, roleDao, ""); syntheticResultDao = new SyntheticResultDaoImpl(session, configRepository, asyncExecutor, Clock.systemClock()); }
Example #3
Source File: SchemaUpgradeIT.java From glowroot with Apache License 2.0 | 6 votes |
@BeforeClass public static void setUp() throws Exception { SharedSetupRunListener.startCassandra(); cluster = Clusters.newCluster(); com.datastax.driver.core.Session wrappedSession = cluster.newSession(); updateSchemaWithRetry(wrappedSession, "drop keyspace if exists glowroot_upgrade_test"); session = new Session(wrappedSession, "glowroot_upgrade_test", null, PoolingOptions.DEFAULT_MAX_QUEUE_SIZE); URL url = Resources.getResource("glowroot-0.9.1-schema.cql"); StringBuilder cql = new StringBuilder(); for (String line : Resources.readLines(url, UTF_8)) { if (line.isEmpty()) { session.updateSchemaWithRetry(cql.toString()); cql.setLength(0); } else { cql.append('\n'); cql.append(line); } } restore("glowroot_upgrade_test"); }
Example #4
Source File: PoolingOptionsFactoryTest.java From dropwizard-cassandra with Apache License 2.0 | 6 votes |
@Test public void buildsPoolingOptionsWithConfiguredValues() throws Exception { // given final PoolingOptionsFactory factory = new PoolingOptionsFactory(); factory.setHeartbeatInterval(Duration.minutes(1)); factory.setPoolTimeout(Duration.seconds(2)); factory.setLocal(createHostDistanceOptions(1, 3, 5, 25)); factory.setRemote(createHostDistanceOptions(2, 4, 6, 30)); // when final PoolingOptions poolingOptions = factory.build(); // then assertThat(poolingOptions.getHeartbeatIntervalSeconds()).isEqualTo(60); assertThat(poolingOptions.getPoolTimeoutMillis()).isEqualTo(2000); assertThat(poolingOptions.getCoreConnectionsPerHost(HostDistance.LOCAL)).isEqualTo(1); assertThat(poolingOptions.getMaxConnectionsPerHost(HostDistance.LOCAL)).isEqualTo(3); assertThat(poolingOptions.getMaxRequestsPerConnection(HostDistance.LOCAL)).isEqualTo(5); assertThat(poolingOptions.getNewConnectionThreshold(HostDistance.LOCAL)).isEqualTo(25); assertThat(poolingOptions.getCoreConnectionsPerHost(HostDistance.REMOTE)).isEqualTo(2); assertThat(poolingOptions.getMaxConnectionsPerHost(HostDistance.REMOTE)).isEqualTo(4); assertThat(poolingOptions.getMaxRequestsPerConnection(HostDistance.REMOTE)).isEqualTo(6); assertThat(poolingOptions.getNewConnectionThreshold(HostDistance.REMOTE)).isEqualTo(30); }
Example #5
Source File: PoolingOptionsFactory.java From dropwizard-cassandra with Apache License 2.0 | 6 votes |
public PoolingOptions build() { PoolingOptions poolingOptions = new PoolingOptions(); if (local != null) { setPoolingOptions(poolingOptions, HostDistance.LOCAL, local); } if (remote != null) { setPoolingOptions(poolingOptions, HostDistance.REMOTE, remote); } if (heartbeatInterval != null) { poolingOptions.setHeartbeatIntervalSeconds((int) heartbeatInterval.toSeconds()); } if (poolTimeout != null) { poolingOptions.setPoolTimeoutMillis((int) poolTimeout.toMilliseconds()); } if (idleTimeout != null) { poolingOptions.setIdleTimeoutSeconds((int) idleTimeout.toSeconds()); } return poolingOptions; }
Example #6
Source File: ClusterConfiguration.java From james-project with Apache License 2.0 | 6 votes |
public ClusterConfiguration(List<Host> hosts, boolean createKeyspace, int minDelay, int maxRetry, Optional<QueryLoggerConfiguration> queryLoggerConfiguration, Optional<PoolingOptions> poolingOptions, int readTimeoutMillis, int connectTimeoutMillis, boolean useSsl, Optional<String> username, Optional<String> password) { this.hosts = hosts; this.createKeyspace = createKeyspace; this.minDelay = minDelay; this.maxRetry = maxRetry; this.queryLoggerConfiguration = queryLoggerConfiguration; this.poolingOptions = poolingOptions; this.readTimeoutMillis = readTimeoutMillis; this.connectTimeoutMillis = connectTimeoutMillis; this.useSsl = useSsl; this.username = username; this.password = password; }
Example #7
Source File: GaugeValueDaoIT.java From glowroot with Apache License 2.0 | 6 votes |
@BeforeClass public static void setUp() throws Exception { SharedSetupRunListener.startCassandra(); clusterManager = ClusterManager.create(); cluster = Clusters.newCluster(); session = new Session(cluster.newSession(), "glowroot_unit_tests", null, PoolingOptions.DEFAULT_MAX_QUEUE_SIZE); asyncExecutor = Executors.newCachedThreadPool(); CentralConfigDao centralConfigDao = new CentralConfigDao(session, clusterManager); AgentDisplayDao agentDisplayDao = new AgentDisplayDao(session, clusterManager, asyncExecutor, 10); agentConfigDao = new AgentConfigDao(session, agentDisplayDao, clusterManager, 10); UserDao userDao = new UserDao(session, clusterManager); RoleDao roleDao = new RoleDao(session, clusterManager); ConfigRepositoryImpl configRepository = new ConfigRepositoryImpl(centralConfigDao, agentConfigDao, userDao, roleDao, ""); gaugeValueDao = new GaugeValueDaoWithV09Support(ImmutableSet.of(), 0, Clock.systemClock(), new GaugeValueDaoImpl(session, configRepository, clusterManager, asyncExecutor, Clock.systemClock())); }
Example #8
Source File: CassandraConfig.java From realtime-analytics with GNU General Public License v2.0 | 6 votes |
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); }
Example #9
Source File: ConfigRepositoryIT.java From glowroot with Apache License 2.0 | 6 votes |
@BeforeClass public static void setUp() throws Exception { SharedSetupRunListener.startCassandra(); clusterManager = ClusterManager.create(); cluster = Clusters.newCluster(); session = new Session(cluster.newSession(), "glowroot_unit_tests", null, PoolingOptions.DEFAULT_MAX_QUEUE_SIZE); session.updateSchemaWithRetry("drop table if exists agent_config"); session.updateSchemaWithRetry("drop table if exists user"); session.updateSchemaWithRetry("drop table if exists role"); session.updateSchemaWithRetry("drop table if exists central_config"); session.updateSchemaWithRetry("drop table if exists agent"); asyncExecutor = Executors.newCachedThreadPool(); CentralConfigDao centralConfigDao = new CentralConfigDao(session, clusterManager); AgentDisplayDao agentDisplayDao = new AgentDisplayDao(session, clusterManager, MoreExecutors.directExecutor(), 10); agentConfigDao = new AgentConfigDao(session, agentDisplayDao, clusterManager, 10); UserDao userDao = new UserDao(session, clusterManager); RoleDao roleDao = new RoleDao(session, clusterManager); configRepository = new ConfigRepositoryImpl(centralConfigDao, agentConfigDao, userDao, roleDao, ""); }
Example #10
Source File: CassandraStorage.java From cassandra-reaper with Apache License 2.0 | 6 votes |
private static void overridePoolingOptions(CassandraFactory cassandraFactory) { PoolingOptionsFactory newPoolingOptionsFactory = new PoolingOptionsFactory() { @Override public PoolingOptions build() { if (null == getPoolTimeout()) { setPoolTimeout(Duration.minutes(2)); } return super.build().setMaxQueueSize(40960); } }; cassandraFactory.getPoolingOptions().ifPresent((originalPoolingOptions) -> { newPoolingOptionsFactory.setHeartbeatInterval(originalPoolingOptions.getHeartbeatInterval()); newPoolingOptionsFactory.setIdleTimeout(originalPoolingOptions.getIdleTimeout()); newPoolingOptionsFactory.setLocal(originalPoolingOptions.getLocal()); newPoolingOptionsFactory.setRemote(originalPoolingOptions.getRemote()); newPoolingOptionsFactory.setPoolTimeout(originalPoolingOptions.getPoolTimeout()); }); cassandraFactory.setPoolingOptions(java.util.Optional.of(newPoolingOptionsFactory)); }
Example #11
Source File: CqlConfigHelper.java From stratio-cassandra with Apache License 2.0 | 6 votes |
private static PoolingOptions getReadPoolingOptions(Configuration conf) { Optional<Integer> coreConnections = getInputCoreConnections(conf); Optional<Integer> maxConnections = getInputMaxConnections(conf); Optional<Integer> maxSimultaneousRequests = getInputMaxSimultReqPerConnections(conf); Optional<Integer> minSimultaneousRequests = getInputMinSimultReqPerConnections(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 (minSimultaneousRequests.isPresent()) poolingOptions.setMinSimultaneousRequestsPerConnectionThreshold(hostDistance, minSimultaneousRequests.get()); if (maxSimultaneousRequests.isPresent()) poolingOptions.setMaxSimultaneousRequestsPerConnectionThreshold(hostDistance, maxSimultaneousRequests.get()); } return poolingOptions; }
Example #12
Source File: IncidentDaoIT.java From glowroot with Apache License 2.0 | 5 votes |
@BeforeClass public static void setUp() throws Exception { SharedSetupRunListener.startCassandra(); cluster = Clusters.newCluster(); session = new Session(cluster.newSession(), "glowroot_unit_tests", null, PoolingOptions.DEFAULT_MAX_QUEUE_SIZE); Clock clock = mock(Clock.class); when(clock.currentTimeMillis()).thenReturn(345L); incidentDao = new IncidentDao(session, clock); }
Example #13
Source File: UserDaoIT.java From glowroot with Apache License 2.0 | 5 votes |
@BeforeClass public static void setUp() throws Exception { SharedSetupRunListener.startCassandra(); cluster = Clusters.newCluster(); session = new Session(cluster.newSession(), "glowroot_unit_tests", null, PoolingOptions.DEFAULT_MAX_QUEUE_SIZE); clusterManager = ClusterManager.create(); userDao = new UserDao(session, clusterManager); }
Example #14
Source File: YugabyteCloudConfig.java From yugastore-java with Apache License 2.0 | 5 votes |
@Override public PoolingOptions getPoolingOptions() { PoolingOptions poolingOptions = new PoolingOptions() .setMaxRequestsPerConnection(HostDistance.LOCAL, 32768) .setMaxRequestsPerConnection(HostDistance.REMOTE, 2000); return poolingOptions; }
Example #15
Source File: WebDriverSetup.java From glowroot with Apache License 2.0 | 5 votes |
private static WebDriverSetup createSetup(boolean shared) throws Exception { int uiPort = getAvailablePort(); File testDir = Files.createTempDir(); CentralModule centralModule; Container container; if (useCentral) { CassandraWrapper.start(); Cluster cluster = Cluster.builder().addContactPoint("127.0.0.1").build(); Session session = new Session(cluster.newSession(), "glowroot_unit_tests", null, PoolingOptions.DEFAULT_MAX_QUEUE_SIZE); session.updateSchemaWithRetry("drop table if exists agent_config"); session.updateSchemaWithRetry("drop table if exists user"); session.updateSchemaWithRetry("drop table if exists role"); session.updateSchemaWithRetry("drop table if exists central_config"); session.updateSchemaWithRetry("drop table if exists agent"); session.close(); cluster.close(); int grpcPort = getAvailablePort(); centralModule = createCentralModule(uiPort, grpcPort); container = createContainerReportingToCentral(grpcPort, testDir); } else { centralModule = null; container = createContainer(uiPort, testDir); } if (SauceLabs.useSauceLabs()) { return new WebDriverSetup(centralModule, container, uiPort, shared, null); } else { return new WebDriverSetup(centralModule, container, uiPort, shared, createWebDriver()); } }
Example #16
Source File: LiveCassandraManager.java From hawkular-metrics with Apache License 2.0 | 5 votes |
@Override public Session createSession() { Cluster.Builder clusterBuilder = new Cluster.Builder() .withPort(9042) .withoutJMXReporting() .withPoolingOptions(new PoolingOptions() .setMaxConnectionsPerHost(HostDistance.LOCAL, 1024) .setCoreConnectionsPerHost(HostDistance.LOCAL, 1024) .setMaxConnectionsPerHost(HostDistance.REMOTE, 1024) .setCoreConnectionsPerHost(HostDistance.REMOTE, 1024) .setMaxRequestsPerConnection(HostDistance.LOCAL, 1024) .setMaxRequestsPerConnection(HostDistance.REMOTE, 1024) .setMaxQueueSize(1024)); Arrays.stream(nodes.split(",")).forEach(clusterBuilder::addContactPoints); cluster = clusterBuilder.build(); cluster.init(); try { session = cluster.connect("system"); return session; } finally { if (session == null) { cluster.close(); } } }
Example #17
Source File: AggregateDaoIT.java From glowroot with Apache License 2.0 | 5 votes |
@BeforeClass public static void setUp() throws Exception { SharedSetupRunListener.startCassandra(); clusterManager = ClusterManager.create(); cluster = Clusters.newCluster(); session = new Session(cluster.newSession(), "glowroot_unit_tests", null, PoolingOptions.DEFAULT_MAX_QUEUE_SIZE); asyncExecutor = Executors.newCachedThreadPool(); CentralConfigDao centralConfigDao = new CentralConfigDao(session, clusterManager); AgentDisplayDao agentDisplayDao = new AgentDisplayDao(session, clusterManager, asyncExecutor, 10); agentConfigDao = new AgentConfigDao(session, agentDisplayDao, clusterManager, 10); UserDao userDao = new UserDao(session, clusterManager); RoleDao roleDao = new RoleDao(session, clusterManager); ConfigRepositoryImpl configRepository = new ConfigRepositoryImpl(centralConfigDao, agentConfigDao, userDao, roleDao, ""); TransactionTypeDao transactionTypeDao = new TransactionTypeDao(session, configRepository, clusterManager, 10); fullQueryTextDao = new FullQueryTextDao(session, configRepository, asyncExecutor); RollupLevelService rollupLevelService = new RollupLevelService(configRepository, Clock.systemClock()); activeAgentDao = new ActiveAgentDao(session, agentDisplayDao, agentConfigDao, configRepository, rollupLevelService, Clock.systemClock()); aggregateDao = new AggregateDaoWithV09Support(ImmutableSet.of(), 0, 0, Clock.systemClock(), new AggregateDaoImpl(session, activeAgentDao, transactionTypeDao, fullQueryTextDao, configRepository, asyncExecutor, Clock.systemClock())); }
Example #18
Source File: RxSessionImpl.java From hawkular-metrics with Apache License 2.0 | 5 votes |
public RxSessionImpl(Session session) { this.session = session; this.loadBalancingPolicy = session.getCluster().getConfiguration().getPolicies().getLoadBalancingPolicy(); PoolingOptions poolingOptions = session.getCluster().getConfiguration().getPoolingOptions(); maxInFlightLocal = poolingOptions.getCoreConnectionsPerHost(HostDistance.LOCAL) * poolingOptions.getMaxRequestsPerConnection(HostDistance.LOCAL); maxInFlightRemote = poolingOptions.getCoreConnectionsPerHost(HostDistance.REMOTE) * poolingOptions.getMaxRequestsPerConnection(HostDistance.REMOTE); }
Example #19
Source File: EnvironmentDaoIT.java From glowroot with Apache License 2.0 | 5 votes |
@BeforeClass public static void setUp() throws Exception { SharedSetupRunListener.startCassandra(); cluster = Clusters.newCluster(); session = new Session(cluster.newSession(), "glowroot_unit_tests", null, PoolingOptions.DEFAULT_MAX_QUEUE_SIZE); environmentDao = new EnvironmentDao(session); }
Example #20
Source File: CqlConfigHelper.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public static Cluster getInputCluster(String[] hosts, Configuration conf) { int port = getInputNativePort(conf); Optional<AuthProvider> authProvider = getAuthProvider(conf); Optional<SSLOptions> sslOptions = getSSLOptions(conf); Optional<Integer> protocolVersion = getProtocolVersion(conf); LoadBalancingPolicy loadBalancingPolicy = getReadLoadBalancingPolicy(conf, hosts); SocketOptions socketOptions = getReadSocketOptions(conf); QueryOptions queryOptions = getReadQueryOptions(conf); PoolingOptions poolingOptions = getReadPoolingOptions(conf); Cluster.Builder builder = Cluster.builder() .addContactPoints(hosts) .withPort(port) .withCompression(ProtocolOptions.Compression.NONE); if (authProvider.isPresent()) builder.withAuthProvider(authProvider.get()); if (sslOptions.isPresent()) builder.withSSL(sslOptions.get()); if (protocolVersion.isPresent()) { builder.withProtocolVersion(protocolVersion.get()); } builder.withLoadBalancingPolicy(loadBalancingPolicy) .withSocketOptions(socketOptions) .withQueryOptions(queryOptions) .withPoolingOptions(poolingOptions); return builder.build(); }
Example #21
Source File: ConfigDaoIT.java From glowroot with Apache License 2.0 | 5 votes |
@BeforeClass public static void setUp() throws Exception { SharedSetupRunListener.startCassandra(); clusterManager = ClusterManager.create(); cluster = Clusters.newCluster(); session = new Session(cluster.newSession(), "glowroot_unit_tests", null, PoolingOptions.DEFAULT_MAX_QUEUE_SIZE); asyncExecutor = Executors.newCachedThreadPool(); AgentDisplayDao agentDisplayDao = new AgentDisplayDao(session, clusterManager, MoreExecutors.directExecutor(), 10); agentConfigDao = new AgentConfigDao(session, agentDisplayDao, clusterManager, 10); }
Example #22
Source File: RoleDaoIT.java From glowroot with Apache License 2.0 | 5 votes |
@BeforeClass public static void setUp() throws Exception { SharedSetupRunListener.startCassandra(); cluster = Clusters.newCluster(); session = new Session(cluster.newSession(), "glowroot_unit_tests", null, PoolingOptions.DEFAULT_MAX_QUEUE_SIZE); clusterManager = ClusterManager.create(); roleDao = new RoleDao(session, clusterManager); }
Example #23
Source File: CassandraClusterCreatorTest.java From spring-cloud-connectors with Apache License 2.0 | 5 votes |
@Test public void shouldCreateClusterWithConfig() throws Exception { CassandraServiceInfo info = new CassandraServiceInfo("local", Collections.singletonList("127.0.0.1"), 9142); CassandraClusterConfig config = new CassandraClusterConfig(); config.setCompression(ProtocolOptions.Compression.NONE); config.setPoolingOptions(new PoolingOptions().setPoolTimeoutMillis(1234)); config.setQueryOptions(new QueryOptions()); config.setProtocolVersion(ProtocolVersion.NEWEST_SUPPORTED); config.setLoadBalancingPolicy(new RoundRobinPolicy()); config.setReconnectionPolicy(new ConstantReconnectionPolicy(1)); config.setRetryPolicy(DowngradingConsistencyRetryPolicy.INSTANCE); config.setSocketOptions(new SocketOptions()); Cluster cluster = creator.create(info, config); Configuration configuration = cluster.getConfiguration(); assertThat(configuration.getProtocolOptions().getCompression(), is(config.getCompression())); assertThat(configuration.getQueryOptions(), is(config.getQueryOptions())); assertThat(configuration.getSocketOptions(), is(config.getSocketOptions())); Policies policies = configuration.getPolicies(); assertThat(policies.getLoadBalancingPolicy(), is(config.getLoadBalancingPolicy())); assertThat(policies.getReconnectionPolicy(), is(config.getReconnectionPolicy())); assertThat(policies.getRetryPolicy(), is(config.getRetryPolicy())); }
Example #24
Source File: CassandraStorageExtension.java From zipkin-dependencies with Apache License 2.0 | 5 votes |
static Cluster getCluster(InetSocketAddress contactPoint) { return Cluster.builder() .withoutJMXReporting() .addContactPointsWithPorts(contactPoint) .withRetryPolicy(ZipkinRetryPolicy.INSTANCE) .withPoolingOptions(new PoolingOptions().setMaxConnectionsPerHost(HostDistance.LOCAL, 1)) .build(); }
Example #25
Source File: CassandraConfig.java From micro-integrator with Apache License 2.0 | 5 votes |
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; }
Example #26
Source File: CassandraController.java From FlareBot with MIT License | 5 votes |
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(); }
Example #27
Source File: CassandraContainer.java From spark-dependencies with Apache License 2.0 | 5 votes |
public Cluster getCluster() { InetSocketAddress address = new InetSocketAddress(getContainerIpAddress(), getMappedPort(9042)); return Cluster.builder() .addContactPointsWithPorts(address) .withPoolingOptions(new PoolingOptions().setMaxConnectionsPerHost(HostDistance.LOCAL, 1)) .build(); }
Example #28
Source File: CassandraStorageExtension.java From zipkin-dependencies with Apache License 2.0 | 5 votes |
static Cluster getCluster(InetSocketAddress contactPoint) { return Cluster.builder() .withoutJMXReporting() .addContactPointsWithPorts(contactPoint) .withRetryPolicy(ZipkinRetryPolicy.INSTANCE) .withPoolingOptions(new PoolingOptions().setMaxConnectionsPerHost(HostDistance.LOCAL, 1)) .build(); }
Example #29
Source File: CentralModule.java From glowroot with Apache License 2.0 | 5 votes |
private static Cluster createCluster(CentralConfiguration centralConfig, TimestampGenerator defaultTimestampGenerator) { Cluster.Builder builder = Cluster.builder() .addContactPoints( centralConfig.cassandraContactPoint().toArray(new String[0])) .withPort(centralConfig.cassandraPort()) // aggressive reconnect policy seems ok since not many clients .withReconnectionPolicy(new ConstantReconnectionPolicy(1000)) // let driver know that only idempotent queries are used so it will retry on timeout .withQueryOptions(new QueryOptions() .setDefaultIdempotence(true) .setConsistencyLevel(centralConfig.cassandraReadConsistencyLevel())) .withPoolingOptions(new PoolingOptions() .setMaxRequestsPerConnection(HostDistance.LOCAL, centralConfig.cassandraMaxConcurrentQueries()) .setMaxRequestsPerConnection(HostDistance.REMOTE, centralConfig.cassandraMaxConcurrentQueries()) // using 2x "max requests per connection", so that thread-based // throttling can allow up to 3x "max requests per connection", which is // split 50% writes / 25% reads / 25% rollups, which will keep the pool // saturated with writes alone .setMaxQueueSize(centralConfig.cassandraMaxConcurrentQueries() * 2) .setPoolTimeoutMillis(centralConfig.cassandraPoolTimeoutMillis())) .withTimestampGenerator(defaultTimestampGenerator); String cassandraUsername = centralConfig.cassandraUsername(); if (!cassandraUsername.isEmpty()) { // empty password is strange but valid builder.withCredentials(cassandraUsername, centralConfig.cassandraPassword()); } if (centralConfig.cassandraSSL()) { builder.withSSL(); } return builder.build(); }
Example #30
Source File: DataSource.java From ignite with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { fetchSize = (Integer)in.readObject(); readConsistency = (ConsistencyLevel)in.readObject(); writeConsistency = (ConsistencyLevel)in.readObject(); user = U.readString(in); pwd = U.readString(in); port = (Integer)in.readObject(); contactPoints = (List<InetAddress>)in.readObject(); contactPointsWithPorts = (List<InetSocketAddress>)in.readObject(); maxSchemaAgreementWaitSeconds = (Integer)in.readObject(); protoVer = (Integer)in.readObject(); compression = U.readString(in); useSSL = (Boolean)in.readObject(); collectMetrix = (Boolean)in.readObject(); jmxReporting = (Boolean)in.readObject(); creds = (Credentials)in.readObject(); loadBalancingPlc = (LoadBalancingPolicy)readObject(in); reconnectionPlc = (ReconnectionPolicy)readObject(in); addrTranslator = (AddressTranslator)readObject(in); speculativeExecutionPlc = (SpeculativeExecutionPolicy)readObject(in); authProvider = (AuthProvider)readObject(in); sslOptions = (SSLOptions)readObject(in); poolingOptions = (PoolingOptions)readObject(in); sockOptions = (SocketOptions)readObject(in); nettyOptions = (NettyOptions)readObject(in); }