/** * 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(); }