Skip to content

Commit 819d941

Browse files
committed
reflected review
1 parent 0b3e688 commit 819d941

File tree

2 files changed

+33
-49
lines changed

2 files changed

+33
-49
lines changed

src/java/org/apache/cassandra/config/DatabaseDescriptor.java

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,11 +1221,21 @@ else if (conf.max_value_size.toMebibytes() >= 2048)
12211221
if (conf.audit_logging_options != null)
12221222
setAuditLoggingOptions(conf.audit_logging_options);
12231223

1224-
// just run through the validation by setting current values back to their setters, so we are sure that their values are valid
1225-
DatabaseDescriptor.setGCLogThreshold((int) DatabaseDescriptor.getGCLogThreshold());
1226-
DatabaseDescriptor.setGCWarnThreshold((int) DatabaseDescriptor.getGCWarnThreshold());
1227-
DatabaseDescriptor.setGCConcurrentPhaseLogThreshold(DatabaseDescriptor.getGCConcurrentPhaseLogThreshold());
1228-
DatabaseDescriptor.setGCConcurrentPhaseWarnThreshold(DatabaseDescriptor.getGCConcurrentPhaseWarnThreshold());
1224+
try
1225+
{
1226+
// Run through the validation by setting current values back to their setters, so we are sure that their values are valid.
1227+
// We are catching IllegalArgumentException and translating it to ConfigurationException to comply with
1228+
// rest of the logic in this method. These setters are also called in GCInspectorMXBean were IllegalArgumentException
1229+
// is thrown when arguments are invalid instead ConfigurationException, on purpose.
1230+
DatabaseDescriptor.setGCLogThreshold((int) DatabaseDescriptor.getGCLogThreshold());
1231+
DatabaseDescriptor.setGCWarnThreshold((int) DatabaseDescriptor.getGCWarnThreshold());
1232+
DatabaseDescriptor.setGCConcurrentPhaseLogThreshold(DatabaseDescriptor.getGCConcurrentPhaseLogThreshold());
1233+
DatabaseDescriptor.setGCConcurrentPhaseWarnThreshold(DatabaseDescriptor.getGCConcurrentPhaseWarnThreshold());
1234+
}
1235+
catch (IllegalArgumentException ex)
1236+
{
1237+
throw new ConfigurationException(ex.getMessage());
1238+
}
12291239
}
12301240

12311241
@VisibleForTesting
@@ -4728,12 +4738,12 @@ public static long getGCLogThreshold()
47284738
public static void setGCLogThreshold(int threshold)
47294739
{
47304740
if (threshold <= 0)
4731-
throw new ConfigurationException("Threshold value for gc_log_threshold must be greater than 0");
4741+
throw new IllegalArgumentException("Threshold value for gc_log_threshold must be greater than 0");
47324742

47334743
long gcWarnThresholdInMs = getGCWarnThreshold();
47344744
if (gcWarnThresholdInMs != 0 && threshold > gcWarnThresholdInMs)
4735-
throw new ConfigurationException("Threshold value for gc_log_threshold (" + threshold + ") must be less than gc_warn_threshold which is currently "
4736-
+ gcWarnThresholdInMs);
4745+
throw new IllegalArgumentException("Threshold value for gc_log_threshold (" + threshold + ") must be less than gc_warn_threshold which is currently "
4746+
+ gcWarnThresholdInMs);
47374747

47384748
conf.gc_log_threshold = new DurationSpec.IntMillisecondsBound(threshold);
47394749
}
@@ -4746,12 +4756,12 @@ public static long getGCWarnThreshold()
47464756
public static void setGCWarnThreshold(int threshold)
47474757
{
47484758
if (threshold < 0)
4749-
throw new ConfigurationException("Threshold value for gc_warn_threshold must be greater than or equal to 0");
4759+
throw new IllegalArgumentException("Threshold value for gc_warn_threshold must be greater than or equal to 0");
47504760

47514761
long gcLogThresholdInMs = getGCLogThreshold();
47524762
if (threshold != 0 && threshold <= gcLogThresholdInMs)
4753-
throw new ConfigurationException("Threshold value for gc_warn_threshold (" + threshold + ") must be greater than gc_log_threshold which is currently "
4754-
+ gcLogThresholdInMs);
4763+
throw new IllegalArgumentException("Threshold value for gc_warn_threshold (" + threshold + ") must be greater than gc_log_threshold which is currently "
4764+
+ gcLogThresholdInMs);
47554765

47564766
conf.gc_warn_threshold = new DurationSpec.IntMillisecondsBound(threshold);
47574767
}
@@ -4764,12 +4774,12 @@ public static int getGCConcurrentPhaseLogThreshold()
47644774
public static void setGCConcurrentPhaseLogThreshold(int threshold)
47654775
{
47664776
if (threshold <= 0)
4767-
throw new ConfigurationException("Threshold must be greater than 0");
4777+
throw new IllegalArgumentException("Threshold must be greater than 0");
47684778

47694779
long gcConcurrentPhaseWarnThresholdInMs = getGCConcurrentPhaseWarnThreshold();
47704780
if (gcConcurrentPhaseWarnThresholdInMs != 0 && threshold > gcConcurrentPhaseWarnThresholdInMs)
4771-
throw new ConfigurationException("Threshold value for gc_concurrent_phase_log_threshold (" + threshold + ") must be less than gc_concurrent_phase_warn_threshold which is currently "
4772-
+ gcConcurrentPhaseWarnThresholdInMs);
4781+
throw new IllegalArgumentException("Threshold value for gc_concurrent_phase_log_threshold (" + threshold + ") must be less than gc_concurrent_phase_warn_threshold which is currently "
4782+
+ gcConcurrentPhaseWarnThresholdInMs);
47734783

47744784
conf.gc_concurrent_phase_log_threshold = new DurationSpec.IntMillisecondsBound(threshold);
47754785
}
@@ -4782,12 +4792,12 @@ public static int getGCConcurrentPhaseWarnThreshold()
47824792
public static void setGCConcurrentPhaseWarnThreshold(int threshold)
47834793
{
47844794
if (threshold < 0)
4785-
throw new ConfigurationException("Threshold value for gc_concurrent_phase_warn_threshold must be greater than or equal to 0");
4795+
throw new IllegalArgumentException("Threshold value for gc_concurrent_phase_warn_threshold must be greater than or equal to 0");
47864796

47874797
long gcConcurrentPhaseLogThresholdInMs = getGCConcurrentPhaseLogThreshold();
47884798
if (threshold != 0 && threshold <= gcConcurrentPhaseLogThresholdInMs)
4789-
throw new ConfigurationException("Threshold value for gc_concurrent_phase_warn_threshold (" + threshold + ") must be greater than gc_concurrent_phase_log_threshold which is currently "
4790-
+ gcConcurrentPhaseLogThresholdInMs);
4799+
throw new IllegalArgumentException("Threshold value for gc_concurrent_phase_warn_threshold (" + threshold + ") must be greater than gc_concurrent_phase_log_threshold which is currently "
4800+
+ gcConcurrentPhaseLogThresholdInMs);
47914801

47924802
conf.gc_concurrent_phase_warn_threshold = new DurationSpec.IntMillisecondsBound(threshold);
47934803
}

