use of com.datastax.driver.core.PlainTextAuthProvider in project storm by apache.
the class ClusterFactory method make.
/**
* Creates a new Cluster based on the specified configuration.
* @param topoConf the storm configuration.
* @return a new a new {@link com.datastax.driver.core.Cluster} instance.
*/
@Override
protected Cluster make(Map<String, Object> topoConf) {
CassandraConf cassandraConf = new CassandraConf(topoConf);
Cluster.Builder cluster = Cluster.builder().withoutJMXReporting().withoutMetrics().addContactPoints(cassandraConf.getNodes()).withPort(cassandraConf.getPort()).withRetryPolicy(cassandraConf.getRetryPolicy()).withReconnectionPolicy(new ExponentialReconnectionPolicy(cassandraConf.getReconnectionPolicyBaseMs(), cassandraConf.getReconnectionPolicyMaxMs())).withLoadBalancingPolicy(cassandraConf.getLoadBalancingPolicy());
cluster.getConfiguration().getSocketOptions().setReadTimeoutMillis((int) cassandraConf.getSocketReadTimeoutMillis());
cluster.getConfiguration().getSocketOptions().setConnectTimeoutMillis((int) cassandraConf.getSocketConnectTimeoutMillis());
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);
PoolingOptions poolOps = new PoolingOptions();
poolOps.setMaxQueueSize(cassandraConf.getPoolMaxQueueSize());
poolOps.setHeartbeatIntervalSeconds(cassandraConf.getHeartbeatIntervalSeconds());
poolOps.setIdleTimeoutSeconds(cassandraConf.getIdleTimeoutSeconds());
poolOps.setMaxRequestsPerConnection(HostDistance.LOCAL, cassandraConf.getMaxRequestPerConnectionLocal());
poolOps.setMaxRequestsPerConnection(HostDistance.REMOTE, cassandraConf.getMaxRequestPerConnectionRemote());
cluster.withPoolingOptions(poolOps);
return cluster.build();
}
Aggregations