Skip to content

Commit 29a6c9a

Browse files
committed
JAVA-2331: Use minimum eviction time if set too low
1 parent c2efde3 commit 29a6c9a

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

core/src/main/java/com/datastax/oss/driver/internal/core/metrics/DropwizardMetricsFactory.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ public class DropwizardMetricsFactory implements MetricsFactory {
4848

4949
private static final Logger LOG = LoggerFactory.getLogger(DropwizardMetricsFactory.class);
5050
static final Duration LOWEST_ACCEPTABLE_EXPIRE_AFTER = Duration.ofMinutes(5);
51-
static final Duration DEFAULT_EXPIRE_AFTER = Duration.ofHours(1);
5251

5352
private final String logPrefix;
5453
private final InternalDriverContext context;
@@ -105,12 +104,11 @@ static Duration getAndValidateEvictionTime(DriverExecutionProfile config, String
105104

106105
if (evictionTime.compareTo(LOWEST_ACCEPTABLE_EXPIRE_AFTER) < 0) {
107106
LOG.warn(
108-
"[{}] Value too low for {}: {} (It should be higher than {}). Forcing to {} instead.",
107+
"[{}] Value too low for {}: {}. Forcing to {} instead.",
109108
logPrefix,
110109
DefaultDriverOption.METRICS_NODE_EXPIRE_AFTER.getPath(),
111110
evictionTime,
112-
LOWEST_ACCEPTABLE_EXPIRE_AFTER,
113-
DEFAULT_EXPIRE_AFTER);
111+
LOWEST_ACCEPTABLE_EXPIRE_AFTER);
114112
}
115113

116114
return evictionTime;

core/src/main/resources/reference.conf

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1613,12 +1613,16 @@ datastax-java-driver {
16131613
}
16141614

16151615
# The time after which the node level metrics will be evicted.
1616-
# The eviction will happen only if none of the enabled node-level
1617-
# metrics is updated for a given node for a given time.
1618-
# When this interval elapses, all metrics for the idle node are removed.
1619-
# If you set it to a value lower than 5 minutes, it will be forced to a default 1 hour.
16201616
#
1621-
# Required: no (defaults to 1 hour)
1617+
# This is used to unregister stale metrics if a node leaves the cluster or gets a new address.
1618+
# The eviction will happen only if none of the enabled node-level metrics is updated for a
1619+
# given node for a given time. When this interval elapses, all metrics for the idle node are
1620+
# removed.
1621+
#
1622+
# The lowest allowed value is 5 minutes. If you try to set it lower, the driver will log a
1623+
# warning and use 5 minutes.
1624+
#
1625+
# Required: yes
16221626
# Modifiable at runtime: no
16231627
# Overridable in a profile: no
16241628
expire-after = 1 hour

core/src/test/java/com/datastax/oss/driver/internal/core/metrics/DropwizardMetricsFactoryTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616
package com.datastax.oss.driver.internal.core.metrics;
1717

18-
import static com.datastax.oss.driver.internal.core.metrics.DropwizardMetricsFactory.DEFAULT_EXPIRE_AFTER;
1918
import static com.datastax.oss.driver.internal.core.metrics.DropwizardMetricsFactory.LOWEST_ACCEPTABLE_EXPIRE_AFTER;
2019
import static org.assertj.core.api.Assertions.assertThat;
2120
import static org.mockito.Mockito.mock;
@@ -58,12 +57,11 @@ public void should_log_warning_when_provided_eviction_time_setting_is_too_low()
5857
assertThat(logger.loggingEventCaptor.getValue().getFormattedMessage())
5958
.contains(
6059
String.format(
61-
"[%s] Value too low for %s: %s (It should be higher than %s). Forcing to %s instead.",
60+
"[%s] Value too low for %s: %s. Forcing to %s instead.",
6261
LOG_PREFIX,
6362
DefaultDriverOption.METRICS_NODE_EXPIRE_AFTER.getPath(),
6463
expireAfter,
65-
LOWEST_ACCEPTABLE_EXPIRE_AFTER,
66-
DEFAULT_EXPIRE_AFTER));
64+
LOWEST_ACCEPTABLE_EXPIRE_AFTER));
6765
}
6866

6967
@Test

0 commit comments

Comments
 (0)