Skip to content

Commit 6961797

Browse files
committed
Align default values for Cassandra's throttling properties
Closes gh-25149
1 parent 0ba1d5f commit 6961797

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraProperties.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -356,24 +356,24 @@ public static class Throttler {
356356
* Maximum number of requests that can be enqueued when the throttling threshold
357357
* is exceeded.
358358
*/
359-
private int maxQueueSize = 10000;
359+
private int maxQueueSize;
360360

361361
/**
362362
* Maximum number of requests that are allowed to execute in parallel.
363363
*/
364-
private int maxConcurrentRequests = 10000;
364+
private int maxConcurrentRequests;
365365

366366
/**
367367
* Maximum allowed request rate.
368368
*/
369-
private int maxRequestsPerSecond = 10000;
369+
private int maxRequestsPerSecond;
370370

371371
/**
372372
* How often the throttler attempts to dequeue requests. Set this high enough that
373373
* each attempt will process multiple entries in the queue, but not delay requests
374374
* too much.
375375
*/
376-
private Duration drainInterval = Duration.ofMillis(10);
376+
private Duration drainInterval;
377377

378378
public ThrottlerType getType() {
379379
return this.type;

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfigurationTests.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@
1717
package org.springframework.boot.autoconfigure.cassandra;
1818

1919
import com.datastax.oss.driver.api.core.CqlIdentifier;
20+
import com.datastax.oss.driver.api.core.CqlSession;
2021
import com.datastax.oss.driver.api.core.CqlSessionBuilder;
2122
import com.datastax.oss.driver.api.core.config.DefaultDriverOption;
2223
import com.datastax.oss.driver.api.core.config.DriverConfigLoader;
@@ -32,6 +33,7 @@
3233
import org.springframework.context.annotation.Configuration;
3334

3435
import static org.assertj.core.api.Assertions.assertThat;
36+
import static org.assertj.core.api.Assertions.assertThatThrownBy;
3537

3638
/**
3739
* Tests for {@link CassandraAutoConfiguration}
@@ -186,6 +188,14 @@ void driverConfigLoaderUsePassThroughLimitingRequestThrottlerByDefault() {
186188
});
187189
}
188190

191+
@Test
192+
void driverConfigLoaderWithRateLimitingRequiresExtraConfiguration() {
193+
this.contextRunner.withPropertyValues("spring.data.cassandra.request.throttler.type=rate-limiting")
194+
.run((context) -> assertThatThrownBy(() -> context.getBean(CqlSession.class))
195+
.hasMessageContaining("Error instantiating class RateLimitingRequestThrottler")
196+
.hasMessageContaining("No configuration setting found for key"));
197+
}
198+
189199
@Test
190200
void driverConfigLoaderCustomizeConcurrencyLimitingRequestThrottler() {
191201
this.contextRunner.withPropertyValues("spring.data.cassandra.request.throttler.type=concurrency-limiting",

0 commit comments

Comments
 (0)