private Cluster buildCluster() { cluster = Cluster.builder() .addContactPoints(contactPoints.split(",")) .withRetryPolicy(DefaultRetryPolicy.INSTANCE) // .withCredentials("cassandra", "cassandra") .withLoadBalancingPolicy( new TokenAwarePolicy(DCAwareRoundRobinPolicy.builder().build())) .build(); logger.info( "Built Cluster on thread [" + Thread.currentThread().getName() + "]:" + cluster.toString()); return cluster; }
public Cluster getCluster() { if (this.cluster == null) { synchronized (this) { if (this.cluster == null) { this.cluster = buildCluster(); } } } logger.info( "Raw Cluster dispatched on thread [" + Thread.currentThread().getName() + "]:" + cluster.toString()); return this.cluster; }