/**
   * Creates a new Cluster based on the specified configuration.
   *
   * @param stormConf the storm configuration.
   * @return a new a new {@link Cluster} instance.
   */
  @Override
  protected Cluster make(Map<String, Object> stormConf) {
    CassandraConf cassandraConf = new CassandraConf(stormConf);

    Cluster.Builder cluster =
        Cluster.builder()
            .withoutJMXReporting()
            .withoutMetrics()
            .addContactPoints(cassandraConf.getNodes())
            .withPort(cassandraConf.getPort())
            .withRetryPolicy(DowngradingConsistencyRetryPolicy.INSTANCE)
            .withReconnectionPolicy(
                new ExponentialReconnectionPolicy(100L, TimeUnit.MINUTES.toMillis(1)))
            .withLoadBalancingPolicy(new TokenAwarePolicy(new RoundRobinPolicy()));

    final String username = cassandraConf.getUsername();
    final String password = cassandraConf.getPassword();

    if (StringUtils.isNotEmpty(username) && StringUtils.isNotEmpty(password)) {
      cluster.withAuthProvider(new PlainTextAuthProvider(username, password));
    }

    QueryOptions options =
        new QueryOptions().setConsistencyLevel(cassandraConf.getConsistencyLevel());
    cluster.withQueryOptions(options);

    return cluster.build();
  }
  public static synchronized Session getSession(String host, int port) throws UnknownHostException {
    Session session = hostConnectionMap.getIfPresent(host);
    if (session == null || session.isClosed()) {
      Cluster.Builder builder = Cluster.builder().addContactPoint(host).withPort(port);
      Cluster cluster = builder.build();
      session = cluster.connect();
      hostConnectionMap.put(host, session);

      logger.debug("Created connection to {}.", host);
      logger.debug("Number of sessions opened are {}.", hostConnectionMap.size());
    }
    return session;
  }
  public PersistentCassandraDrain(
      E environment, String username, String password, String[] seeds, String keyspace) {
    Cluster.Builder builder = Cluster.builder().addContactPoints(seeds);
    builder.withReconnectionPolicy(new ExponentialReconnectionPolicy(500, 60_000));
    if (username != null) {
      if (password != null) {
        builder = builder.withCredentials(username, password);
      } else {
        logger.warn("username was set, password was NOT set - IGNORING username!");
      }
    }

    this.environment = environment;
    this.cluster = builder.build();
    this.keyspace = keyspace;
    this.session = cluster.connect(keyspace);
  }