use of com.datastax.driver.core.policies.RoundRobinPolicy in project cassandra-driver-mapping by valchkou.
the class SchemaSyncTest method init.
@BeforeClass
public static void init() {
String node = "127.0.0.1";
Builder builder = Cluster.builder();
builder.addContactPoint(node);
builder.withLoadBalancingPolicy(LatencyAwarePolicy.builder(new RoundRobinPolicy()).build());
builder.withReconnectionPolicy(new ConstantReconnectionPolicy(1000L));
cluster = builder.build();
session = cluster.connect();
Cache<String, PreparedStatement> cache = CacheBuilder.newBuilder().expireAfterAccess(1, TimeUnit.MILLISECONDS).maximumSize(1).concurrencyLevel(1).build();
MappingSession.setStatementCache(cache);
}
use of com.datastax.driver.core.policies.RoundRobinPolicy in project cassandra-driver-mapping by valchkou.
the class MappingSessionAsyncTest method init.
@BeforeClass
public static void init() {
String node = "127.0.0.1";
Builder builder = Cluster.builder();
builder.addContactPoint(node);
builder.withLoadBalancingPolicy(LatencyAwarePolicy.builder(new RoundRobinPolicy()).build());
builder.withReconnectionPolicy(new ConstantReconnectionPolicy(1000L));
cluster = builder.build();
session = cluster.connect();
Cache<String, PreparedStatement> cache = CacheBuilder.newBuilder().expireAfterAccess(1, TimeUnit.MILLISECONDS).maximumSize(1).concurrencyLevel(1).build();
MappingSession.setStatementCache(cache);
}
use of com.datastax.driver.core.policies.RoundRobinPolicy in project cassandra-driver-mapping by valchkou.
the class MappingSessionTest method init.
@BeforeClass
public static void init() {
String node = "127.0.0.1";
Builder builder = Cluster.builder();
builder.addContactPoint(node);
builder.withLoadBalancingPolicy(LatencyAwarePolicy.builder(new RoundRobinPolicy()).build());
builder.withReconnectionPolicy(new ConstantReconnectionPolicy(1000L));
cluster = builder.build();
session = cluster.connect();
Cache<String, PreparedStatement> cache = CacheBuilder.newBuilder().expireAfterAccess(1, TimeUnit.MILLISECONDS).maximumSize(1).concurrencyLevel(1).build();
MappingSession.setStatementCache(cache);
}
use of com.datastax.driver.core.policies.RoundRobinPolicy in project ats-framework by Axway.
the class CassandraDbProvider method connect.
/**
* Currently we connect just once and then reuse the connection.
* We do not bother with closing the connection.
*
* It is normal to use one Session per DB. The Session is thread safe.
*/
private void connect() {
if (cluster == null) {
log.info("Connecting to Cassandra server on " + this.dbHost + " at port " + this.dbPort);
// allow fetching as much data as present in the DB
QueryOptions queryOptions = new QueryOptions();
queryOptions.setFetchSize(Integer.MAX_VALUE);
queryOptions.setConsistencyLevel(ConsistencyLevel.ONE);
cluster = Cluster.builder().addContactPoint(this.dbHost).withPort(this.dbPort).withLoadBalancingPolicy(new TokenAwarePolicy(new RoundRobinPolicy())).withReconnectionPolicy(new ExponentialReconnectionPolicy(500, 30000)).withQueryOptions(queryOptions).withCredentials(this.dbUser, this.dbPassword).build();
}
if (session == null) {
log.info("Connecting to Cassandra DB with name " + this.dbName);
session = cluster.connect(dbName);
}
}
Aggregations