private ConnectionPoolConfiguration getConnectionPoolConfig ( final String poolName, final int poolSize ){ ConnectionPoolConfiguration config; final String username = cassandraFig.getUsername(); final String password = cassandraFig.getPassword(); if ( username != null && !username.isEmpty() && password != null && !password.isEmpty() ){ config = new ConnectionPoolConfigurationImpl( poolName ) .setPort( cassandraFig.getThriftPort() ) .setLocalDatacenter( cassandraFig.getLocalDataCenter() ) .setMaxConnsPerHost( poolSize ) .setSeeds( cassandraFig.getHosts() ) .setConnectTimeout( cassandraFig.getTimeout() ) .setSocketTimeout( cassandraFig.getTimeout() ) .setAuthenticationCredentials(new SimpleAuthenticationCredentials( username, password)); } else { // create instance of the connection pool without credential if they are not set config = new ConnectionPoolConfigurationImpl( poolName ) .setPort( cassandraFig.getThriftPort() ) .setLocalDatacenter( cassandraFig.getLocalDataCenter() ) .setMaxConnsPerHost( poolSize ) .setSeeds( cassandraFig.getHosts() ) .setSocketTimeout( cassandraFig.getTimeout() ) .setConnectTimeout( cassandraFig.getTimeout() ); } return config; }
final ConnectionPoolType poolType = ConnectionPoolType.valueOf(config.get(CONNECTION_POOL_TYPE)); new ConnectionPoolConfigurationImpl(usedFor + "TitanConnectionPool") .setPort(port) .setMaxOperationsPerConnection(maxOperationsPerConnection) .setMaxConnsPerHost(maxConnsPerHost) .setRetryDelaySlice(retryDelaySlice) .setRetryMaxDelaySlice(retryMaxDelaySlice) .setRetrySuspendWindow(retrySuspendWindow) .setSocketTimeout(connectionTimeout) .setConnectTimeout(connectionTimeout) .setSeeds(StringUtils.join(hostnames, ",")); cpool.setRetryBackoffStrategy(retryBackoffStrategy); log.debug("Custom RetryBackoffStrategy {}", cpool.getRetryBackoffStrategy()); } else { log.debug("Default RetryBackoffStrategy {}", cpool.getRetryBackoffStrategy()); cpool.setLocalDatacenter(localDatacenter); log.debug("Set local datacenter: {}", cpool.getLocalDatacenter()); cpool.setMaxConns(maxConnections); cpool.setAuthenticationCredentials(new SimpleAuthenticationCredentials(username, password)); cpool.setSSLConnectionContext(new SSLConnectionContext(config.get(SSL_TRUSTSTORE_LOCATION), config.get(SSL_TRUSTSTORE_PASSWORD))); .withAstyanaxConfiguration(aconf) .withConnectionPoolConfiguration(cpool)
public CassandraStorage(CassandraDataSegmentConfig config) { this.astyanaxContext = new AstyanaxContext.Builder() .forCluster(CLUSTER_NAME) .forKeyspace(config.getKeyspace()) .withAstyanaxConfiguration(new AstyanaxConfigurationImpl().setDiscoveryType(NodeDiscoveryType.NONE)) .withConnectionPoolConfiguration( new ConnectionPoolConfigurationImpl("MyConnectionPool").setMaxConnsPerHost(10) .setSeeds(config.getHost())).withConnectionPoolMonitor(new CountingConnectionPoolMonitor()) .buildKeyspace(ThriftFamilyFactory.getInstance()); this.astyanaxContext.start(); this.keyspace = this.astyanaxContext.getEntity(); this.config = config; indexStorage = new CassandraChunkedStorageProvider(keyspace, INDEX_TABLE_NAME); descriptorStorage = new ColumnFamily<String, String>(DESCRIPTOR_TABLE_NAME, StringSerializer.get(), StringSerializer.get()); } }
.withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl("MyConnectionPool") .setPort(9160) .setMaxConnsPerHost(40) .setLocalDatacenter("phx") .setSeeds("cdb03.vip.phx.host.com:9160,cdb04.vip.phx.host.com:9160") )
public BagExecuteWithFailover(ConnectionPoolConfiguration config) throws ConnectionException { super(config, monitor); size = topology.getAllPools().getPools().size(); retryCountdown = Math.min(config.getMaxFailoverCount(), size); if (retryCountdown < 0) retryCountdown = size; }
public ConnectionPoolConfigurationImpl(String name) { this.name = name; this.badHostDetector = new BadHostDetectorImpl(this); this.hostRetryBackoffStrategy = new ExponentialRetryBackoffStrategy(this); }
@Override public synchronized void removePool(HostConnectionPool<CL> pool) { allPools.removePool(pool); refresh(); }
private AstyanaxContext<Cluster> getCluster ( final String clusterName, final AstyanaxConfiguration astyanaxConfiguration, final ConnectionPoolConfiguration poolConfig ) { return new AstyanaxContext.Builder().forCluster( clusterName ) .withAstyanaxConfiguration( astyanaxConfiguration ) .withConnectionPoolConfiguration( poolConfig ) .withConnectionPoolMonitor( new Slf4jConnectionPoolMonitorImpl()) .buildCluster( ThriftFamilyFactory.getInstance() ); }
public TokenPartitionedTopology(Partitioner partitioner, LatencyScoreStrategy strategy) { this.strategy = strategy; this.partitioner = partitioner; this.allPools = new TokenHostConnectionPoolPartition<CL>(null, this.strategy); }
/** * Host is marked as down * @param pool */ @Override public void onHostDown(HostConnectionPool<CL> pool) { topology.suspendPool(pool); }
public ThriftSyncConnectionFactoryImpl(AstyanaxConfiguration asConfig, ConnectionPoolConfiguration cpConfig, KeyspaceTracerFactory tracerFactory, ConnectionPoolMonitor monitor) { this.cpConfig = cpConfig; this.asConfig = asConfig; this.limiter = new SimpleRateLimiterImpl(cpConfig); this.tracerFactory = tracerFactory; this.monitor = monitor; }
/** * Called every time a host is added, removed or is marked as down */ protected void rebuildPartitions() { topology.refresh(); }
@Override public void onReset() { rebuildPartitions(); } });
/** * Host is marked as up * @param pool */ @Override public void onHostUp(HostConnectionPool<CL> pool) { topology.resumePool(pool); }
public BagExecuteWithFailover(ConnectionPoolConfiguration config) throws ConnectionException { super(config, monitor); size = topology.getAllPools().getPools().size(); retryCountdown = Math.min(config.getMaxFailoverCount(), size); if (retryCountdown < 0) retryCountdown = size; }
public ConnectionPoolConfigurationImpl(String name) { this.name = name; this.badHostDetector = new BadHostDetectorImpl(this); this.hostRetryBackoffStrategy = new ExponentialRetryBackoffStrategy(this); }
@Override public synchronized void removePool(HostConnectionPool<CL> pool) { allPools.removePool(pool); refresh(); }
public TokenPartitionedTopology(Partitioner partitioner, LatencyScoreStrategy strategy) { this.strategy = strategy; this.partitioner = partitioner; this.allPools = new TokenHostConnectionPoolPartition<CL>(null, this.strategy); }
/** * list of all active pools * @return {@link List<HostConnectionPool>} */ @Override public List<HostConnectionPool<CL>> getActivePools() { return ImmutableList.copyOf(topology.getAllPools().getPools()); }