smiklosovic commented on code in PR #4515:
URL: https://github.com/apache/cassandra/pull/4515#discussion_r2594224585
##########
src/java/org/apache/cassandra/service/disk/usage/DiskUsageMonitor.java:
##########
@@ -79,14 +81,28 @@ public void start(Consumer<DiskUsageState> notifier)
{
// start the scheduler regardless guardrail is enabled, so we can
enable it later without a restart
ScheduledExecutors.scheduledTasks.scheduleAtFixedRate(() -> {
-
- if (!Guardrails.localDataDiskUsage.enabled(null))
+ boolean currentEnabledStatus =
Guardrails.localDataDiskUsage.enabled(null);
+ boolean oldEnabledStatus = enabled;
+ enabled = currentEnabledStatus;
+ if (!currentEnabledStatus)
Review Comment:
this `if` is ever entered only in case `currentEnabledStatus` is `false`.
Then you do
if (currentEnabledStatus != oldEnabledStatus)
That means that `currentEnabledStatus` is true, which can not equal to
`oldEnbledStatus`.
That means that in order to call `onDiskUsageGuardrailDisabled` method,
`oldEnabledStatus` has to be `true`.
This can then be simplified to
if (!currentEnabledStatus)
{
if (oldEnabledStatus)
onDiskUsageGuardrailDisabled(notifier);
}
else
updateLocalState(getDiskUsage(), notifier);
Which can be further simplified to
if (!currentEnabledStatus && oldEnabledStatus)
onDiskUsageGuardrailDisabled(notifier);
else
updateLocalState(getDiskUsage(), notifier);
--
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]