Search in sources :

Example 76 with DriverExecutionProfile

use of com.datastax.oss.driver.api.core.config.DriverExecutionProfile in project spring-boot by spring-projects.

the class CassandraAutoConfigurationTests method driverConfigLoaderCustomizeConcurrencyLimitingRequestThrottler.

@Test
void driverConfigLoaderCustomizeConcurrencyLimitingRequestThrottler() {
    this.contextRunner.withPropertyValues("spring.data.cassandra.request.throttler.type=concurrency-limiting", "spring.data.cassandra.request.throttler.max-concurrent-requests=62", "spring.data.cassandra.request.throttler.max-queue-size=72").run((context) -> {
        DriverExecutionProfile config = context.getBean(DriverConfigLoader.class).getInitialConfig().getDefaultProfile();
        assertThat(config.getString(DefaultDriverOption.REQUEST_THROTTLER_CLASS)).isEqualTo(ConcurrencyLimitingRequestThrottler.class.getSimpleName());
        assertThat(config.getInt(DefaultDriverOption.REQUEST_THROTTLER_MAX_CONCURRENT_REQUESTS)).isEqualTo(62);
        assertThat(config.getInt(DefaultDriverOption.REQUEST_THROTTLER_MAX_QUEUE_SIZE)).isEqualTo(72);
    });
}
Also used : ConcurrencyLimitingRequestThrottler(com.datastax.oss.driver.internal.core.session.throttling.ConcurrencyLimitingRequestThrottler) DriverExecutionProfile(com.datastax.oss.driver.api.core.config.DriverExecutionProfile) Test(org.junit.jupiter.api.Test)

Example 77 with DriverExecutionProfile

use of com.datastax.oss.driver.api.core.config.DriverExecutionProfile in project spring-boot by spring-projects.

the class CassandraAutoConfigurationTests method driverConfigLoaderWithContactPointAndNoPort.

@Test
void driverConfigLoaderWithContactPointAndNoPort() {
    this.contextRunner.withPropertyValues("spring.data.cassandra.contact-points=cluster.example.com,another.example.com:9041", "spring.data.cassandra.local-datacenter=cassandra-eu1").run((context) -> {
        assertThat(context).hasSingleBean(DriverConfigLoader.class);
        DriverExecutionProfile configuration = context.getBean(DriverConfigLoader.class).getInitialConfig().getDefaultProfile();
        assertThat(configuration.getStringList(DefaultDriverOption.CONTACT_POINTS)).containsOnly("cluster.example.com:9042", "another.example.com:9041");
        assertThat(configuration.getString(DefaultDriverOption.LOAD_BALANCING_LOCAL_DATACENTER)).isEqualTo("cassandra-eu1");
    });
}
Also used : DriverExecutionProfile(com.datastax.oss.driver.api.core.config.DriverExecutionProfile) Test(org.junit.jupiter.api.Test)

Example 78 with DriverExecutionProfile

use of com.datastax.oss.driver.api.core.config.DriverExecutionProfile in project spring-boot by spring-projects.

the class CassandraAutoConfigurationTests method driverConfigLoaderCustomizeConnectionOptions.

@Test
void driverConfigLoaderCustomizeConnectionOptions() {
    this.contextRunner.withPropertyValues("spring.data.cassandra.connection.connect-timeout=200ms", "spring.data.cassandra.connection.init-query-timeout=10").run((context) -> {
        DriverExecutionProfile config = context.getBean(DriverConfigLoader.class).getInitialConfig().getDefaultProfile();
        assertThat(config.getInt(DefaultDriverOption.CONNECTION_CONNECT_TIMEOUT)).isEqualTo(200);
        assertThat(config.getInt(DefaultDriverOption.CONNECTION_INIT_QUERY_TIMEOUT)).isEqualTo(10);
    });
}
Also used : DriverExecutionProfile(com.datastax.oss.driver.api.core.config.DriverExecutionProfile) Test(org.junit.jupiter.api.Test)

Example 79 with DriverExecutionProfile

use of com.datastax.oss.driver.api.core.config.DriverExecutionProfile in project spring-boot by spring-projects.

