adelapena commented on code in PR #2246:
URL: https://github.com/apache/cassandra/pull/2246#discussion_r1158398043
##########
src/java/org/apache/cassandra/config/GuardrailsOptions.java:
##########
@@ -760,6 +762,82 @@ public void setZeroTTLOnTWCSEnabled(boolean value)
x -> config.zero_ttl_on_twcs_enabled = x);
}
+ @Override
+ public long getMaximumTimestampWarnThreshold(long currentTimestamp)
+ {
+ long configVal =
config.maximum_timestamp_warn_threshold.toMicroseconds();
+ return configVal == 0 ? Long.MAX_VALUE : currentTimestamp + configVal;
+ }
+
+ @Override
+ public void
setMaximumTimestampWarnThreshold(DurationSpec.LongMicrosecondsBound duration)
+ {
+ if (duration.toMicroseconds() != 0)
+ validateTimestampThreshold(config.maximum_timestamp_warn_threshold,
+
config.maximum_timestamp_fail_threshold, "maximum_timestamp");
+ updatePropertyWithLogging("maximum_timestamp_warn_threshold",
+ duration,
+ () ->
config.maximum_timestamp_warn_threshold,
+ x -> config.maximum_timestamp_warn_threshold
= x);
+ }
+
+ @Override
+ public long getMaximumTimestampFailThreshold(long currentTimestamp)
+ {
+ long configVal =
config.maximum_timestamp_fail_threshold.toMicroseconds();
+ return configVal == 0 ? Long.MAX_VALUE : currentTimestamp + configVal;
+ }
+
+ @Override
+ public void
setMaximumTimestampFailThreshold(DurationSpec.LongMicrosecondsBound duration)
+ {
+ if (duration.toMicroseconds() != 0)
+ validateTimestampThreshold(config.maximum_timestamp_warn_threshold,
+
config.maximum_timestamp_fail_threshold, "maximum_timestamp");
Review Comment:
This isn't validating the new duration argument, but the previous values. So
the following test will wrongly pass:
```java
guardrails().setMaximumTimestampFailThreshold(1);
guardrails().setMaximumTimestampWarnThreshold(2);
```
Same for the other three setters. Also, there isn't any test verifying the
behaviour of this validation.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]