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() ); }
new Slf4jConnectionPoolMonitorImpl() : new CountingConnectionPoolMonitor();
@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; }
new Slf4jConnectionPoolMonitorImpl() : new CountingConnectionPoolMonitor();
AstyanaxContext<Keyspace> getKeyspaceAstyanaxContext(String cassandraVersion, String cqlVersion, ConsistencyLevel readConsistency, ConsistencyLevel writeConsistency, ConnectionPoolConfigurationImpl conf) { return new AstyanaxContext.Builder() // .forCluster("ClusterName") // Not sure why this is helpful .forKeyspace(configuration.getKeyspaceName()) .withAstyanaxConfiguration(new AstyanaxConfigurationImpl() .setTargetCassandraVersion(cassandraVersion) .setCqlVersion(cqlVersion) .setDefaultReadConsistencyLevel(readConsistency) .setDefaultWriteConsistencyLevel(writeConsistency) .setDiscoveryType(configuration.getNodeDiscoveryType()) .setConnectionPoolType(configuration.getConnectionPoolType()) ) .withConnectionPoolConfiguration(conf) .withConnectionPoolMonitor(new Slf4jConnectionPoolMonitorImpl()) .buildKeyspace(ThriftFamilyFactory.getInstance()); }