Search in sources :

Example 1 with ThrottlerType

use of org.springframework.boot.autoconfigure.cassandra.CassandraProperties.ThrottlerType in project spring-boot by spring-projects.

the class CassandraAutoConfiguration method mapRequestOptions.

private void mapRequestOptions(CassandraProperties properties, CassandraDriverOptions options) {
    PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
    Request requestProperties = properties.getRequest();
    map.from(requestProperties::getTimeout).asInt(Duration::toMillis).to(((timeout) -> options.add(DefaultDriverOption.REQUEST_TIMEOUT, timeout)));
    map.from(requestProperties::getConsistency).to(((consistency) -> options.add(DefaultDriverOption.REQUEST_CONSISTENCY, consistency)));
    map.from(requestProperties::getSerialConsistency).to((serialConsistency) -> options.add(DefaultDriverOption.REQUEST_SERIAL_CONSISTENCY, serialConsistency));
    map.from(requestProperties::getPageSize).to((pageSize) -> options.add(DefaultDriverOption.REQUEST_PAGE_SIZE, pageSize));
    Throttler throttlerProperties = requestProperties.getThrottler();
    map.from(throttlerProperties::getType).as(ThrottlerType::type).to((type) -> options.add(DefaultDriverOption.REQUEST_THROTTLER_CLASS, type));
    map.from(throttlerProperties::getMaxQueueSize).to((maxQueueSize) -> options.add(DefaultDriverOption.REQUEST_THROTTLER_MAX_QUEUE_SIZE, maxQueueSize));
    map.from(throttlerProperties::getMaxConcurrentRequests).to((maxConcurrentRequests) -> options.add(DefaultDriverOption.REQUEST_THROTTLER_MAX_CONCURRENT_REQUESTS, maxConcurrentRequests));
    map.from(throttlerProperties::getMaxRequestsPerSecond).to((maxRequestsPerSecond) -> options.add(DefaultDriverOption.REQUEST_THROTTLER_MAX_REQUESTS_PER_SECOND, maxRequestsPerSecond));
    map.from(throttlerProperties::getDrainInterval).asInt(Duration::toMillis).to((drainInterval) -> options.add(DefaultDriverOption.REQUEST_THROTTLER_DRAIN_INTERVAL, drainInterval));
}
Also used : SSLContext(javax.net.ssl.SSLContext) Throttler(org.springframework.boot.autoconfigure.cassandra.CassandraProperties.Throttler) ConditionalOnClass(org.springframework.boot.autoconfigure.condition.ConditionalOnClass) Request(org.springframework.boot.autoconfigure.cassandra.CassandraProperties.Request) Supplier(java.util.function.Supplier) Scope(org.springframework.context.annotation.Scope) LinkedHashMap(java.util.LinkedHashMap) ProgrammaticDriverConfigLoaderBuilder(com.datastax.oss.driver.api.core.config.ProgrammaticDriverConfigLoaderBuilder) ObjectProvider(org.springframework.beans.factory.ObjectProvider) DefaultDriverOption(com.datastax.oss.driver.api.core.config.DefaultDriverOption) CqlSession(com.datastax.oss.driver.api.core.CqlSession) Duration(java.time.Duration) Map(java.util.Map) EnableConfigurationProperties(org.springframework.boot.context.properties.EnableConfigurationProperties) ConfigFactory(com.typesafe.config.ConfigFactory) AutoConfiguration(org.springframework.boot.autoconfigure.AutoConfiguration) Resource(org.springframework.core.io.Resource) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) PropertyMapper(org.springframework.boot.context.properties.PropertyMapper) EnableAutoConfiguration(org.springframework.boot.autoconfigure.EnableAutoConfiguration) Config(com.typesafe.config.Config) Connection(org.springframework.boot.autoconfigure.cassandra.CassandraProperties.Connection) CqlSessionBuilder(com.datastax.oss.driver.api.core.CqlSessionBuilder) IOException(java.io.IOException) Controlconnection(org.springframework.boot.autoconfigure.cassandra.CassandraProperties.Controlconnection) ThrottlerType(org.springframework.boot.autoconfigure.cassandra.CassandraProperties.ThrottlerType) Collectors(java.util.stream.Collectors) DriverOption(com.datastax.oss.driver.api.core.config.DriverOption) DefaultDriverConfigLoader(com.datastax.oss.driver.internal.core.config.typesafe.DefaultDriverConfigLoader) DefaultProgrammaticDriverConfigLoaderBuilder(com.datastax.oss.driver.internal.core.config.typesafe.DefaultProgrammaticDriverConfigLoaderBuilder) List(java.util.List) DriverConfigLoader(com.datastax.oss.driver.api.core.config.DriverConfigLoader) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) Lazy(org.springframework.context.annotation.Lazy) Bean(org.springframework.context.annotation.Bean) Request(org.springframework.boot.autoconfigure.cassandra.CassandraProperties.Request) PropertyMapper(org.springframework.boot.context.properties.PropertyMapper) Throttler(org.springframework.boot.autoconfigure.cassandra.CassandraProperties.Throttler)

Aggregations

CqlSession (com.datastax.oss.driver.api.core.CqlSession)1 CqlSessionBuilder (com.datastax.oss.driver.api.core.CqlSessionBuilder)1 DefaultDriverOption (com.datastax.oss.driver.api.core.config.DefaultDriverOption)1 DriverConfigLoader (com.datastax.oss.driver.api.core.config.DriverConfigLoader)1 DriverOption (com.datastax.oss.driver.api.core.config.DriverOption)1 ProgrammaticDriverConfigLoaderBuilder (com.datastax.oss.driver.api.core.config.ProgrammaticDriverConfigLoaderBuilder)1 DefaultDriverConfigLoader (com.datastax.oss.driver.internal.core.config.typesafe.DefaultDriverConfigLoader)1 DefaultProgrammaticDriverConfigLoaderBuilder (com.datastax.oss.driver.internal.core.config.typesafe.DefaultProgrammaticDriverConfigLoaderBuilder)1 Config (com.typesafe.config.Config)1 ConfigFactory (com.typesafe.config.ConfigFactory)1 IOException (java.io.IOException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 Duration (java.time.Duration)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1 Supplier (java.util.function.Supplier)1 Collectors (java.util.stream.Collectors)1 SSLContext (javax.net.ssl.SSLContext)1 ObjectProvider (org.springframework.beans.factory.ObjectProvider)1