the class CassandraAutoConfigurationTests method driverConfigLoaderWithContactPoints.

@Test
void driverConfigLoaderWithContactPoints() {
    this.contextRunner.withPropertyValues("spring.data.cassandra.contact-points=cluster.example.com:9042", "spring.data.cassandra.local-datacenter=cassandra-eu1").run((context) -> {
        assertThat(context).hasSingleBean(DriverConfigLoader.class);
        DriverExecutionProfile configuration = context.getBean(DriverConfigLoader.class).getInitialConfig().getDefaultProfile();
        assertThat(configuration.getStringList(DefaultDriverOption.CONTACT_POINTS)).containsOnly("cluster.example.com:9042");
        assertThat(configuration.getString(DefaultDriverOption.LOAD_BALANCING_LOCAL_DATACENTER)).isEqualTo("cassandra-eu1");
    });
}
Also used : DriverExecutionProfile(com.datastax.oss.driver.api.core.config.DriverExecutionProfile) Test(org.junit.jupiter.api.Test)

Example 80 with DriverExecutionProfile

use of com.datastax.oss.driver.api.core.config.DriverExecutionProfile in project spring-boot by spring-projects.

the class CassandraAutoConfigurationTests method driverConfigLoaderCustomizeRequestOptions.

@Test
void driverConfigLoaderCustomizeRequestOptions() {
    this.contextRunner.withPropertyValues("spring.data.cassandra.request.timeout=5s", "spring.data.cassandra.request.consistency=two", "spring.data.cassandra.request.serial-consistency=quorum", "spring.data.cassandra.request.page-size=42").run((context) -> {
        DriverExecutionProfile config = context.getBean(DriverConfigLoader.class).getInitialConfig().getDefaultProfile();
        assertThat(config.getInt(DefaultDriverOption.REQUEST_TIMEOUT)).isEqualTo(5000);
        assertThat(config.getString(DefaultDriverOption.REQUEST_CONSISTENCY)).isEqualTo("TWO");
        assertThat(config.getString(DefaultDriverOption.REQUEST_SERIAL_CONSISTENCY)).isEqualTo("QUORUM");
        assertThat(config.getInt(DefaultDriverOption.REQUEST_PAGE_SIZE)).isEqualTo(42);
    });
}
Also used : DriverExecutionProfile(com.datastax.oss.driver.api.core.config.DriverExecutionProfile) Test(org.junit.jupiter.api.Test)

Aggregations

DriverExecutionProfile (com.datastax.oss.driver.api.core.config.DriverExecutionProfile)140 Test (org.junit.Test)81 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)29 DriverConfig (com.datastax.oss.driver.api.core.config.DriverConfig)20 CqlSession (com.datastax.oss.driver.api.core.CqlSession)19 InternalDriverContext (com.datastax.oss.driver.internal.core.context.InternalDriverContext)17 Node (com.datastax.oss.driver.api.core.metadata.Node)14 ByteBuffer (java.nio.ByteBuffer)13 SimpleStatement (com.datastax.oss.driver.api.core.cql.SimpleStatement)12 Duration (java.time.Duration)11 GraphTestUtils.createGraphBinaryModule (com.datastax.dse.driver.internal.core.graph.GraphTestUtils.createGraphBinaryModule)10 GraphBinaryModule (com.datastax.dse.driver.internal.core.graph.binary.GraphBinaryModule)10 Row (com.datastax.oss.driver.api.core.cql.Row)9 Test (org.junit.jupiter.api.Test)9 LoggerTest (com.datastax.oss.driver.internal.core.util.LoggerTest)8 DefaultNodeMetric (com.datastax.oss.driver.api.core.metrics.DefaultNodeMetric)7 NodeMetric (com.datastax.oss.driver.api.core.metrics.NodeMetric)7 Message (com.datastax.oss.protocol.internal.Message)7 DriverTimeoutException (com.datastax.oss.driver.api.core.DriverTimeoutException)6 DriverConfigLoader (com.datastax.oss.driver.api.core.config.DriverConfigLoader)6