Пример #1
0
  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;
  }
Пример #2
0
  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;
  }