Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/java/org/apache/cassandra/config/DatabaseDescriptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import com.google.common.util.concurrent.RateLimiter;
import com.googlecode.concurrenttrees.common.Iterables;

import org.apache.cassandra.cql3.QueryOptions;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
Expand Down Expand Up @@ -267,6 +268,8 @@ public class DatabaseDescriptor

public static volatile boolean allowUnlimitedConcurrentValidations = ALLOW_UNLIMITED_CONCURRENT_VALIDATIONS.getBoolean();

private static volatile QueryOptions.DefaultReadThresholds defaultReadThresholds;

/**
* The configuration for guardrails.
*/
Expand Down Expand Up @@ -5452,6 +5455,14 @@ public static boolean getInvalidLegacyProtocolMagicNoSpamEnabled()
return conf.invalid_legacy_protocol_magic_no_spam_enabled;
}

public static QueryOptions.DefaultReadThresholds getDefaultReadThresholds()
{
if (defaultReadThresholds == null)
defaultReadThresholds = new QueryOptions.DefaultReadThresholds(getCoordinatorReadSizeWarnThreshold(),
getCoordinatorReadSizeFailThreshold());
return defaultReadThresholds;
}

public static boolean getReadThresholdsEnabled()
{
return conf.read_thresholds_enabled;
Expand All @@ -5476,6 +5487,7 @@ public static void setCoordinatorReadSizeWarnThreshold(@Nullable DataStorageSpec
{
logger.info("updating coordinator_read_size_warn_threshold to {}", value);
conf.coordinator_read_size_warn_threshold = value;
defaultReadThresholds = new QueryOptions.DefaultReadThresholds(value, getCoordinatorReadSizeFailThreshold());
}

@Nullable
Expand All @@ -5488,6 +5500,7 @@ public static void setCoordinatorReadSizeFailThreshold(@Nullable DataStorageSpec
{
logger.info("updating coordinator_read_size_fail_threshold to {}", value);
conf.coordinator_read_size_fail_threshold = value;
defaultReadThresholds = new QueryOptions.DefaultReadThresholds(getCoordinatorReadSizeWarnThreshold(), value);
}

@Nullable
Expand Down
4 changes: 2 additions & 2 deletions src/java/org/apache/cassandra/cql3/QueryOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ static ReadThresholds create()
// if daemon initialization hasn't happened yet (very common in tests) then ignore
if (!DatabaseDescriptor.isDaemonInitialized() || !DatabaseDescriptor.getReadThresholdsEnabled())
return DisabledReadThresholds.INSTANCE;
return new DefaultReadThresholds(DatabaseDescriptor.getCoordinatorReadSizeWarnThreshold(), DatabaseDescriptor.getCoordinatorReadSizeFailThreshold());
return DatabaseDescriptor.getDefaultReadThresholds();
}
}

Expand All @@ -349,7 +349,7 @@ public long getCoordinatorReadSizeFailThresholdBytes()
}
}

private static class DefaultReadThresholds implements ReadThresholds
public static class DefaultReadThresholds implements ReadThresholds
{
private final long warnThresholdBytes;
private final long abortThresholdBytes;
Expand Down