|
|
|
@ -40,6 +40,7 @@ import com.typesafe.config.ConfigFactory;
|
|
|
|
|
import org.springframework.beans.factory.ObjectProvider;
|
|
|
|
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
|
|
|
|
import org.springframework.boot.autoconfigure.cassandra.CassandraProperties.Connection;
|
|
|
|
|
import org.springframework.boot.autoconfigure.cassandra.CassandraProperties.Controlconnection;
|
|
|
|
|
import org.springframework.boot.autoconfigure.cassandra.CassandraProperties.Request;
|
|
|
|
|
import org.springframework.boot.autoconfigure.cassandra.CassandraProperties.Throttler;
|
|
|
|
|
import org.springframework.boot.autoconfigure.cassandra.CassandraProperties.ThrottlerType;
|
|
|
|
@ -127,6 +128,7 @@ public class CassandraAutoConfiguration {
|
|
|
|
|
mapConnectionOptions(properties, options);
|
|
|
|
|
mapPoolingOptions(properties, options);
|
|
|
|
|
mapRequestOptions(properties, options);
|
|
|
|
|
mapControlConnectionOptions(properties, options);
|
|
|
|
|
map.from(mapContactPoints(properties))
|
|
|
|
|
.to((contactPoints) -> options.add(DefaultDriverOption.CONTACT_POINTS, contactPoints));
|
|
|
|
|
map.from(properties.getLocalDatacenter()).to(
|
|
|
|
@ -178,6 +180,13 @@ public class CassandraAutoConfiguration {
|
|
|
|
|
(drainInterval) -> options.add(DefaultDriverOption.REQUEST_THROTTLER_DRAIN_INTERVAL, drainInterval));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void mapControlConnectionOptions(CassandraProperties properties, CassandraDriverOptions options) {
|
|
|
|
|
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
|
|
|
|
|
Controlconnection controlProperties = properties.getControlconnection();
|
|
|
|
|
map.from(controlProperties::getTimeout).asInt(Duration::toMillis)
|
|
|
|
|
.to((timeout) -> options.add(DefaultDriverOption.CONTROL_CONNECTION_TIMEOUT, timeout));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<String> mapContactPoints(CassandraProperties properties) {
|
|
|
|
|
return properties.getContactPoints().stream()
|
|
|
|
|
.map((candidate) -> formatContactPoint(candidate, properties.getPort())).collect(Collectors.toList());
|
|
|
|
|