Search in sources :

Example 6 with Builder

use of com.datastax.driver.core.Cluster.Builder 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);
}
Also used : QueryBuilder(com.datastax.driver.core.querybuilder.QueryBuilder) Builder(com.datastax.driver.core.Cluster.Builder) CacheBuilder(com.google.common.cache.CacheBuilder) RoundRobinPolicy(com.datastax.driver.core.policies.RoundRobinPolicy) ConstantReconnectionPolicy(com.datastax.driver.core.policies.ConstantReconnectionPolicy)

Aggregations

Builder (com.datastax.driver.core.Cluster.Builder)6 ConstantReconnectionPolicy (com.datastax.driver.core.policies.ConstantReconnectionPolicy)3 RoundRobinPolicy (com.datastax.driver.core.policies.RoundRobinPolicy)3 CacheBuilder (com.google.common.cache.CacheBuilder)3 ClusterBuilder (org.apache.flink.streaming.connectors.cassandra.ClusterBuilder)3 PreparedStatement (com.datastax.driver.core.PreparedStatement)2 Tuple2 (org.apache.flink.api.java.tuple.Tuple2)2 StreamExecutionEnvironment (org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)2 BeforeClass (org.junit.BeforeClass)2 QueryBuilder (com.datastax.driver.core.querybuilder.QueryBuilder)1 ArrayList (java.util.ArrayList)1 TypeHint (org.apache.flink.api.common.typeinfo.TypeHint)1 ExecutionEnvironment (org.apache.flink.api.java.ExecutionEnvironment)1