Search in sources :

Example 71 with DriverExecutionProfile

use of com.datastax.oss.driver.api.core.config.DriverExecutionProfile in project java-driver by datastax.

the class ContinuousPagingReactiveIT method should_execute_reactively.

@Test
@UseDataProvider("pagingOptions")
public void should_execute_reactively(Options options) {
    CqlSession session = sessionRule.session();
    SimpleStatement statement = SimpleStatement.newInstance("SELECT v from test where k=?", KEY);
    DriverExecutionProfile profile = options.asProfile(session);
    ContinuousReactiveResultSet rs = session.executeContinuouslyReactive(statement.setExecutionProfile(profile));
    List<ReactiveRow> results = Flowable.fromPublisher(rs).toList().blockingGet();
    assertThat(results).hasSize(options.expectedRows);
    Set<ExecutionInfo> expectedExecInfos = new LinkedHashSet<>();
    for (int i = 0; i < results.size(); i++) {
        ReactiveRow row = results.get(i);
        assertThat(row.getInt("v")).isEqualTo(i);
        expectedExecInfos.add(row.getExecutionInfo());
    }
    List<ExecutionInfo> execInfos = Flowable.<ExecutionInfo>fromPublisher(rs.getExecutionInfos()).toList().blockingGet();
    // DSE may send an empty page as it can't always know if it's done paging or not yet.
    // See: CASSANDRA-8871. In this case, this page's execution info appears in
    // rs.getExecutionInfos(), but is not present in expectedExecInfos since the page did not
    // contain any rows.
    assertThat(execInfos).containsAll(expectedExecInfos);
    List<ColumnDefinitions> colDefs = Flowable.<ColumnDefinitions>fromPublisher(rs.getColumnDefinitions()).toList().blockingGet();
    ReactiveRow first = results.get(0);
    assertThat(colDefs).hasSize(1).containsExactly(first.getColumnDefinitions());
    List<Boolean> wasApplied = Flowable.fromPublisher(rs.wasApplied()).toList().blockingGet();
    assertThat(wasApplied).hasSize(1).containsExactly(first.wasApplied());
    validateMetrics(session);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ColumnDefinitions(com.datastax.oss.driver.api.core.cql.ColumnDefinitions) DriverExecutionProfile(com.datastax.oss.driver.api.core.config.DriverExecutionProfile) SimpleStatement(com.datastax.oss.driver.api.core.cql.SimpleStatement) ExecutionInfo(com.datastax.oss.driver.api.core.cql.ExecutionInfo) ReactiveRow(com.datastax.dse.driver.api.core.cql.reactive.ReactiveRow) CqlSession(com.datastax.oss.driver.api.core.CqlSession) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Example 72 with DriverExecutionProfile

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

the class CassandraAutoConfigurationTests method driverConfigLoaderWithContactPointAndNoPortAndCustomPort.

@Test
void driverConfigLoaderWithContactPointAndNoPortAndCustomPort() {
    this.contextRunner.withPropertyValues("spring.data.cassandra.contact-points=cluster.example.com:9041,another.example.com", "spring.data.cassandra.port=9043", "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:9041", "another.example.com:9043");
        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 73 with DriverExecutionProfile

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

the class CassandraAutoConfigurationTests method driverConfigLoaderUsePassThroughLimitingRequestThrottlerByDefault.

@Test
void driverConfigLoaderUsePassThroughLimitingRequestThrottlerByDefault() {
    this.contextRunner.withPropertyValues().run((context) -> {
        DriverExecutionProfile config = context.getBean(DriverConfigLoader.class).getInitialConfig().getDefaultProfile();
        assertThat(config.getString(DefaultDriverOption.REQUEST_THROTTLER_CLASS)).isEqualTo(PassThroughRequestThrottler.class.getSimpleName());
    });
}
Also used : PassThroughRequestThrottler(com.datastax.oss.driver.internal.core.session.throttling.PassThroughRequestThrottler) DriverExecutionProfile(com.datastax.oss.driver.api.core.config.DriverExecutionProfile) Test(org.junit.jupiter.api.Test)

Example 74 with DriverExecutionProfile

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

the class CassandraAutoConfigurationTests method driverConfigLoaderCustomizeRateLimitingRequestThrottler.

@Test
void driverConfigLoaderCustomizeRateLimitingRequestThrottler() {
    this.contextRunner.withPropertyValues("spring.data.cassandra.request.throttler.type=rate-limiting", "spring.data.cassandra.request.throttler.max-requests-per-second=62", "spring.data.cassandra.request.throttler.max-queue-size=72", "spring.data.cassandra.request.throttler.drain-interval=16ms").run((context) -> {
        DriverExecutionProfile config = context.getBean(DriverConfigLoader.class).getInitialConfig().getDefaultProfile();
        assertThat(config.getString(DefaultDriverOption.REQUEST_THROTTLER_CLASS)).isEqualTo(RateLimitingRequestThrottler.class.getSimpleName());
        assertThat(config.getInt(DefaultDriverOption.REQUEST_THROTTLER_MAX_REQUESTS_PER_SECOND)).isEqualTo(62);
        assertThat(config.getInt(DefaultDriverOption.REQUEST_THROTTLER_MAX_QUEUE_SIZE)).isEqualTo(72);
        assertThat(config.getInt(DefaultDriverOption.REQUEST_THROTTLER_DRAIN_INTERVAL)).isEqualTo(16);
    });
}
Also used : RateLimitingRequestThrottler(com.datastax.oss.driver.internal.core.session.throttling.RateLimitingRequestThrottler) DriverExecutionProfile(com.datastax.oss.driver.api.core.config.DriverExecutionProfile) Test(org.junit.jupiter.api.Test)

Example 75 with DriverExecutionProfile

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

the class CassandraAutoConfigurationTests method driverConfigLoaderCustomizePoolOptions.

@Test
void driverConfigLoaderCustomizePoolOptions() {
    this.contextRunner.withPropertyValues("spring.data.cassandra.pool.idle-timeout=42", "spring.data.cassandra.pool.heartbeat-interval=62").run((context) -> {
        DriverExecutionProfile config = context.getBean(DriverConfigLoader.class).getInitialConfig().getDefaultProfile();
        assertThat(config.getInt(DefaultDriverOption.HEARTBEAT_TIMEOUT)).isEqualTo(42);
        assertThat(config.getInt(DefaultDriverOption.HEARTBEAT_INTERVAL)).isEqualTo(62);
    });
}
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