.setPort(port) .setMaxOperationsPerConnection(maxOperationsPerConnection) .setMaxConnsPerHost(maxConnsPerHost) .setRetryDelaySlice(retryDelaySlice) .setRetryMaxDelaySlice(retryMaxDelaySlice)
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; }
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()); } }
@Nonnull @Override public Collection<Runnable> getRunnables(@Nonnull UUID jobId, int sliceId, @Nonnull UUID workerId, @Nonnull ScopedProgressClient progressClient) throws IOException { context = new AstyanaxContext.Builder().forCluster(clusterName) .forKeyspace(keyspaceName) .withAstyanaxConfiguration(new AstyanaxConfigurationImpl().setDiscoveryType(NodeDiscoveryType.NONE)) .withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl("defaultConnPool") .setPort(port) .setMaxConnsPerHost(100) .setSeeds(seeds)) .withConnectionPoolMonitor(new Slf4jConnectionPoolMonitorImpl()) .buildKeyspace(ThriftFamilyFactory.getInstance()); context.start(); Keyspace keyspace = context.getEntity(); ColumnFamily<byte[], byte[]> cfDef = new ColumnFamily<>(columnFamilyName, BytesArraySerializer.get(), BytesArraySerializer.get()); ArrayList<Runnable> runnables = Lists.newArrayList(); byte[] colNameBytes = colName.getBytes(Charsets.UTF_8); for (int i = 0; i < numThreads; i++) { runnables.add(new CassandraRunnable(taskOperation, keyGeneratorFactory.getKeyGenerator(), workerId, sliceId, numQuanta, batchSize, jobId, valueGeneratorFactory.getValueGenerator(), keyspace, cfDef, colNameBytes)); } return runnables; }
private AstyanaxContext<Keyspace> initWithThriftDriverWithEurekaHostsSupplier() { logger.info("BOOT_CLUSTER = {}, KS_NAME = {}", BOOT_CLUSTER, KS_NAME); return new AstyanaxContext.Builder().forCluster(BOOT_CLUSTER).forKeyspace(KS_NAME) .withAstyanaxConfiguration( new AstyanaxConfigurationImpl().setDiscoveryType(NodeDiscoveryType.DISCOVERY_SERVICE)) .withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl("MyConnectionPool") .setMaxConnsPerHost(3).setPort(thriftPortForAstyanax)) .withHostSupplier(hostSupplier.getSupplier(BOOT_CLUSTER)) .withConnectionPoolMonitor(new CountingConnectionPoolMonitor()) .buildKeyspace(ThriftFamilyFactory.getInstance()); }
public synchronized Cluster registerCluster(String clusterName, String contactPoint, int port) { logger.info("Connected Cassandra Cluster: " + clusterName); if(clusterContext == null) { clusterContext = new AstyanaxContext.Builder().forCluster(clusterName) .withAstyanaxConfiguration(new AstyanaxConfigurationImpl() .setDiscoveryType(NodeDiscoveryType.RING_DESCRIBE) ) .withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl("MyConnectionPool") .setPort(port) .setMaxConnsPerHost(1) .setSeeds(contactPoint) ) .withConnectionPoolMonitor(new CountingConnectionPoolMonitor()) .buildCluster(ThriftFamilyFactory.getInstance()); clusterContext.start(); } logger.warn("Cluster already registered"); return clusterContext.getClient(); }
public synchronized Cluster registerCluster(String clusterName, String contactPoint, int port) { logger.info("Connected Cassandra Cluster: " + clusterName); if(clusterContext == null) { clusterContext = new AstyanaxContext.Builder().forCluster(clusterName) .withAstyanaxConfiguration(new AstyanaxConfigurationImpl() .setDiscoveryType(NodeDiscoveryType.RING_DESCRIBE) ) .withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl("MyConnectionPool") .setPort(port) .setMaxConnsPerHost(1) .setSeeds(contactPoint) ) .withConnectionPoolMonitor(new CountingConnectionPoolMonitor()) .buildCluster(ThriftFamilyFactory.getInstance()); clusterContext.start(); } logger.warn("Cluster already registered"); return clusterContext.getClient(); }
private AstyanaxContext<Keyspace> initWithThriftDriverWithExternalHostsSupplier() { logger.info("BOOT_CLUSTER = {}, KS_NAME = {}", BOOT_CLUSTER, KS_NAME); return new AstyanaxContext.Builder().forCluster(BOOT_CLUSTER).forKeyspace(KS_NAME) .withAstyanaxConfiguration( new AstyanaxConfigurationImpl().setDiscoveryType(NodeDiscoveryType.DISCOVERY_SERVICE) .setConnectionPoolType(ConnectionPoolType.ROUND_ROBIN)) .withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl("MyConnectionPool") .setMaxConnsPerHost(3).setPort(thriftPortForAstyanax)) .withHostSupplier(getSupplier()).withConnectionPoolMonitor(new CountingConnectionPoolMonitor()) .buildKeyspace(ThriftFamilyFactory.getInstance()); }
public synchronized Keyspace registerKeyspace(String clusterName, String ksName, String contactPoint, int port) { logger.info("Cassandra Cluster: " + clusterName); if(keyspaceContext == null) { keyspaceContext = new AstyanaxContext.Builder() .forCluster(clusterName) .forKeyspace(ksName) .withAstyanaxConfiguration(new AstyanaxConfigurationImpl() .setDiscoveryType(NodeDiscoveryType.RING_DESCRIBE) ) .withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl("MyConnectionPool") .setPort(port) .setMaxConnsPerHost(1) .setSeeds(contactPoint) ) .withConnectionPoolMonitor(new CountingConnectionPoolMonitor()) .buildKeyspace(ThriftFamilyFactory.getInstance()); keyspaceContext.start(); } logger.warn("Keyspace already registered"); return keyspaceContext.getClient(); }
public synchronized Keyspace registerKeyspace(String clusterName, String ksName, String contactPoint, int port) { logger.info("Cassandra Cluster: " + clusterName); if(keyspaceContext == null) { keyspaceContext = new AstyanaxContext.Builder() .forCluster(clusterName) .forKeyspace(ksName) .withAstyanaxConfiguration(new AstyanaxConfigurationImpl() .setDiscoveryType(NodeDiscoveryType.RING_DESCRIBE) ) .withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl("MyConnectionPool") .setPort(port) .setMaxConnsPerHost(1) .setSeeds(contactPoint) ) .withConnectionPoolMonitor(new CountingConnectionPoolMonitor()) .buildKeyspace(ThriftFamilyFactory.getInstance()); keyspaceContext.start(); } logger.warn("Keyspace already registered"); return keyspaceContext.getClient(); }
public AstyanaxContext<Cluster> newAstyanaxContextForCluster() { AstyanaxContext<Cluster> context = new AstyanaxContext.Builder() .forCluster(clusterName) .withAstyanaxConfiguration(new AstyanaxConfigurationImpl() .setDiscoveryType(NodeDiscoveryType.NONE)) .withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl("BrooklynPool") .setPort(thriftPort) .setMaxConnsPerHost(1) .setConnectTimeout(5000) // 10s .setSeeds(String.format("%s:%d", hostname, thriftPort))) .withConnectionPoolMonitor(new CountingConnectionPoolMonitor()) .buildCluster(ThriftFamilyFactory.getInstance()); context.start(); return context; }
.setMaxConnsPerHost(1) .setSeeds("127.0.0.1:9160")
.setMaxConnsPerHost(1) .setSeeds("127.0.0.1:9160")
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()); } }
public AstyanaxContext<Keyspace> newAstyanaxContextForKeyspace(String keyspace) { AstyanaxContext<Keyspace> context = new AstyanaxContext.Builder() .forCluster(clusterName) .forKeyspace(keyspace) .withAstyanaxConfiguration(new AstyanaxConfigurationImpl() .setDiscoveryType(NodeDiscoveryType.NONE)) .withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl("BrooklynPool") .setPort(thriftPort) .setMaxConnsPerHost(1) .setConnectTimeout(5000) // 10s .setSeeds(String.format("%s:%d", hostname, thriftPort))) .withConnectionPoolMonitor(new CountingConnectionPoolMonitor()) .buildKeyspace(ThriftFamilyFactory.getInstance()); context.start(); return context; }
.setSocketTimeout(30000) .setMaxTimeoutWhenExhausted(2000) .setMaxConnsPerHost(20) .setInitConnsPerHost(10) .setSeeds(SEEDS)
.setSocketTimeout(30000) .setMaxTimeoutWhenExhausted(2000) .setMaxConnsPerHost(20) .setInitConnsPerHost(10) .setSeeds(SEEDS)
.setMaxConnsPerHost(DynamicPropertyFactory.getInstance().getIntProperty(ZUUL_CASSANDRA_MAXCONNECTIONSPERHOST, 1).get()) .setSeeds(DynamicPropertyFactory.getInstance().getStringProperty(ZUUL_CASSANDRA_HOST, "").get() + ":" + DynamicPropertyFactory.getInstance().getIntProperty(ZUUL_CASSANDRA_PORT, 7102).get()
.setMaxConnsPerHost(DynamicPropertyFactory.getInstance().getIntProperty(ZUUL_CASSANDRA_MAXCONNECTIONSPERHOST, 1).get()) .setSeeds(DynamicPropertyFactory.getInstance().getStringProperty(ZUUL_CASSANDRA_HOST, "").get() + ":" + DynamicPropertyFactory.getInstance().getIntProperty(ZUUL_CASSANDRA_PORT, 7102).get()
.setSocketTimeout(30000) .setMaxTimeoutWhenExhausted(2000) .setMaxConnsPerHost(20) .setInitConnsPerHost(10) .setSeeds(SEEDS)