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);
}
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");
});
}
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());
});
}
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);
});
}
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);
});
}
Aggregations