use of com.datastax.driver.core.QueryOptions 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