src/java/org/apache/cassandra/service/GCInspector.java

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ else if (duration > getGcConcurrentPhaseLogThresholdInMs())
296296
logger.info(sb.toString());
297297
else if (logger.isTraceEnabled())
298298
logger.trace(sb.toString());
299+
299300
if (duration > this.getConcurrentStatusThresholdInMs())
300301
StatusLogger.log();
301302
}
@@ -307,6 +308,7 @@ else if (duration > getGcLogThresholdInMs())
307308
logger.info(sb.toString());
308309
else if (logger.isTraceEnabled())
309310
logger.trace(sb.toString());
311+
310312
if (duration > this.getStatusThresholdInMs())
311313
StatusLogger.log();
312314
}
@@ -409,14 +411,7 @@ private static long getFieldValue(Field field, boolean isAtomicLong)
409411

410412
public void setGcWarnThresholdInMs(long threshold)
411413
{
412-
try
413-
{
414-
DatabaseDescriptor.setGCWarnThreshold((int)threshold);
415-
}
416-
catch (Throwable t)
417-
{
418-
throw new IllegalArgumentException(t.getMessage());
419-
}
414+
DatabaseDescriptor.setGCWarnThreshold((int)threshold);
420415
}
421416

422417
public long getGcWarnThresholdInMs()
@@ -426,14 +421,7 @@ public long getGcWarnThresholdInMs()
426421

427422
public void setGcLogThresholdInMs(long threshold)
428423
{
429-
try
430-
{
431-
DatabaseDescriptor.setGCLogThreshold((int) threshold);
432-
}
433-
catch (Throwable t)
434-
{
435-
throw new IllegalArgumentException(t.getMessage());
436-
}
424+
DatabaseDescriptor.setGCLogThreshold((int) threshold);
437425
}
438426

439427
public int getGcConcurrentPhaseWarnThresholdInMs()
@@ -443,14 +431,7 @@ public int getGcConcurrentPhaseWarnThresholdInMs()
443431

444432
public void setGcConcurrentPhaseWarnThresholdInMs(int threshold)
445433
{
446-
try
447-
{
448-
DatabaseDescriptor.setGCConcurrentPhaseWarnThreshold(threshold);
449-
}
450-
catch (Throwable t)
451-
{
452-
throw new IllegalArgumentException(t.getMessage());
453-
}
434+
DatabaseDescriptor.setGCConcurrentPhaseWarnThreshold(threshold);
454435
}
455436

456437
public int getGcConcurrentPhaseLogThresholdInMs()
@@ -460,14 +441,7 @@ public int getGcConcurrentPhaseLogThresholdInMs()
460441

461442
public void setGcConcurrentPhaseLogThresholdInMs(int threshold)
462443
{
463-
try
464-
{
465-
DatabaseDescriptor.setGCConcurrentPhaseLogThreshold(threshold);
466-
}
467-
catch (Throwable t)
468-
{
469-
throw new IllegalArgumentException(t.getMessage());
470-
}
444+
DatabaseDescriptor.setGCConcurrentPhaseLogThreshold(threshold);
471445
}
472446

473447
public long getGcLogThresholdInMs()

0 commit comments

Comments
 (0)