jmckenzie-dev commented on code in PR #3696:
URL: https://github.com/apache/cassandra/pull/3696#discussion_r2733755643
##########
src/java/org/apache/cassandra/config/DatabaseDescriptor.java:
##########
@@ -4769,27 +4769,67 @@ public static long getGCLogThreshold()
public static void setGCLogThreshold(int threshold)
{
- if (threshold <= 0)
- throw new IllegalArgumentException("Threshold value for
gc_log_threshold must be greater than 0");
+ validateGCParams(threshold, getGCWarnThreshold());
+ conf.gc_log_threshold = new
DurationSpec.IntMillisecondsBound(threshold);
+ }
- long gcWarnThresholdInMs = getGCWarnThreshold();
- if (gcWarnThresholdInMs != 0 && threshold > gcWarnThresholdInMs)
- throw new IllegalArgumentException("Threshold value for
gc_log_threshold (" + threshold + ") must be less than gc_warn_threshold which
is currently "
- + gcWarnThresholdInMs);
+ public static void validateGCParams(long logThreshold, long warnThreshold)
+ {
+ if (logThreshold <= 0)
+ throw new IllegalArgumentException("Threshold value for
gc_log*_threshold must be greater than 0");
+ if (logThreshold > Integer.MAX_VALUE)
+ throw new IllegalArgumentException("Threshold value for
gc_log*_threshold must be less than Integer.MAX_VALUE");
+
+ if (warnThreshold <= 0)
+ throw new IllegalArgumentException("Threshold value for
gc_warn*_threshold must be greater than 0");
+ if (warnThreshold > Integer.MAX_VALUE)
+ throw new IllegalArgumentException("Threshold value for
gc_warn*_threshold must be less than Integer.MAX_VALUE");
+
+ if (warnThreshold != 0 && logThreshold > warnThreshold)
+ throw new IllegalArgumentException("Threshold value for
gc_log*_threshold (" + logThreshold + ") must be less than gc_warn*_threshold
which is currently "
+ + warnThreshold);
+ }
+
+ public static long getZGCLogThreshold()
+ {
+ return conf.gc_log_zgc_threshold.toMilliseconds();
+ }
+
+ public static void setZGCLogThreshold(long threshold)
+ {
+ validateGCParams(threshold, getZGCWarnThreshold());
+ conf.gc_log_zgc_threshold = new
DurationSpec.IntMillisecondsBound(threshold);
+ }
+
+ public static long getGCPauseLogThreshold()
+ {
+ return conf.gc_pause_log_threshold.toMilliseconds();
+ }
+
+ public static void setGCPauseLogThreshold(long threshold)
+ {
+ conf.gc_pause_log_threshold = new
DurationSpec.IntMillisecondsBound(threshold);
+ }
+
+ public static EncryptionContext getEncryptionContext()
+ {
+ return encryptionContext;
- conf.gc_log_threshold = new
DurationSpec.IntMillisecondsBound(threshold);
}
public static long getGCWarnThreshold()
{
return conf.gc_warn_threshold.toMilliseconds();
}
- public static void setGCWarnThreshold(int threshold)
+ public static void setGCWarnThreshold(long threshold)
{
if (threshold < 0)
throw new IllegalArgumentException("Threshold value for
gc_warn_threshold must be greater than or equal to 0");
+ if (threshold > Integer.MAX_VALUE)
+ throw new IllegalArgumentException("Threshold must be less than
Integer.MAX_VALUE");
Review Comment:
The int to long conversion predates this patch; I just kind of "When in
Rome'ed" it.
```
DatabaseDescriptor.setGCLogThreshold((int)
DatabaseDescriptor.getGCLogThreshold());
DatabaseDescriptor.setGCWarnThreshold((int)
DatabaseDescriptor.getGCWarnThreshold());
```
I could dig around a bit to try and figure out why these return a long -
comes from JJirsa in 2016. My guess is that we didn't want to change the type
but _did_ want to sanity check and constrain the values to permissible ranges,
but I'm not sure tbh.
--
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]