private void initPersistence() {
long ts1 = System.currentTimeMillis();
logger.info("event=initializing_hector");
CassandraHostConfigurator cassandraHostConfigurator = new CassandraHostConfigurator();
cassandraHostConfigurator.setHosts(CLUSTER_URL);
cassandraHostConfigurator.setMaxActive(hectorPoolSize);
cassandraHostConfigurator.setCassandraThriftSocketTimeout(CMBProperties.getInstance().getCassandraThriftSocketTimeOutMS());
cassandraHostConfigurator.setAutoDiscoverHosts(CMBProperties.getInstance().isHectorAutoDiscovery());
cassandraHostConfigurator.setAutoDiscoveryDelayInSeconds(CMBProperties.getInstance().getHectorAutoDiscoveryDelaySeconds());
String dataCenter = CMBProperties.getInstance().getCassandraDataCenter();
if (dataCenter != null && !dataCenter.equals("")) {
cassandraHostConfigurator.setAutoDiscoveryDataCenter(dataCenter);
}
// some other settings we may be interested in down the road, see here for more details:
// https://github.com/rantav/hector/wiki/User-Guide
if (hectorBalancingPolicy != null) {
if (hectorBalancingPolicy.equals("LeastActiveBalancingPolicy")) {
cassandraHostConfigurator.setLoadBalancingPolicy(new LeastActiveBalancingPolicy());
} else if (hectorBalancingPolicy.equals("RoundRobinBalancingPolicy")) {
cassandraHostConfigurator.setLoadBalancingPolicy(new RoundRobinBalancingPolicy()); //default
} else if (hectorBalancingPolicy.equals("DynamicLoadBalancingPolicy")) {
cassandraHostConfigurator.setLoadBalancingPolicy(new DynamicLoadBalancingPolicy());
}
}
//cassandraHostConfigurator.setExhaustedPolicy(ExhaustedPolicy.WHEN_EXHAUSTED_GROW);