This is an automated email from the ASF dual-hosted git repository. dcapwell pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/cassandra.git
The following commit(s) were added to refs/heads/trunk by this push: new 7db3285e7b Migrate track_warnings to more standard naming conventions and use latest configuration types rather than long 7db3285e7b is described below commit 7db3285e7b745e591dc4c405ae9af6c1cddb0c79 Author: David Capwell <dcapw...@apache.org> AuthorDate: Wed Apr 20 15:15:34 2022 -0700 Migrate track_warnings to more standard naming conventions and use latest configuration types rather than long patch by David Capwell; reviewed by Andres de la Peña, Caleb Rackliffe for CASSANDRA-17560 --- CHANGES.txt | 1 + NEWS.txt | 18 ++-- build.xml | 4 +- conf/cassandra.yaml | 35 +++---- ide/idea/workspace.xml | 6 +- src/java/org/apache/cassandra/config/Config.java | 8 +- .../cassandra/config/DatabaseDescriptor.java | 82 ++++++++++------ .../org/apache/cassandra/config/TrackWarnings.java | 108 -------------------- .../org/apache/cassandra/cql3/QueryOptions.java | 75 +++++++------- .../cassandra/cql3/selection/ResultSetBuilder.java | 9 +- .../cassandra/cql3/statements/SelectStatement.java | 14 +-- src/java/org/apache/cassandra/db/ReadCommand.java | 24 ++--- .../org/apache/cassandra/db/RowIndexEntry.java | 31 +++--- ...=> RowIndexEntryReadSizeTooLargeException.java} | 4 +- .../exceptions/TombstoneAbortException.java | 2 +- src/java/org/apache/cassandra/net/ParamType.java | 8 +- .../apache/cassandra/service/StorageService.java | 83 +++++++--------- .../cassandra/service/StorageServiceMBean.java | 34 +++---- .../cassandra/service/reads/ReadCallback.java | 6 +- .../CoordinatorWarnings.java | 9 +- .../WarnAbortCounter.java | 2 +- .../WarningContext.java | 22 ++--- .../WarningsSnapshot.java | 30 +++--- .../org/apache/cassandra/transport/Dispatcher.java | 2 +- test/conf/cassandra.yaml | 19 ++-- .../cassandra/distributed/impl/Coordinator.java | 2 +- .../cassandra/distributed/impl/Instance.java | 2 +- .../distributed/test/NativeMixedVersionTest.java | 7 +- .../AbstractClientSizeWarning.java | 6 +- .../CoordinatorReadSizeWarningTest.java | 7 +- .../LocalReadSizeWarningTest.java | 15 +-- .../RowIndexSizeWarningTest.java | 11 ++- .../TombstoneCountWarningTest.java | 6 +- .../cassandra/config/DatabaseDescriptorTest.java | 109 ++++++++------------- .../config/YamlConfigurationLoaderTest.java | 54 +++++----- .../WarningsSnapshotTest.java | 4 +- 36 files changed, 364 insertions(+), 495 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 0f60d18244..5ab33a229b 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 4.1 + * Migrate track_warnings to more standard naming conventions and use latest configuration types rather than long (CASSANDRA-17560) * Add support for CONTAINS and CONTAINS KEY in conditional UPDATE and DELETE statement (CASSANDRA-10537) * Migrate advanced config parameters to the new Config types (CASSANDRA-17431) * Make null to be meaning disabled and leave 0 as a valid value for permissions_update_interval, roles_update_interval, credentials_update_interval (CASSANDRA-17431) diff --git a/NEWS.txt b/NEWS.txt index 992c291115..7afac5e105 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -89,16 +89,16 @@ New features paxos_state_purging: repaired. Once this has been set across the cluster, users are encouraged to set their applications to supply a Commit consistency level of ANY with their LWT write operations, saving one additional WAN round-trip. See upgrade notes below. - - Warn/abort thresholds added to read queries notifying clients when these thresholds trigger (by - emitting a client warning or aborting the query). This feature is disabled by default, scheduled - to be enabled in 4.2; it is controlled with the configuration track_warnings.enabled, - setting to true will enable this feature. Each check has its own warn/abort thresholds, currently + - Warn/fail thresholds added to read queries notifying clients when these thresholds trigger (by + emitting a client warning or failing the query). This feature is disabled by default, scheduled + to be enabled in 4.2; it is controlled with the configuration read_thresholds_enabled, + setting to true will enable this feature. Each check has its own warn/fail thresholds, currently tombstones (tombstone_warn_threshold, and tombstone_failure_threshold), coordinator result set - materialized size (track_warnings.coordinator_large_read.warn_threshold_kb, and - track_warnings.coordinator_large_read.abort_threshold_kb), local read materialized heap size - (track_warnings.local_read_size.warn_threshold_kb and track_warnings.local_read_size.abort_threshold_kb), - and RowIndexEntry estimated memory size (track_warnings.row_index_size.warn_threshold_kb and - track_warnings.row_index_size.abort_threshold_kb) are supported; more checks will be added over time. + materialized size (coordinator_read_size_warn_threshold and coordinator_read_size_fail_threshold), + local read materialized heap size + (local_read_size_warn_threshold and local_read_size_fail_threshold), + and RowIndexEntry estimated memory size (row_index_read_size_warn_threshold and + row_index_read_size_fail_threshold) are supported; more checks will be added over time. - Prior to this version, the hint system was storing a window of hints as defined by configuration property max_hint_window_in_ms, however this window is not persistent across restarts. For example, if a node is restarted, it will be still eligible for a hint to be sent to it because it diff --git a/build.xml b/build.xml index 44d45bba10..1c20100a5a 100644 --- a/build.xml +++ b/build.xml @@ -891,7 +891,7 @@ <pathelement location="${test.conf}"/> </classpath> <jvmarg value="-Dstorage-config=${test.conf}"/> - <jvmarg value="-Dcassandra.track_warnings.coordinator.defensive_checks_enabled=true" /> <!-- enable defensive checks --> + <jvmarg value="-Dcassandra.reads.thresholds.coordinator.defensive_checks_enabled=true" /> <!-- enable defensive checks --> <jvmarg value="-javaagent:${build.lib}/jamm-${jamm.version}.jar" /> <jvmarg value="-ea"/> <jvmarg line="${java11-jvmargs}"/> @@ -1500,7 +1500,7 @@ <jvmarg value="-Dcassandra.testtag=@{testtag}"/> <jvmarg value="-Dcassandra.keepBriefBrief=${cassandra.keepBriefBrief}" /> <jvmarg value="-Dcassandra.strict.runtime.checks=true" /> - <jvmarg value="-Dcassandra.track_warnings.coordinator.defensive_checks_enabled=true" /> <!-- enable defensive checks --> + <jvmarg value="-Dcassandra.reads.thresholds.coordinator.defensive_checks_enabled=true" /> <!-- enable defensive checks --> <jvmarg line="${java11-jvmargs}"/> <!-- disable shrinks in quicktheories CASSANDRA-15554 --> <jvmarg value="-DQT_SHRINKS=0"/> diff --git a/conf/cassandra.yaml b/conf/cassandra.yaml index e8ebe029ef..c455d45950 100644 --- a/conf/cassandra.yaml +++ b/conf/cassandra.yaml @@ -1575,29 +1575,24 @@ drop_compact_storage_enabled: false # - 127.0.0.1 # - 127.0.0.0/31 -# Enables tracking warnings/aborts across all replicas for reporting back to client. +# Enables read thresholds (warn/fail) across all replicas for reporting back to the client. # See: CASSANDRA-16850 -# track_warnings: -# Scheduled to enable in 4.2 -# enabled: true -# When track_warnings.enabled: true, this tracks the materialized size of a query on the -# coordinator. If coordinator_large_read.warn_threshold_kb is greater than 0, this will emit a warning +# read_thresholds_enabled: false # scheduled to be set true in 4.2 +# When read_thresholds_enabled: true, this tracks the materialized size of a query on the +# coordinator. If coordinator_read_size_warn_threshold is defined, this will emit a warning # to clients with details on what query triggered this as well as the size of the result set; if -# coordinator_large_read.abort_threshold_kb is greater than 0, this will abort the query after it +# coordinator_read_size_fail_threshold is defined, this will fail the query after it # has exceeded this threshold, returning a read error to the user. -# coordinator_read_size: -# warn_threshold_kb: 0 -# abort_threshold_kb: 0 -# When track_warnings.enabled: true, this tracks the size of the local read (as defined by -# heap size), and will warn/abort based off these thresholds; 0 disables these checks. -# local_read_size: -# warn_threshold_kb: 0 -# abort_threshold_kb: 0 -# When track_warnings.enabled: true, this tracks the expected memory size of the RowIndexEntry -# and will warn/abort based off these thresholds; 0 disables these checks. -# row_index_size: -# warn_threshold_kb: 0 -# abort_threshold_kb: 0 +# coordinator_read_size_warn_threshold: +# coordinator_read_size_fail_threshold: +# When read_thresholds_enabled: true, this tracks the size of the local read (as defined by +# heap size), and will warn/fail based off these thresholds; undefined disables these checks. +# local_read_size_warn_threshold: +# local_read_size_fail_threshold: +# When read_thresholds_enabled: true, this tracks the expected memory size of the RowIndexEntry +# and will warn/fail based off these thresholds; undefined disables these checks +# row_index_read_size_warn_threshold: +# row_index_read_size_fail_threshold: # Guardrail to warn or fail when creating more user keyspaces than threshold. # The two thresholds default to -1 to disable. diff --git a/ide/idea/workspace.xml b/ide/idea/workspace.xml index 8a2f4e6937..e35ba90ac7 100644 --- a/ide/idea/workspace.xml +++ b/ide/idea/workspace.xml @@ -143,7 +143,7 @@ <configuration default="true" type="Application" factoryName="Application"> <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" /> <option name="MAIN_CLASS_NAME" value="" /> - <option name="VM_PARAMETERS" value="-Dcassandra.config=file://$PROJECT_DIR$/conf/cassandra.yaml -Dcassandra.storagedir=$PROJECT_DIR$/data -Dlogback.configurationFile=file://$PROJECT_DIR$/conf/logback.xml -Dcassandra.logdir=$PROJECT_DIR$/data/logs -Djava.library.path=$PROJECT_DIR$/lib/sigar-bin -DQT_SHRINKS=0 -ea -Dcassandra.track_warnings.coordinator.defensive_checks_enabled=true" /> + <option name="VM_PARAMETERS" value="-Dcassandra.config=file://$PROJECT_DIR$/conf/cassandra.yaml -Dcassandra.storagedir=$PROJECT_DIR$/data -Dlogback.configurationFile=file://$PROJECT_DIR$/conf/logback.xml -Dcassandra.logdir=$PROJECT_DIR$/data/logs -Djava.library.path=$PROJECT_DIR$/lib/sigar-bin -DQT_SHRINKS=0 -ea -Dcassandra.reads.thresholds.coordinator.defensive_checks_enabled=true" /> <option name="PROGRAM_PARAMETERS" value="" /> <option name="WORKING_DIRECTORY" value="" /> <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" /> @@ -167,7 +167,7 @@ <option name="MAIN_CLASS_NAME" value="" /> <option name="METHOD_NAME" value="" /> <option name="TEST_OBJECT" value="class" /> - <option name="VM_PARAMETERS" value="-Dcassandra.config=file://$PROJECT_DIR$/test/conf/cassandra.yaml -Dlogback.configurationFile=file://$PROJECT_DIR$/test/conf/logback-test.xml -Dcassandra.logdir=$PROJECT_DIR$/build/test/logs -Djava.library.path=$PROJECT_DIR$/lib/sigar-bin -Dlegacy-sstable-root=$PROJECT_DIR$/test/data/legacy-sstables -Dinvalid-legacy-sstable-root=$PROJECT_DIR$/test/data/invalid-legacy-sstables -Dcassandra.ring_delay_ms=1000 -Dcassandra.skip_sync=true -ea -XX:MaxMet [...] + <option name="VM_PARAMETERS" value="-Dcassandra.config=file://$PROJECT_DIR$/test/conf/cassandra.yaml -Dlogback.configurationFile=file://$PROJECT_DIR$/test/conf/logback-test.xml -Dcassandra.logdir=$PROJECT_DIR$/build/test/logs -Djava.library.path=$PROJECT_DIR$/lib/sigar-bin -Dlegacy-sstable-root=$PROJECT_DIR$/test/data/legacy-sstables -Dinvalid-legacy-sstable-root=$PROJECT_DIR$/test/data/invalid-legacy-sstables -Dcassandra.ring_delay_ms=1000 -Dcassandra.skip_sync=true -ea -XX:MaxMet [...] <option name="PARAMETERS" value="" /> <fork_mode value="class" /> <option name="WORKING_DIRECTORY" value="" /> @@ -187,7 +187,7 @@ <configuration default="false" name="Cassandra" type="Application" factoryName="Application"> <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" /> <option name="MAIN_CLASS_NAME" value="org.apache.cassandra.service.CassandraDaemon" /> - <option name="VM_PARAMETERS" value="-Dcassandra-foreground=yes -Dcassandra.config=file://$PROJECT_DIR$/conf/cassandra.yaml -Dcassandra.storagedir=$PROJECT_DIR$/data -Dlogback.configurationFile=file://$PROJECT_DIR$/conf/logback.xml -Dcassandra.logdir=$PROJECT_DIR$/data/logs -Djava.library.path=$PROJECT_DIR$/lib/sigar-bin -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=7199 -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate= [...] + <option name="VM_PARAMETERS" value="-Dcassandra-foreground=yes -Dcassandra.config=file://$PROJECT_DIR$/conf/cassandra.yaml -Dcassandra.storagedir=$PROJECT_DIR$/data -Dlogback.configurationFile=file://$PROJECT_DIR$/conf/logback.xml -Dcassandra.logdir=$PROJECT_DIR$/data/logs -Djava.library.path=$PROJECT_DIR$/lib/sigar-bin -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=7199 -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate= [...] <option name="PROGRAM_PARAMETERS" value="" /> <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" /> <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" /> diff --git a/src/java/org/apache/cassandra/config/Config.java b/src/java/org/apache/cassandra/config/Config.java index eb416aa4cc..58cfbfddfd 100644 --- a/src/java/org/apache/cassandra/config/Config.java +++ b/src/java/org/apache/cassandra/config/Config.java @@ -467,7 +467,13 @@ public class Config public MemtableAllocationType memtable_allocation_type = MemtableAllocationType.heap_buffers; - public final TrackWarnings track_warnings = new TrackWarnings(); + public volatile boolean read_thresholds_enabled = false; + public volatile DataStorageSpec coordinator_read_size_warn_threshold = null; + public volatile DataStorageSpec coordinator_read_size_fail_threshold = null; + public volatile DataStorageSpec local_read_size_warn_threshold = null; + public volatile DataStorageSpec local_read_size_fail_threshold = null; + public volatile DataStorageSpec row_index_read_size_warn_threshold = null; + public volatile DataStorageSpec row_index_read_size_fail_threshold = null; public volatile int tombstone_warn_threshold = 1000; public volatile int tombstone_failure_threshold = 100000; diff --git a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java index e1418fa55f..c1fee6e5c8 100644 --- a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java +++ b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java @@ -687,7 +687,7 @@ public class DatabaseDescriptor applyConcurrentValidations(conf); applyRepairCommandPoolSize(conf); - applyTrackWarningsValidations(conf); + applyReadThresholdsValidations(conf); if (conf.concurrent_materialized_view_builders <= 0) throw new ConfigurationException("concurrent_materialized_view_builders should be strictly greater than 0, but was " + conf.concurrent_materialized_view_builders, false); @@ -906,9 +906,19 @@ public class DatabaseDescriptor } @VisibleForTesting - static void applyTrackWarningsValidations(Config config) + static void applyReadThresholdsValidations(Config config) { - config.track_warnings.validate("track_warnings"); + validateReadThresholds("coordinator_read_size", config.coordinator_read_size_warn_threshold, config.coordinator_read_size_fail_threshold); + validateReadThresholds("local_read_size", config.local_read_size_warn_threshold, config.local_read_size_fail_threshold); + validateReadThresholds("row_index_read_size", config.row_index_read_size_warn_threshold, config.row_index_read_size_fail_threshold); + } + + private static void validateReadThresholds(String name, DataStorageSpec warn, DataStorageSpec fail) + { + if (fail != null && warn != null && fail.toBytes() < warn.toBytes()) + throw new ConfigurationException(String.format("%s (%s) must be greater than or equal to %s (%s)", + name + "_fail_threshold", fail, + name + "_warn_threshold", warn)); } public static GuardrailsOptions getGuardrailsConfig() @@ -3982,74 +3992,84 @@ public class DatabaseDescriptor return conf.internode_error_reporting_exclusions; } - public static boolean getTrackWarningsEnabled() + public static boolean getReadThresholdsEnabled() { - return conf.track_warnings.enabled; + return conf.read_thresholds_enabled; } - public static void setTrackWarningsEnabled(boolean value) + public static void setReadThresholdsEnabled(boolean value) { - conf.track_warnings.enabled = value; + if (conf.read_thresholds_enabled != value) + { + conf.read_thresholds_enabled = value; + logger.info("updated read_thresholds_enabled to {}", value); + } } - public static long getCoordinatorReadSizeWarnThresholdKB() + public static DataStorageSpec getCoordinatorReadSizeWarnThreshold() { - return conf.track_warnings.coordinator_read_size.getWarnThresholdKb(); + return conf.coordinator_read_size_warn_threshold; } - public static void setCoordinatorReadSizeWarnThresholdKB(long threshold) + public static void setCoordinatorReadSizeWarnThreshold(DataStorageSpec value) { - conf.track_warnings.coordinator_read_size.setWarnThresholdKb(threshold); + logger.info("updating coordinator_read_size_warn_threshold to {}", value); + conf.coordinator_read_size_warn_threshold = value; } - public static long getCoordinatorReadSizeAbortThresholdKB() + public static DataStorageSpec getCoordinatorReadSizeFailThreshold() { - return conf.track_warnings.coordinator_read_size.getAbortThresholdKb(); + return conf.coordinator_read_size_fail_threshold; } - public static void setCoordinatorReadSizeAbortThresholdKB(long threshold) + public static void setCoordinatorReadSizeFailThreshold(DataStorageSpec value) { - conf.track_warnings.coordinator_read_size.setAbortThresholdKb(threshold); + logger.info("updating coordinator_read_size_fail_threshold to {}", value); + conf.coordinator_read_size_fail_threshold = value; } - public static long getLocalReadSizeWarnThresholdKb() + public static DataStorageSpec getLocalReadSizeWarnThreshold() { - return conf.track_warnings.local_read_size.getWarnThresholdKb(); + return conf.local_read_size_warn_threshold; } - public static void setLocalReadSizeWarnThresholdKb(long value) + public static void setLocalReadSizeWarnThreshold(DataStorageSpec value) { - conf.track_warnings.local_read_size.setWarnThresholdKb(value); + logger.info("updating local_read_size_warn_threshold to {}", value); + conf.local_read_size_warn_threshold = value; } - public static long getLocalReadSizeAbortThresholdKb() + public static DataStorageSpec getLocalReadSizeFailThreshold() { - return conf.track_warnings.local_read_size.getAbortThresholdKb(); + return conf.local_read_size_fail_threshold; } - public static void setLocalReadSizeAbortThresholdKb(long value) + public static void setLocalReadSizeFailThreshold(DataStorageSpec value) { - conf.track_warnings.local_read_size.setAbortThresholdKb(value); + logger.info("updating local_read_size_fail_threshold to {}", value); + conf.local_read_size_fail_threshold = value; } - public static int getRowIndexSizeWarnThresholdKiB() + public static DataStorageSpec getRowIndexReadSizeWarnThreshold() { - return conf.track_warnings.row_index_size.getWarnThresholdKb(); + return conf.row_index_read_size_warn_threshold; } - public static void setRowIndexSizeWarnThresholdKiB(int value) + public static void setRowIndexReadSizeWarnThreshold(DataStorageSpec value) { - conf.track_warnings.row_index_size.setWarnThresholdKb(value); + logger.info("updating row_index_size_warn_threshold to {}", value); + conf.row_index_read_size_warn_threshold = value; } - public static int getRowIndexSizeAbortThresholdKiB() + public static DataStorageSpec getRowIndexReadSizeFailThreshold() { - return conf.track_warnings.row_index_size.getAbortThresholdKb(); + return conf.row_index_read_size_fail_threshold; } - public static void setRowIndexSizeAbortThresholdKiB(int value) + public static void setRowIndexReadSizeFailThreshold(DataStorageSpec value) { - conf.track_warnings.row_index_size.setAbortThresholdKb(value); + logger.info("updating row_index_read_size_fail_threshold to {}", value); + conf.row_index_read_size_fail_threshold = value; } public static int getDefaultKeyspaceRF() { return conf.default_keyspace_rf; } diff --git a/src/java/org/apache/cassandra/config/TrackWarnings.java b/src/java/org/apache/cassandra/config/TrackWarnings.java deleted file mode 100644 index 77530a8e8b..0000000000 --- a/src/java/org/apache/cassandra/config/TrackWarnings.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.cassandra.config; - -import org.apache.cassandra.exceptions.ConfigurationException; - -public class TrackWarnings -{ - public volatile boolean enabled = false; // should set to true in 4.2 - public final LongByteThreshold coordinator_read_size = new LongByteThreshold(); - public final LongByteThreshold local_read_size = new LongByteThreshold(); - public final IntByteThreshold row_index_size = new IntByteThreshold(); - - public void validate(String prefix) - { - prefix += "."; - coordinator_read_size.validate(prefix + "coordinator_read_size"); - local_read_size.validate(prefix + "local_read_size"); - row_index_size.validate(prefix + "row_index_size"); - } - - public static class LongByteThreshold - { - public volatile long warn_threshold_kb = 0; - public volatile long abort_threshold_kb = 0; - - public long getWarnThresholdKb() - { - return warn_threshold_kb; - } - - public void setWarnThresholdKb(long value) - { - warn_threshold_kb = Math.max(value, 0); - } - - public long getAbortThresholdKb() - { - return abort_threshold_kb; - } - - public void setAbortThresholdKb(long value) - { - abort_threshold_kb = Math.max(value, 0); - } - - public void validate(String prefix) - { - warn_threshold_kb = Math.max(warn_threshold_kb, 0); - abort_threshold_kb = Math.max(abort_threshold_kb, 0); - - if (abort_threshold_kb != 0 && abort_threshold_kb < warn_threshold_kb) - throw new ConfigurationException(String.format("abort_threshold_kb (%d) must be greater than or equal to warn_threshold_kb (%d); see %s", - abort_threshold_kb, warn_threshold_kb, prefix)); - } - } - - public static class IntByteThreshold - { - public volatile int warn_threshold_kb = 0; - public volatile int abort_threshold_kb = 0; - - public int getWarnThresholdKb() - { - return warn_threshold_kb; - } - - public void setWarnThresholdKb(int value) - { - warn_threshold_kb = Math.max(value, 0); - } - - public int getAbortThresholdKb() - { - return abort_threshold_kb; - } - - public void setAbortThresholdKb(int value) - { - abort_threshold_kb = Math.max(value, 0); - } - - public void validate(String prefix) - { - warn_threshold_kb = Math.max(warn_threshold_kb, 0); - abort_threshold_kb = Math.max(abort_threshold_kb, 0); - - if (abort_threshold_kb != 0 && abort_threshold_kb < warn_threshold_kb) - throw new ConfigurationException(String.format("abort_threshold_kb (%d) must be greater than or equal to warn_threshold_kb (%d); see %s", - abort_threshold_kb, warn_threshold_kb, prefix)); - } - } -} diff --git a/src/java/org/apache/cassandra/cql3/QueryOptions.java b/src/java/org/apache/cassandra/cql3/QueryOptions.java index 7b93616c1c..4193c4e15a 100644 --- a/src/java/org/apache/cassandra/cql3/QueryOptions.java +++ b/src/java/org/apache/cassandra/cql3/QueryOptions.java @@ -24,6 +24,8 @@ import com.google.common.collect.ImmutableList; import io.netty.buffer.ByteBuf; +import org.apache.cassandra.config.Config; +import org.apache.cassandra.config.DataStorageSpec; import org.apache.cassandra.config.DatabaseDescriptor; import org.apache.cassandra.schema.ColumnMetadata; import org.apache.cassandra.db.ConsistencyLevel; @@ -228,21 +230,21 @@ public abstract class QueryOptions // Mainly for the sake of BatchQueryOptions abstract SpecificOptions getSpecificOptions(); - abstract TrackWarnings getTrackWarnings(); + abstract ReadThresholds getReadThresholds(); - public boolean isTrackWarningsEnabled() + public boolean isReadThresholdsEnabled() { - return getTrackWarnings().isEnabled(); + return getReadThresholds().isEnabled(); } - public long getCoordinatorReadSizeWarnThresholdKB() + public long getCoordinatorReadSizeWarnThresholdBytes() { - return getTrackWarnings().getCoordinatorReadSizeWarnThresholdKB(); + return getReadThresholds().getCoordinatorReadSizeWarnThresholdBytes(); } - public long getCoordinatorReadSizeAbortThresholdKB() + public long getCoordinatorReadSizeAbortThresholdBytes() { - return getTrackWarnings().getCoordinatorReadSizeAbortThresholdKB(); + return getReadThresholds().getCoordinatorReadSizeFailThresholdBytes(); } public QueryOptions prepare(List<ColumnSpecification> specs) @@ -250,29 +252,24 @@ public abstract class QueryOptions return this; } - interface TrackWarnings + interface ReadThresholds { boolean isEnabled(); - long getCoordinatorReadSizeWarnThresholdKB(); + long getCoordinatorReadSizeWarnThresholdBytes(); - long getCoordinatorReadSizeAbortThresholdKB(); + long getCoordinatorReadSizeFailThresholdBytes(); - static TrackWarnings create() + static ReadThresholds create() { // if daemon initialization hasn't happened yet (very common in tests) then ignore - if (!DatabaseDescriptor.isDaemonInitialized()) - return DisabledTrackWarnings.INSTANCE; - boolean enabled = DatabaseDescriptor.getTrackWarningsEnabled(); - if (!enabled) - return DisabledTrackWarnings.INSTANCE; - long warnThresholdKB = DatabaseDescriptor.getCoordinatorReadSizeWarnThresholdKB(); - long abortThresholdKB = DatabaseDescriptor.getCoordinatorReadSizeAbortThresholdKB(); - return new DefaultTrackWarnings(warnThresholdKB, abortThresholdKB); + if (!DatabaseDescriptor.isDaemonInitialized() || !DatabaseDescriptor.getReadThresholdsEnabled()) + return DisabledReadThresholds.INSTANCE; + return new DefaultReadThresholds(DatabaseDescriptor.getCoordinatorReadSizeWarnThreshold(), DatabaseDescriptor.getCoordinatorReadSizeFailThreshold()); } } - private enum DisabledTrackWarnings implements TrackWarnings + private enum DisabledReadThresholds implements ReadThresholds { INSTANCE; @@ -283,27 +280,27 @@ public abstract class QueryOptions } @Override - public long getCoordinatorReadSizeWarnThresholdKB() + public long getCoordinatorReadSizeWarnThresholdBytes() { - return 0; + return Config.DISABLED_GUARDRAIL; } @Override - public long getCoordinatorReadSizeAbortThresholdKB() + public long getCoordinatorReadSizeFailThresholdBytes() { - return 0; + return Config.DISABLED_GUARDRAIL; } } - private static class DefaultTrackWarnings implements TrackWarnings + private static class DefaultReadThresholds implements ReadThresholds { - private final long warnThresholdKB; - private final long abortThresholdKB; + private final long warnThresholdBytes; + private final long abortThresholdBytes; - public DefaultTrackWarnings(long warnThresholdKB, long abortThresholdKB) + public DefaultReadThresholds(DataStorageSpec warnThreshold, DataStorageSpec abortThreshold) { - this.warnThresholdKB = warnThresholdKB; - this.abortThresholdKB = abortThresholdKB; + this.warnThresholdBytes = warnThreshold == null ? Config.DISABLED_GUARDRAIL : warnThreshold.toBytes(); + this.abortThresholdBytes = abortThreshold == null ? Config.DISABLED_GUARDRAIL : abortThreshold.toBytes(); } @Override @@ -313,15 +310,15 @@ public abstract class QueryOptions } @Override - public long getCoordinatorReadSizeWarnThresholdKB() + public long getCoordinatorReadSizeWarnThresholdBytes() { - return warnThresholdKB; + return warnThresholdBytes; } @Override - public long getCoordinatorReadSizeAbortThresholdKB() + public long getCoordinatorReadSizeFailThresholdBytes() { - return abortThresholdKB; + return abortThresholdBytes; } } @@ -334,7 +331,7 @@ public abstract class QueryOptions private final SpecificOptions options; private final transient ProtocolVersion protocolVersion; - private final transient TrackWarnings trackWarnings = TrackWarnings.create(); + private final transient ReadThresholds readThresholds = ReadThresholds.create(); DefaultQueryOptions(ConsistencyLevel consistency, List<ByteBuffer> values, boolean skipMetadata, SpecificOptions options, ProtocolVersion protocolVersion) { @@ -371,9 +368,9 @@ public abstract class QueryOptions } @Override - TrackWarnings getTrackWarnings() + ReadThresholds getReadThresholds() { - return trackWarnings; + return readThresholds; } } @@ -412,9 +409,9 @@ public abstract class QueryOptions } @Override - TrackWarnings getTrackWarnings() + ReadThresholds getReadThresholds() { - return wrapped.getTrackWarnings(); + return wrapped.getReadThresholds(); } @Override diff --git a/src/java/org/apache/cassandra/cql3/selection/ResultSetBuilder.java b/src/java/org/apache/cassandra/cql3/selection/ResultSetBuilder.java index 9a02a33fc6..cb8c57681a 100644 --- a/src/java/org/apache/cassandra/cql3/selection/ResultSetBuilder.java +++ b/src/java/org/apache/cassandra/cql3/selection/ResultSetBuilder.java @@ -22,6 +22,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import org.apache.cassandra.config.Config; import org.apache.cassandra.cql3.ResultSet; import org.apache.cassandra.cql3.ResultSet.ResultMetadata; import org.apache.cassandra.cql3.selection.Selection.Selectors; @@ -91,9 +92,9 @@ public final class ResultSetBuilder } } - public boolean shouldWarn(long thresholdKB) + public boolean shouldWarn(long thresholdBytes) { - if (thresholdKB > 0 && !sizeWarningEmitted && size > thresholdKB << 10) + if (thresholdBytes != Config.DISABLED_GUARDRAIL &&!sizeWarningEmitted && size > thresholdBytes) { sizeWarningEmitted = true; return true; @@ -101,9 +102,9 @@ public final class ResultSetBuilder return false; } - public boolean shouldReject(long thresholdKB) + public boolean shouldReject(long thresholdBytes) { - return thresholdKB > 0 && size > thresholdKB << 10; + return thresholdBytes != Config.DISABLED_GUARDRAIL && size > thresholdBytes; } public long getSize() diff --git a/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java b/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java index d55a64b951..7bf226b27f 100644 --- a/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java +++ b/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java @@ -251,7 +251,7 @@ public class SelectStatement implements CQLStatement.SingleKeyspaceCqlStatement ReadQuery query = getQuery(options, state.getClientState(), selectors.getColumnFilter(), nowInSec, userLimit, userPerPartitionLimit, pageSize); - if (options.isTrackWarningsEnabled()) + if (options.isReadThresholdsEnabled()) query.trackWarnings(); if (aggregationSpec == null && (pageSize <= 0 || (query.limits().count() <= pageSize))) @@ -880,14 +880,14 @@ public class SelectStatement implements CQLStatement.SingleKeyspaceCqlStatement private void maybeWarn(ResultSetBuilder result, QueryOptions options) { - if (!options.isTrackWarningsEnabled()) + if (!options.isReadThresholdsEnabled()) return; ColumnFamilyStore store = cfs(); if (store != null) store.metric.coordinatorReadSize.update(result.getSize()); - if (result.shouldWarn(options.getCoordinatorReadSizeWarnThresholdKB())) + if (result.shouldWarn(options.getCoordinatorReadSizeWarnThresholdBytes())) { - String msg = String.format("Read on table %s has exceeded the size warning threshold of %,d kb", table, options.getCoordinatorReadSizeWarnThresholdKB()); + String msg = String.format("Read on table %s has exceeded the size warning threshold of %,d bytes", table, options.getCoordinatorReadSizeWarnThresholdBytes()); ClientState state = ClientState.forInternalCalls(); ClientWarn.instance.warn(msg + " with " + loggableTokens(options, state)); logger.warn("{} with query {}", msg, asCQL(options, state)); @@ -898,11 +898,11 @@ public class SelectStatement implements CQLStatement.SingleKeyspaceCqlStatement private void maybeFail(ResultSetBuilder result, QueryOptions options) { - if (!options.isTrackWarningsEnabled()) + if (!options.isReadThresholdsEnabled()) return; - if (result.shouldReject(options.getCoordinatorReadSizeAbortThresholdKB())) + if (result.shouldReject(options.getCoordinatorReadSizeAbortThresholdBytes())) { - String msg = String.format("Read on table %s has exceeded the size failure threshold of %,d kb", table, options.getCoordinatorReadSizeAbortThresholdKB()); + String msg = String.format("Read on table %s has exceeded the size failure threshold of %,d bytes", table, options.getCoordinatorReadSizeAbortThresholdBytes()); ClientState state = ClientState.forInternalCalls(); String clientMsg = msg + " with " + loggableTokens(options, state); ClientWarn.instance.warn(clientMsg); diff --git a/src/java/org/apache/cassandra/db/ReadCommand.java b/src/java/org/apache/cassandra/db/ReadCommand.java index 2ea90eeb65..721aa81080 100644 --- a/src/java/org/apache/cassandra/db/ReadCommand.java +++ b/src/java/org/apache/cassandra/db/ReadCommand.java @@ -560,7 +560,7 @@ public abstract class ReadCommand extends AbstractReadQuery if (trackWarnings) { MessageParams.remove(ParamType.TOMBSTONE_WARNING); - MessageParams.add(ParamType.TOMBSTONE_ABORT, tombstones); + MessageParams.add(ParamType.TOMBSTONE_FAIL, tombstones); } throw new TombstoneOverwhelmingException(tombstones, query, ReadCommand.this.metadata(), currentKey, clustering); } @@ -653,19 +653,21 @@ public abstract class ReadCommand extends AbstractReadQuery } } - private boolean shouldTrackSize(long warnThresholdBytes, long abortThresholdBytes) + private boolean shouldTrackSize(DataStorageSpec warnThresholdBytes, DataStorageSpec abortThresholdBytes) { return trackWarnings && !SchemaConstants.isSystemKeyspace(metadata().keyspace) - && !(warnThresholdBytes == 0 && abortThresholdBytes == 0); + && !(warnThresholdBytes == null && abortThresholdBytes == null); } private UnfilteredPartitionIterator withQuerySizeTracking(UnfilteredPartitionIterator iterator) { - final long warnThresholdBytes = DatabaseDescriptor.getLocalReadSizeWarnThresholdKb() * 1024; - final long abortThresholdBytes = DatabaseDescriptor.getLocalReadSizeAbortThresholdKb() * 1024; - if (!shouldTrackSize(warnThresholdBytes, abortThresholdBytes)) + DataStorageSpec warnThreshold = DatabaseDescriptor.getLocalReadSizeWarnThreshold(); + DataStorageSpec failThreshold = DatabaseDescriptor.getLocalReadSizeFailThreshold(); + if (!shouldTrackSize(warnThreshold, failThreshold)) return iterator; + final long warnBytes = warnThreshold == null ? Config.DISABLED_GUARDRAIL : warnThreshold.toBytes(); + final long failBytes = failThreshold == null ? Config.DISABLED_GUARDRAIL : failThreshold.toBytes(); class QuerySizeTracking extends Transformation<UnfilteredRowIterator> { private long sizeInBytes = 0; @@ -707,16 +709,16 @@ public abstract class ReadCommand extends AbstractReadQuery private void addSize(long size) { this.sizeInBytes += size; - if (abortThresholdBytes != 0 && this.sizeInBytes >= abortThresholdBytes) + if (failBytes != Config.DISABLED_GUARDRAIL && this.sizeInBytes >= failBytes) { - String msg = String.format("Query %s attempted to read %d bytes but max allowed is %d; query aborted (see track_warnings.local_read_size.abort_threshold_kb)", - ReadCommand.this.toCQLString(), this.sizeInBytes, abortThresholdBytes); + String msg = String.format("Query %s attempted to read %d bytes but max allowed is %s; query aborted (see local_read_size_fail_threshold)", + ReadCommand.this.toCQLString(), this.sizeInBytes, failThreshold); Tracing.trace(msg); MessageParams.remove(ParamType.LOCAL_READ_SIZE_WARN); - MessageParams.add(ParamType.LOCAL_READ_SIZE_ABORT, this.sizeInBytes); + MessageParams.add(ParamType.LOCAL_READ_SIZE_FAIL, this.sizeInBytes); throw new LocalReadSizeTooLargeException(msg); } - else if (warnThresholdBytes != 0 && this.sizeInBytes >= warnThresholdBytes) + else if (warnBytes != Config.DISABLED_GUARDRAIL && this.sizeInBytes >= warnBytes) { MessageParams.add(ParamType.LOCAL_READ_SIZE_WARN, this.sizeInBytes); } diff --git a/src/java/org/apache/cassandra/db/RowIndexEntry.java b/src/java/org/apache/cassandra/db/RowIndexEntry.java index f5f632a9df..addeaf82ef 100644 --- a/src/java/org/apache/cassandra/db/RowIndexEntry.java +++ b/src/java/org/apache/cassandra/db/RowIndexEntry.java @@ -23,8 +23,9 @@ import java.util.List; import com.codahale.metrics.Histogram; import org.apache.cassandra.cache.IMeasurableMemory; +import org.apache.cassandra.config.DataStorageSpec; import org.apache.cassandra.config.DatabaseDescriptor; -import org.apache.cassandra.db.filter.RowIndexEntryTooLargeException; +import org.apache.cassandra.db.filter.RowIndexEntryReadSizeTooLargeException; import org.apache.cassandra.io.ISerializer; import org.apache.cassandra.io.sstable.IndexInfo; import org.apache.cassandra.io.sstable.format.Version; @@ -352,12 +353,12 @@ public class RowIndexEntry<T> implements IMeasurableMemory private void checkSize(int entries, int bytes) { ReadCommand command = ReadCommand.getCommand(); - if (command == null || SchemaConstants.isSystemKeyspace(command.metadata().keyspace) || !DatabaseDescriptor.getTrackWarningsEnabled()) + if (command == null || SchemaConstants.isSystemKeyspace(command.metadata().keyspace) || !DatabaseDescriptor.getReadThresholdsEnabled()) return; - int warnThreshold = DatabaseDescriptor.getRowIndexSizeWarnThresholdKiB() * 1024; - int abortThreshold = DatabaseDescriptor.getRowIndexSizeAbortThresholdKiB() * 1024; - if (warnThreshold == 0 && abortThreshold == 0) + DataStorageSpec warnThreshold = DatabaseDescriptor.getRowIndexReadSizeWarnThreshold(); + DataStorageSpec failThreshold = DatabaseDescriptor.getRowIndexReadSizeFailThreshold(); + if (warnThreshold == null && failThreshold == null) return; long estimatedMemory = estimateMaterializedIndexSize(entries, bytes); @@ -365,23 +366,23 @@ public class RowIndexEntry<T> implements IMeasurableMemory if (cfs != null) cfs.metric.rowIndexSize.update(estimatedMemory); - if (abortThreshold != 0 && estimatedMemory > abortThreshold) + if (failThreshold != null && estimatedMemory > failThreshold.toBytes()) { String msg = String.format("Query %s attempted to access a large RowIndexEntry estimated to be %d bytes " + - "in-memory (total entries: %d, total bytes: %d) but the max allowed is %d;" + - " query aborted (see row_index_size_abort_threshold_kb)", - command.toCQLString(), estimatedMemory, entries, bytes, abortThreshold); - MessageParams.remove(ParamType.ROW_INDEX_SIZE_WARN); - MessageParams.add(ParamType.ROW_INDEX_SIZE_ABORT, estimatedMemory); + "in-memory (total entries: %d, total bytes: %d) but the max allowed is %s;" + + " query aborted (see row_index_read_size_fail_threshold)", + command.toCQLString(), estimatedMemory, entries, bytes, failThreshold); + MessageParams.remove(ParamType.ROW_INDEX_READ_SIZE_WARN); + MessageParams.add(ParamType.ROW_INDEX_READ_SIZE_FAIL, estimatedMemory); - throw new RowIndexEntryTooLargeException(msg); + throw new RowIndexEntryReadSizeTooLargeException(msg); } - else if (warnThreshold != 0 && estimatedMemory > warnThreshold) + else if (warnThreshold != null && estimatedMemory > warnThreshold.toBytes()) { // use addIfLarger rather than add as a previous partition may be larger than this one - Long current = MessageParams.get(ParamType.ROW_INDEX_SIZE_WARN); + Long current = MessageParams.get(ParamType.ROW_INDEX_READ_SIZE_WARN); if (current == null || current.compareTo(estimatedMemory) < 0) - MessageParams.add(ParamType.ROW_INDEX_SIZE_WARN, estimatedMemory); + MessageParams.add(ParamType.ROW_INDEX_READ_SIZE_WARN, estimatedMemory); } } diff --git a/src/java/org/apache/cassandra/db/filter/RowIndexEntryTooLargeException.java b/src/java/org/apache/cassandra/db/filter/RowIndexEntryReadSizeTooLargeException.java similarity index 86% rename from src/java/org/apache/cassandra/db/filter/RowIndexEntryTooLargeException.java rename to src/java/org/apache/cassandra/db/filter/RowIndexEntryReadSizeTooLargeException.java index 5f7bfcdf0d..20f3f8f426 100644 --- a/src/java/org/apache/cassandra/db/filter/RowIndexEntryTooLargeException.java +++ b/src/java/org/apache/cassandra/db/filter/RowIndexEntryReadSizeTooLargeException.java @@ -20,9 +20,9 @@ package org.apache.cassandra.db.filter; import org.apache.cassandra.db.RejectException; -public class RowIndexEntryTooLargeException extends RejectException +public class RowIndexEntryReadSizeTooLargeException extends RejectException { - public RowIndexEntryTooLargeException(String message) + public RowIndexEntryReadSizeTooLargeException(String message) { super(message); } diff --git a/src/java/org/apache/cassandra/exceptions/TombstoneAbortException.java b/src/java/org/apache/cassandra/exceptions/TombstoneAbortException.java index ef30ff3f49..833a093f54 100644 --- a/src/java/org/apache/cassandra/exceptions/TombstoneAbortException.java +++ b/src/java/org/apache/cassandra/exceptions/TombstoneAbortException.java @@ -23,7 +23,7 @@ import java.util.Map; import org.apache.cassandra.db.ConsistencyLevel; import org.apache.cassandra.locator.InetAddressAndPort; -import static org.apache.cassandra.service.reads.trackwarnings.WarningsSnapshot.tombstoneAbortMessage; +import static org.apache.cassandra.service.reads.thresholds.WarningsSnapshot.tombstoneAbortMessage; public class TombstoneAbortException extends ReadAbortException { diff --git a/src/java/org/apache/cassandra/net/ParamType.java b/src/java/org/apache/cassandra/net/ParamType.java index 3417d7672d..42222d0412 100644 --- a/src/java/org/apache/cassandra/net/ParamType.java +++ b/src/java/org/apache/cassandra/net/ParamType.java @@ -58,12 +58,12 @@ public enum ParamType @Deprecated TRACK_REPAIRED_DATA (7, "TrackRepaired", LegacyFlag.serializer), - TOMBSTONE_ABORT(8, "TSA", Int32Serializer.serializer), + TOMBSTONE_FAIL(8, "TSF", Int32Serializer.serializer), TOMBSTONE_WARNING(9, "TSW", Int32Serializer.serializer), - LOCAL_READ_SIZE_ABORT(10, "LRSA", Int64Serializer.serializer), + LOCAL_READ_SIZE_FAIL(10, "LRSF", Int64Serializer.serializer), LOCAL_READ_SIZE_WARN(11, "LRSW", Int64Serializer.serializer), - ROW_INDEX_SIZE_ABORT(12, "RISA", Int64Serializer.serializer), - ROW_INDEX_SIZE_WARN(13, "RISW", Int64Serializer.serializer); + ROW_INDEX_READ_SIZE_FAIL(12, "RIRSF", Int64Serializer.serializer), + ROW_INDEX_READ_SIZE_WARN(13, "RIRSW", Int64Serializer.serializer); final int id; @Deprecated final String legacyAlias; // pre-4.0 we used to serialize entire param name string diff --git a/src/java/org/apache/cassandra/service/StorageService.java b/src/java/org/apache/cassandra/service/StorageService.java index d25a7a0f99..0e8b2570fe 100644 --- a/src/java/org/apache/cassandra/service/StorageService.java +++ b/src/java/org/apache/cassandra/service/StorageService.java @@ -63,6 +63,7 @@ import com.google.common.util.concurrent.*; import org.apache.cassandra.config.CassandraRelevantProperties; import org.apache.cassandra.concurrent.*; +import org.apache.cassandra.config.DataStorageSpec; import org.apache.cassandra.cql3.QueryHandler; import org.apache.cassandra.dht.RangeStreamer.FetchReplica; import org.apache.cassandra.fql.FullQueryLogger; @@ -6371,106 +6372,87 @@ public class StorageService extends NotificationBroadcasterSupport implements IE } @Override - public boolean getTrackWarningsEnabled() + public boolean getReadThresholdsEnabled() { - return DatabaseDescriptor.getTrackWarningsEnabled(); + return DatabaseDescriptor.getReadThresholdsEnabled(); } @Override - public void setTrackWarningsEnabled(boolean value) + public void setReadThresholdsEnabled(boolean value) { - DatabaseDescriptor.setTrackWarningsEnabled(value); - logger.info("updated track_warnings.enabled to {}", value); + DatabaseDescriptor.setReadThresholdsEnabled(value); } @Override - public long getCoordinatorLargeReadWarnThresholdKB() + public String getCoordinatorLargeReadWarnThreshold() { - return DatabaseDescriptor.getCoordinatorReadSizeWarnThresholdKB(); + return DatabaseDescriptor.getCoordinatorReadSizeWarnThreshold().toString(); } @Override - public void setCoordinatorLargeReadWarnThresholdKB(long threshold) + public void setCoordinatorLargeReadWarnThreshold(String threshold) { - if (threshold < 0) - throw new IllegalArgumentException("threshold " + threshold + " is less than 0; must be positive or zero"); - DatabaseDescriptor.setCoordinatorReadSizeWarnThresholdKB(threshold); - logger.info("updated track_warnings.coordinator_large_read.warn_threshold_kb to {}", threshold); + DatabaseDescriptor.setCoordinatorReadSizeWarnThreshold(parseDataStorageSpec(threshold)); } @Override - public long getCoordinatorLargeReadAbortThresholdKB() + public String getCoordinatorLargeReadAbortThreshold() { - return DatabaseDescriptor.getCoordinatorReadSizeAbortThresholdKB(); + return DatabaseDescriptor.getCoordinatorReadSizeFailThreshold().toString(); } @Override - public void setCoordinatorLargeReadAbortThresholdKB(long threshold) + public void setCoordinatorLargeReadAbortThreshold(String threshold) { - if (threshold < 0) - throw new IllegalArgumentException("threshold " + threshold + " is less than 0; must be positive or zero"); - DatabaseDescriptor.setCoordinatorReadSizeAbortThresholdKB(threshold); - logger.info("updated track_warnings.coordinator_large_read.abort_threshold_kb to {}", threshold); + DatabaseDescriptor.setCoordinatorReadSizeFailThreshold(parseDataStorageSpec(threshold)); } @Override - public long getLocalReadTooLargeWarnThresholdKb() + public String getLocalReadTooLargeWarnThreshold() { - return DatabaseDescriptor.getLocalReadSizeWarnThresholdKb(); + return DatabaseDescriptor.getLocalReadSizeWarnThreshold().toString(); } @Override - public void setLocalReadTooLargeWarnThresholdKb(long value) + public void setLocalReadTooLargeWarnThreshold(String threshold) { - if (value < 0) - throw new IllegalArgumentException("value " + value + " is less than 0; must be positive or zero"); - DatabaseDescriptor.setLocalReadSizeWarnThresholdKb(value); - logger.info("updated track_warnings.local_read_size.warn_threshold_kb to {}", value); + DatabaseDescriptor.setLocalReadSizeWarnThreshold(parseDataStorageSpec(threshold)); } @Override - public long getLocalReadTooLargeAbortThresholdKb() + public String getLocalReadTooLargeAbortThreshold() { - return DatabaseDescriptor.getLocalReadSizeAbortThresholdKb(); + return DatabaseDescriptor.getLocalReadSizeFailThreshold().toString(); } @Override - public void setLocalReadTooLargeAbortThresholdKb(long value) + public void setLocalReadTooLargeAbortThreshold(String threshold) { - if (value < 0) - throw new IllegalArgumentException("value " + value + " is less than 0; must be positive or zero"); - DatabaseDescriptor.setLocalReadSizeAbortThresholdKb(value); - logger.info("updated track_warnings.local_read_size.abort_threshold_kb to {}", value); + DatabaseDescriptor.setLocalReadSizeFailThreshold(parseDataStorageSpec(threshold)); } @Override - public int getRowIndexSizeWarnThresholdKb() + public String getRowIndexReadSizeWarnThreshold() { - return DatabaseDescriptor.getRowIndexSizeWarnThresholdKiB(); + return DatabaseDescriptor.getRowIndexReadSizeWarnThreshold().toString(); } @Override - public void setRowIndexSizeWarnThresholdKb(int value) + public void setRowIndexReadSizeWarnThreshold(String threshold) { - if (value < 0) - throw new IllegalArgumentException("value " + value + " is less than 0; must be positive or zero"); - DatabaseDescriptor.setRowIndexSizeWarnThresholdKiB(value); - logger.info("updated track_warnings.row_index_size.warn_threshold_kb to {}", value); + DatabaseDescriptor.setRowIndexReadSizeWarnThreshold(parseDataStorageSpec(threshold)); } @Override - public int getRowIndexSizeAbortThresholdKb() + public String getRowIndexReadSizeAbortThreshold() { - return DatabaseDescriptor.getRowIndexSizeAbortThresholdKiB(); + return DatabaseDescriptor.getRowIndexReadSizeFailThreshold().toString(); } @Override - public void setRowIndexSizeAbortThresholdKb(int value) + public void setRowIndexReadSizeAbortThreshold(String threshold) { - if (value < 0) - throw new IllegalArgumentException("value " + value + " is less than 0; must be positive or zero"); - DatabaseDescriptor.setRowIndexSizeAbortThresholdKiB(value); - logger.info("updated track_warnings.row_index_size.abort_threshold_kb to {}", value); + DatabaseDescriptor.setRowIndexReadSizeFailThreshold(parseDataStorageSpec(threshold)); } public void setDefaultKeyspaceReplicationFactor(int value) @@ -6479,6 +6461,13 @@ public class StorageService extends NotificationBroadcasterSupport implements IE logger.info("set default keyspace rf to {}", value); } + private static DataStorageSpec parseDataStorageSpec(String threshold) + { + return threshold == null + ? null + : new DataStorageSpec(threshold); + } + public int getDefaultKeyspaceReplicationFactor() { return DatabaseDescriptor.getDefaultKeyspaceRF(); diff --git a/src/java/org/apache/cassandra/service/StorageServiceMBean.java b/src/java/org/apache/cassandra/service/StorageServiceMBean.java index f789c48dbd..a3267189e1 100644 --- a/src/java/org/apache/cassandra/service/StorageServiceMBean.java +++ b/src/java/org/apache/cassandra/service/StorageServiceMBean.java @@ -920,23 +920,23 @@ public interface StorageServiceMBean extends NotificationEmitter public void setCompactionTombstoneWarningThreshold(int count); public int getCompactionTombstoneWarningThreshold(); - public boolean getTrackWarningsEnabled(); - public void setTrackWarningsEnabled(boolean value); - - public long getCoordinatorLargeReadWarnThresholdKB(); - public void setCoordinatorLargeReadWarnThresholdKB(long threshold); - public long getCoordinatorLargeReadAbortThresholdKB(); - public void setCoordinatorLargeReadAbortThresholdKB(long threshold); - - public long getLocalReadTooLargeWarnThresholdKb(); - public void setLocalReadTooLargeWarnThresholdKb(long value); - public long getLocalReadTooLargeAbortThresholdKb(); - public void setLocalReadTooLargeAbortThresholdKb(long value); - - public int getRowIndexSizeWarnThresholdKb(); - public void setRowIndexSizeWarnThresholdKb(int value); - public int getRowIndexSizeAbortThresholdKb(); - public void setRowIndexSizeAbortThresholdKb(int value); + public boolean getReadThresholdsEnabled(); + public void setReadThresholdsEnabled(boolean value); + + public String getCoordinatorLargeReadWarnThreshold(); + public void setCoordinatorLargeReadWarnThreshold(String threshold); + public String getCoordinatorLargeReadAbortThreshold(); + public void setCoordinatorLargeReadAbortThreshold(String threshold); + + public String getLocalReadTooLargeWarnThreshold(); + public void setLocalReadTooLargeWarnThreshold(String value); + public String getLocalReadTooLargeAbortThreshold(); + public void setLocalReadTooLargeAbortThreshold(String value); + + public String getRowIndexReadSizeWarnThreshold(); + public void setRowIndexReadSizeWarnThreshold(String value); + public String getRowIndexReadSizeAbortThreshold(); + public void setRowIndexReadSizeAbortThreshold(String value); public void setDefaultKeyspaceReplicationFactor(int value); public int getDefaultKeyspaceReplicationFactor(); diff --git a/src/java/org/apache/cassandra/service/reads/ReadCallback.java b/src/java/org/apache/cassandra/service/reads/ReadCallback.java index 9b42296857..e69e6bd2b9 100644 --- a/src/java/org/apache/cassandra/service/reads/ReadCallback.java +++ b/src/java/org/apache/cassandra/service/reads/ReadCallback.java @@ -42,9 +42,9 @@ import org.apache.cassandra.net.Message; import org.apache.cassandra.net.ParamType; import org.apache.cassandra.net.RequestCallback; import org.apache.cassandra.net.Verb; -import org.apache.cassandra.service.reads.trackwarnings.CoordinatorWarnings; -import org.apache.cassandra.service.reads.trackwarnings.WarningContext; -import org.apache.cassandra.service.reads.trackwarnings.WarningsSnapshot; +import org.apache.cassandra.service.reads.thresholds.CoordinatorWarnings; +import org.apache.cassandra.service.reads.thresholds.WarningContext; +import org.apache.cassandra.service.reads.thresholds.WarningsSnapshot; import org.apache.cassandra.tracing.Tracing; import org.apache.cassandra.utils.concurrent.UncheckedInterruptedException; diff --git a/src/java/org/apache/cassandra/service/reads/trackwarnings/CoordinatorWarnings.java b/src/java/org/apache/cassandra/service/reads/thresholds/CoordinatorWarnings.java similarity index 93% rename from src/java/org/apache/cassandra/service/reads/trackwarnings/CoordinatorWarnings.java rename to src/java/org/apache/cassandra/service/reads/thresholds/CoordinatorWarnings.java index 076c8165ca..ff5bd78fa2 100644 --- a/src/java/org/apache/cassandra/service/reads/trackwarnings/CoordinatorWarnings.java +++ b/src/java/org/apache/cassandra/service/reads/thresholds/CoordinatorWarnings.java @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.cassandra.service.reads.trackwarnings; +package org.apache.cassandra.service.reads.thresholds; import java.util.AbstractMap; import java.util.Collections; @@ -32,12 +32,11 @@ import org.apache.cassandra.db.ReadCommand; import org.apache.cassandra.metrics.TableMetrics; import org.apache.cassandra.schema.Schema; import org.apache.cassandra.service.ClientWarn; -import org.apache.cassandra.service.reads.ReadCallback; public class CoordinatorWarnings { private static final Logger logger = LoggerFactory.getLogger(CoordinatorWarnings.class); - private static final boolean ENABLE_DEFENSIVE_CHECKS = Boolean.getBoolean("cassandra.track_warnings.coordinator.defensive_checks_enabled"); + private static final boolean ENABLE_DEFENSIVE_CHECKS = Boolean.getBoolean("cassandra.reads.thresholds.coordinator.defensive_checks_enabled"); // when .init() is called set the STATE to be INIT; this is to lazy allocate the map only when warnings are generated private static final Map<ReadCommand, WarningsSnapshot> INIT = Collections.emptyMap(); @@ -93,8 +92,8 @@ public class CoordinatorWarnings recordAborts(merged.localReadSize, cql, loggableTokens, cfs.metric.localReadSizeAborts, WarningsSnapshot::localReadSizeAbortMessage); recordWarnings(merged.localReadSize, cql, loggableTokens, cfs.metric.localReadSizeWarnings, WarningsSnapshot::localReadSizeWarnMessage); - recordAborts(merged.rowIndexTooSize, cql, loggableTokens, cfs.metric.rowIndexSizeAborts, WarningsSnapshot::rowIndexSizeAbortMessage); - recordWarnings(merged.rowIndexTooSize, cql, loggableTokens, cfs.metric.rowIndexSizeWarnings, WarningsSnapshot::rowIndexSizeWarnMessage); + recordAborts(merged.rowIndexReadSize, cql, loggableTokens, cfs.metric.rowIndexSizeAborts, WarningsSnapshot::rowIndexReadSizeAbortMessage); + recordWarnings(merged.rowIndexReadSize, cql, loggableTokens, cfs.metric.rowIndexSizeWarnings, WarningsSnapshot::rowIndexSizeWarnMessage); }); // reset the state to block from double publishing diff --git a/src/java/org/apache/cassandra/service/reads/trackwarnings/WarnAbortCounter.java b/src/java/org/apache/cassandra/service/reads/thresholds/WarnAbortCounter.java similarity index 97% rename from src/java/org/apache/cassandra/service/reads/trackwarnings/WarnAbortCounter.java rename to src/java/org/apache/cassandra/service/reads/thresholds/WarnAbortCounter.java index 55955c3a47..37a64b8816 100644 --- a/src/java/org/apache/cassandra/service/reads/trackwarnings/WarnAbortCounter.java +++ b/src/java/org/apache/cassandra/service/reads/thresholds/WarnAbortCounter.java @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.cassandra.service.reads.trackwarnings; +package org.apache.cassandra.service.reads.thresholds; import java.util.Collections; import java.util.Set; diff --git a/src/java/org/apache/cassandra/service/reads/trackwarnings/WarningContext.java b/src/java/org/apache/cassandra/service/reads/thresholds/WarningContext.java similarity index 82% rename from src/java/org/apache/cassandra/service/reads/trackwarnings/WarningContext.java rename to src/java/org/apache/cassandra/service/reads/thresholds/WarningContext.java index bbd52cf3f0..1303f9bfdd 100644 --- a/src/java/org/apache/cassandra/service/reads/trackwarnings/WarningContext.java +++ b/src/java/org/apache/cassandra/service/reads/thresholds/WarningContext.java @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.cassandra.service.reads.trackwarnings; +package org.apache.cassandra.service.reads.thresholds; import java.util.Collections; import java.util.EnumSet; @@ -28,13 +28,13 @@ import org.apache.cassandra.net.ParamType; public class WarningContext { - private static EnumSet<ParamType> SUPPORTED = EnumSet.of(ParamType.TOMBSTONE_WARNING, ParamType.TOMBSTONE_ABORT, - ParamType.LOCAL_READ_SIZE_WARN, ParamType.LOCAL_READ_SIZE_ABORT, - ParamType.ROW_INDEX_SIZE_WARN, ParamType.ROW_INDEX_SIZE_ABORT); + private static EnumSet<ParamType> SUPPORTED = EnumSet.of(ParamType.TOMBSTONE_WARNING, ParamType.TOMBSTONE_FAIL, + ParamType.LOCAL_READ_SIZE_WARN, ParamType.LOCAL_READ_SIZE_FAIL, + ParamType.ROW_INDEX_READ_SIZE_WARN, ParamType.ROW_INDEX_READ_SIZE_FAIL); final WarnAbortCounter tombstones = new WarnAbortCounter(); final WarnAbortCounter localReadSize = new WarnAbortCounter(); - final WarnAbortCounter rowIndexTooLarge = new WarnAbortCounter(); + final WarnAbortCounter rowIndexReadSize = new WarnAbortCounter(); public static boolean isSupported(Set<ParamType> keys) { @@ -49,17 +49,17 @@ public class WarningContext RequestFailureReason reason = null; switch (entry.getKey()) { - case ROW_INDEX_SIZE_ABORT: + case ROW_INDEX_READ_SIZE_FAIL: reason = RequestFailureReason.READ_SIZE; - case ROW_INDEX_SIZE_WARN: - counter = rowIndexTooLarge; + case ROW_INDEX_READ_SIZE_WARN: + counter = rowIndexReadSize; break; - case LOCAL_READ_SIZE_ABORT: + case LOCAL_READ_SIZE_FAIL: reason = RequestFailureReason.READ_SIZE; case LOCAL_READ_SIZE_WARN: counter = localReadSize; break; - case TOMBSTONE_ABORT: + case TOMBSTONE_FAIL: reason = RequestFailureReason.READ_TOO_MANY_TOMBSTONES; case TOMBSTONE_WARNING: counter = tombstones; @@ -78,6 +78,6 @@ public class WarningContext public WarningsSnapshot snapshot() { - return WarningsSnapshot.create(tombstones.snapshot(), localReadSize.snapshot(), rowIndexTooLarge.snapshot()); + return WarningsSnapshot.create(tombstones.snapshot(), localReadSize.snapshot(), rowIndexReadSize.snapshot()); } } diff --git a/src/java/org/apache/cassandra/service/reads/trackwarnings/WarningsSnapshot.java b/src/java/org/apache/cassandra/service/reads/thresholds/WarningsSnapshot.java similarity index 90% rename from src/java/org/apache/cassandra/service/reads/trackwarnings/WarningsSnapshot.java rename to src/java/org/apache/cassandra/service/reads/thresholds/WarningsSnapshot.java index 2995e943f9..fddb1e13d8 100644 --- a/src/java/org/apache/cassandra/service/reads/trackwarnings/WarningsSnapshot.java +++ b/src/java/org/apache/cassandra/service/reads/thresholds/WarningsSnapshot.java @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.cassandra.service.reads.trackwarnings; +package org.apache.cassandra.service.reads.thresholds; import java.util.Map; import java.util.Objects; @@ -36,13 +36,13 @@ public class WarningsSnapshot { private static final WarningsSnapshot EMPTY = new WarningsSnapshot(Warnings.EMPTY, Warnings.EMPTY, Warnings.EMPTY); - public final Warnings tombstones, localReadSize, rowIndexTooSize; + public final Warnings tombstones, localReadSize, rowIndexReadSize; - private WarningsSnapshot(Warnings tombstones, Warnings localReadSize, Warnings rowIndexTooSize) + private WarningsSnapshot(Warnings tombstones, Warnings localReadSize, Warnings rowIndexReadSize) { this.tombstones = tombstones; this.localReadSize = localReadSize; - this.rowIndexTooSize = rowIndexTooSize; + this.rowIndexReadSize = rowIndexReadSize; } public static WarningsSnapshot empty() @@ -83,7 +83,7 @@ public class WarningsSnapshot { if (other == null || other == EMPTY) return this; - return WarningsSnapshot.create(tombstones.merge(other.tombstones), localReadSize.merge(other.localReadSize), rowIndexTooSize.merge(other.rowIndexTooSize)); + return WarningsSnapshot.create(tombstones.merge(other.tombstones), localReadSize.merge(other.localReadSize), rowIndexReadSize.merge(other.rowIndexReadSize)); } public void maybeAbort(ReadCommand command, ConsistencyLevel cl, int received, int blockFor, boolean isDataPresent, Map<InetAddressAndPort, RequestFailureReason> failureReasonByEndpoint) @@ -96,8 +96,8 @@ public class WarningsSnapshot throw new ReadSizeAbortException(localReadSizeAbortMessage(localReadSize.aborts.instances.size(), localReadSize.aborts.maxValue, command.toCQLString()), cl, received, blockFor, isDataPresent, failureReasonByEndpoint); - if (!rowIndexTooSize.aborts.instances.isEmpty()) - throw new ReadSizeAbortException(rowIndexSizeAbortMessage(rowIndexTooSize.aborts.instances.size(), rowIndexTooSize.aborts.maxValue, command.toCQLString()), + if (!rowIndexReadSize.aborts.instances.isEmpty()) + throw new ReadSizeAbortException(rowIndexReadSizeAbortMessage(rowIndexReadSize.aborts.instances.size(), rowIndexReadSize.aborts.maxValue, command.toCQLString()), cl, received, blockFor, isDataPresent, failureReasonByEndpoint); } @@ -116,25 +116,25 @@ public class WarningsSnapshot @VisibleForTesting public static String localReadSizeAbortMessage(long nodes, long bytes, String cql) { - return String.format("%s nodes loaded over %s bytes and aborted the query %s (see track_warnings.local_read_size.abort_threshold_kb)", nodes, bytes, cql); + return String.format("%s nodes loaded over %s bytes and aborted the query %s (see local_read_size_fail_threshold)", nodes, bytes, cql); } @VisibleForTesting public static String localReadSizeWarnMessage(int nodes, long bytes, String cql) { - return String.format("%s nodes loaded over %s bytes and issued local read size warnings for query %s (see track_warnings.local_read_size.warn_threshold_kb)", nodes, bytes, cql); + return String.format("%s nodes loaded over %s bytes and issued local read size warnings for query %s (see local_read_size_warn_threshold)", nodes, bytes, cql); } @VisibleForTesting - public static String rowIndexSizeAbortMessage(long nodes, long bytes, String cql) + public static String rowIndexReadSizeAbortMessage(long nodes, long bytes, String cql) { - return String.format("%s nodes loaded over %s bytes in RowIndexEntry and aborted the query %s (see track_warnings.row_index_size.abort_threshold_kb)", nodes, bytes, cql); + return String.format("%s nodes loaded over %s bytes in RowIndexEntry and aborted the query %s (see row_index_size_fail_threshold)", nodes, bytes, cql); } @VisibleForTesting public static String rowIndexSizeWarnMessage(int nodes, long bytes, String cql) { - return String.format("%s nodes loaded over %s bytes in RowIndexEntry and issued warnings for query %s (see track_warnings.row_index_size.warn_threshold_kb)", nodes, bytes, cql); + return String.format("%s nodes loaded over %s bytes in RowIndexEntry and issued warnings for query %s (see row_index_size_warn_threshold)", nodes, bytes, cql); } @Override @@ -143,19 +143,19 @@ public class WarningsSnapshot if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; WarningsSnapshot that = (WarningsSnapshot) o; - return Objects.equals(tombstones, that.tombstones) && Objects.equals(localReadSize, that.localReadSize) && Objects.equals(rowIndexTooSize, that.rowIndexTooSize); + return Objects.equals(tombstones, that.tombstones) && Objects.equals(localReadSize, that.localReadSize) && Objects.equals(rowIndexReadSize, that.rowIndexReadSize); } @Override public int hashCode() { - return Objects.hash(tombstones, localReadSize, rowIndexTooSize); + return Objects.hash(tombstones, localReadSize, rowIndexReadSize); } @Override public String toString() { - return "(tombstones=" + tombstones + ", localReadSize=" + localReadSize + ", rowIndexTooLarge=" + rowIndexTooSize + ')'; + return "(tombstones=" + tombstones + ", localReadSize=" + localReadSize + ", rowIndexTooLarge=" + rowIndexReadSize + ')'; } public static final class Warnings diff --git a/src/java/org/apache/cassandra/transport/Dispatcher.java b/src/java/org/apache/cassandra/transport/Dispatcher.java index 45addcf7ab..da79c3d2c4 100644 --- a/src/java/org/apache/cassandra/transport/Dispatcher.java +++ b/src/java/org/apache/cassandra/transport/Dispatcher.java @@ -36,7 +36,7 @@ import org.apache.cassandra.config.DatabaseDescriptor; import org.apache.cassandra.net.FrameEncoder; import org.apache.cassandra.service.ClientWarn; import org.apache.cassandra.service.QueryState; -import org.apache.cassandra.service.reads.trackwarnings.CoordinatorWarnings; +import org.apache.cassandra.service.reads.thresholds.CoordinatorWarnings; import org.apache.cassandra.transport.ClientResourceLimits.Overload; import org.apache.cassandra.transport.Flusher.FlushItem; import org.apache.cassandra.transport.messages.ErrorMessage; diff --git a/test/conf/cassandra.yaml b/test/conf/cassandra.yaml index 58afdb932f..764379c7f9 100644 --- a/test/conf/cassandra.yaml +++ b/test/conf/cassandra.yaml @@ -53,14 +53,11 @@ materialized_views_enabled: true drop_compact_storage_enabled: true file_cache_enabled: true auto_hints_cleanup_enabled: true -track_warnings: - enabled: true - coordinator_read_size: - warn_threshold_kb: 1024 - abort_threshold_kb: 4096 - local_read_size: - warn_threshold_kb: 4096 - abort_threshold_kb: 8192 - row_index_size: - warn_threshold_kb: 4096 - abort_threshold_kb: 8192 + +read_thresholds_enabled: true +coordinator_read_size_warn_threshold: 1024KiB +coordinator_read_size_fail_threshold: 4096KiB +local_read_size_warn_threshold: 4096KiB +local_read_size_fail_threshold: 8192KiB +row_index_read_size_warn_threshold: 4096KiB +row_index_read_size_fail_threshold: 8192KiB diff --git a/test/distributed/org/apache/cassandra/distributed/impl/Coordinator.java b/test/distributed/org/apache/cassandra/distributed/impl/Coordinator.java index 980ee19973..19d80626d3 100644 --- a/test/distributed/org/apache/cassandra/distributed/impl/Coordinator.java +++ b/test/distributed/org/apache/cassandra/distributed/impl/Coordinator.java @@ -42,7 +42,7 @@ import org.apache.cassandra.distributed.api.SimpleQueryResult; import org.apache.cassandra.service.ClientState; import org.apache.cassandra.service.ClientWarn; import org.apache.cassandra.service.QueryState; -import org.apache.cassandra.service.reads.trackwarnings.CoordinatorWarnings; +import org.apache.cassandra.service.reads.thresholds.CoordinatorWarnings; import org.apache.cassandra.transport.ProtocolVersion; import org.apache.cassandra.tracing.Tracing; import org.apache.cassandra.transport.messages.ResultMessage; diff --git a/test/distributed/org/apache/cassandra/distributed/impl/Instance.java b/test/distributed/org/apache/cassandra/distributed/impl/Instance.java index e283bb6476..aa178dad69 100644 --- a/test/distributed/org/apache/cassandra/distributed/impl/Instance.java +++ b/test/distributed/org/apache/cassandra/distributed/impl/Instance.java @@ -120,7 +120,7 @@ import org.apache.cassandra.service.StorageService; import org.apache.cassandra.service.StorageServiceMBean; import org.apache.cassandra.service.paxos.PaxosRepair; import org.apache.cassandra.service.paxos.PaxosState; -import org.apache.cassandra.service.reads.trackwarnings.CoordinatorWarnings; +import org.apache.cassandra.service.reads.thresholds.CoordinatorWarnings; import org.apache.cassandra.service.snapshot.SnapshotManager; import org.apache.cassandra.streaming.StreamManager; import org.apache.cassandra.service.paxos.uncommitted.UncommittedTableData; diff --git a/test/distributed/org/apache/cassandra/distributed/test/NativeMixedVersionTest.java b/test/distributed/org/apache/cassandra/distributed/test/NativeMixedVersionTest.java index b2391e388b..26d0186504 100644 --- a/test/distributed/org/apache/cassandra/distributed/test/NativeMixedVersionTest.java +++ b/test/distributed/org/apache/cassandra/distributed/test/NativeMixedVersionTest.java @@ -22,7 +22,6 @@ import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; import java.util.List; -import com.google.common.collect.ImmutableMap; import org.junit.Test; import com.datastax.driver.core.ProtocolVersion; @@ -44,10 +43,8 @@ public class NativeMixedVersionTest extends TestBaseImpl try (Cluster cluster = Cluster.build(1) .withConfig(c -> c.with(Feature.values()) - .set("track_warnings", ImmutableMap.of( - "enabled", true, - "local_read_size", ImmutableMap.of("warn_threshold_kb", 1) - )) + .set("read_thresholds_enabled", true) + .set("local_read_size_warn_threshold", "1KiB") ) .start()) { diff --git a/test/distributed/org/apache/cassandra/distributed/test/trackwarnings/AbstractClientSizeWarning.java b/test/distributed/org/apache/cassandra/distributed/test/thresholds/AbstractClientSizeWarning.java similarity index 98% rename from test/distributed/org/apache/cassandra/distributed/test/trackwarnings/AbstractClientSizeWarning.java rename to test/distributed/org/apache/cassandra/distributed/test/thresholds/AbstractClientSizeWarning.java index 34b2322a89..2355403cb1 100644 --- a/test/distributed/org/apache/cassandra/distributed/test/trackwarnings/AbstractClientSizeWarning.java +++ b/test/distributed/org/apache/cassandra/distributed/test/thresholds/AbstractClientSizeWarning.java @@ -16,7 +16,7 @@ * limitations under the License. */ -package org.apache.cassandra.distributed.test.trackwarnings; +package org.apache.cassandra.distributed.test.thresholds; import java.io.IOException; import java.net.InetAddress; @@ -51,7 +51,7 @@ import org.apache.cassandra.exceptions.ReadSizeAbortException; import org.apache.cassandra.exceptions.RequestFailureReason; import org.apache.cassandra.service.ClientWarn; import org.apache.cassandra.service.QueryState; -import org.apache.cassandra.service.reads.trackwarnings.CoordinatorWarnings; +import org.apache.cassandra.service.reads.thresholds.CoordinatorWarnings; import org.assertj.core.api.Condition; import static org.assertj.core.api.Assertions.assertThat; @@ -319,7 +319,7 @@ public abstract class AbstractClientSizeWarning extends TestBaseImpl protected static void enable(boolean value) { - CLUSTER.stream().forEach(i -> i.runOnInstance(() -> DatabaseDescriptor.setTrackWarningsEnabled(value))); + CLUSTER.stream().forEach(i -> i.runOnInstance(() -> DatabaseDescriptor.setReadThresholdsEnabled(value))); } protected static ByteBuffer bytes(int size) diff --git a/test/distributed/org/apache/cassandra/distributed/test/trackwarnings/CoordinatorReadSizeWarningTest.java b/test/distributed/org/apache/cassandra/distributed/test/thresholds/CoordinatorReadSizeWarningTest.java similarity index 92% rename from test/distributed/org/apache/cassandra/distributed/test/trackwarnings/CoordinatorReadSizeWarningTest.java rename to test/distributed/org/apache/cassandra/distributed/test/thresholds/CoordinatorReadSizeWarningTest.java index 523220d866..a1fad44ae7 100644 --- a/test/distributed/org/apache/cassandra/distributed/test/trackwarnings/CoordinatorReadSizeWarningTest.java +++ b/test/distributed/org/apache/cassandra/distributed/test/thresholds/CoordinatorReadSizeWarningTest.java @@ -16,13 +16,14 @@ * limitations under the License. */ -package org.apache.cassandra.distributed.test.trackwarnings; +package org.apache.cassandra.distributed.test.thresholds; import java.io.IOException; import java.util.List; import org.junit.*; +import org.apache.cassandra.config.DataStorageSpec; import org.apache.cassandra.config.DatabaseDescriptor; import static org.assertj.core.api.Assertions.assertThat; @@ -41,8 +42,8 @@ public class CoordinatorReadSizeWarningTest extends AbstractClientSizeWarning // setup threshold after init to avoid driver issues loading // the test uses a rather small limit, which causes driver to fail while loading metadata CLUSTER.stream().forEach(i -> i.runOnInstance(() -> { - DatabaseDescriptor.setCoordinatorReadSizeWarnThresholdKB(1); - DatabaseDescriptor.setCoordinatorReadSizeAbortThresholdKB(2); + DatabaseDescriptor.setCoordinatorReadSizeWarnThreshold(DataStorageSpec.inKibibytes(1)); + DatabaseDescriptor.setCoordinatorReadSizeFailThreshold(DataStorageSpec.inKibibytes(2)); })); } diff --git a/test/distributed/org/apache/cassandra/distributed/test/trackwarnings/LocalReadSizeWarningTest.java b/test/distributed/org/apache/cassandra/distributed/test/thresholds/LocalReadSizeWarningTest.java similarity index 79% rename from test/distributed/org/apache/cassandra/distributed/test/trackwarnings/LocalReadSizeWarningTest.java rename to test/distributed/org/apache/cassandra/distributed/test/thresholds/LocalReadSizeWarningTest.java index 8060bd5ee5..2c5e45b2f3 100644 --- a/test/distributed/org/apache/cassandra/distributed/test/trackwarnings/LocalReadSizeWarningTest.java +++ b/test/distributed/org/apache/cassandra/distributed/test/thresholds/LocalReadSizeWarningTest.java @@ -16,13 +16,14 @@ * limitations under the License. */ -package org.apache.cassandra.distributed.test.trackwarnings; +package org.apache.cassandra.distributed.test.thresholds; import java.io.IOException; import java.util.List; import org.junit.BeforeClass; +import org.apache.cassandra.config.DataStorageSpec; import org.apache.cassandra.config.DatabaseDescriptor; import static org.assertj.core.api.Assertions.assertThat; @@ -38,11 +39,11 @@ public class LocalReadSizeWarningTest extends AbstractClientSizeWarning // the test uses a rather small limit, which causes driver to fail while loading metadata CLUSTER.stream().forEach(i -> i.runOnInstance(() -> { // disable coordinator version - DatabaseDescriptor.setCoordinatorReadSizeWarnThresholdKB(0); - DatabaseDescriptor.setCoordinatorReadSizeAbortThresholdKB(0); + DatabaseDescriptor.setCoordinatorReadSizeWarnThreshold(null); + DatabaseDescriptor.setCoordinatorReadSizeFailThreshold(null); - DatabaseDescriptor.setLocalReadSizeWarnThresholdKb(1); - DatabaseDescriptor.setLocalReadSizeAbortThresholdKb(2); + DatabaseDescriptor.setLocalReadSizeWarnThreshold(DataStorageSpec.inKibibytes(1)); + DatabaseDescriptor.setLocalReadSizeFailThreshold(DataStorageSpec.inKibibytes(2)); })); } @@ -50,14 +51,14 @@ public class LocalReadSizeWarningTest extends AbstractClientSizeWarning protected void assertWarnings(List<String> warnings) { assertThat(warnings).hasSize(1); - assertThat(warnings.get(0)).contains("(see track_warnings.local_read_size.warn_threshold_kb)").contains("and issued local read size warnings for query"); + assertThat(warnings.get(0)).contains("(see local_read_size_warn_threshold)").contains("and issued local read size warnings for query"); } @Override protected void assertAbortWarnings(List<String> warnings) { assertThat(warnings).hasSize(1); - assertThat(warnings.get(0)).contains("(see track_warnings.local_read_size.abort_threshold_kb)").contains("aborted the query"); + assertThat(warnings.get(0)).contains("(see local_read_size_fail_threshold)").contains("aborted the query"); } @Override diff --git a/test/distributed/org/apache/cassandra/distributed/test/trackwarnings/RowIndexSizeWarningTest.java b/test/distributed/org/apache/cassandra/distributed/test/thresholds/RowIndexSizeWarningTest.java similarity index 85% rename from test/distributed/org/apache/cassandra/distributed/test/trackwarnings/RowIndexSizeWarningTest.java rename to test/distributed/org/apache/cassandra/distributed/test/thresholds/RowIndexSizeWarningTest.java index 43f3061329..513f00de4b 100644 --- a/test/distributed/org/apache/cassandra/distributed/test/trackwarnings/RowIndexSizeWarningTest.java +++ b/test/distributed/org/apache/cassandra/distributed/test/thresholds/RowIndexSizeWarningTest.java @@ -16,7 +16,7 @@ * limitations under the License. */ -package org.apache.cassandra.distributed.test.trackwarnings; +package org.apache.cassandra.distributed.test.thresholds; import java.io.IOException; import java.util.List; @@ -24,6 +24,7 @@ import java.util.List; import org.junit.Assume; import org.junit.BeforeClass; +import org.apache.cassandra.config.DataStorageSpec; import org.apache.cassandra.config.DatabaseDescriptor; import static org.assertj.core.api.Assertions.assertThat; @@ -36,8 +37,8 @@ public class RowIndexSizeWarningTest extends AbstractClientSizeWarning AbstractClientSizeWarning.setupClass(); CLUSTER.stream().forEach(i -> i.runOnInstance(() -> { - DatabaseDescriptor.setRowIndexSizeWarnThresholdKiB(1); - DatabaseDescriptor.setRowIndexSizeAbortThresholdKiB(2); + DatabaseDescriptor.setRowIndexReadSizeWarnThreshold(DataStorageSpec.inKibibytes(1)); + DatabaseDescriptor.setRowIndexReadSizeFailThreshold(DataStorageSpec.inKibibytes(2)); // hack to force multiple index entries DatabaseDescriptor.setColumnIndexCacheSize(1 << 20); @@ -99,14 +100,14 @@ public class RowIndexSizeWarningTest extends AbstractClientSizeWarning protected void assertWarnings(List<String> warnings) { assertThat(warnings).hasSize(1); - assertThat(warnings.get(0)).contains("(see track_warnings.row_index_size.warn_threshold_kb)").contains("bytes in RowIndexEntry and issued warnings for query"); + assertThat(warnings.get(0)).contains("(see row_index_size_warn_threshold)").contains("bytes in RowIndexEntry and issued warnings for query"); } @Override protected void assertAbortWarnings(List<String> warnings) { assertThat(warnings).hasSize(1); - assertThat(warnings.get(0)).contains("(see track_warnings.row_index_size.abort_threshold_kb)").contains("bytes in RowIndexEntry and aborted the query"); + assertThat(warnings.get(0)).contains("(see row_index_size_fail_threshold)").contains("bytes in RowIndexEntry and aborted the query"); } @Override diff --git a/test/distributed/org/apache/cassandra/distributed/test/trackwarnings/TombstoneCountWarningTest.java b/test/distributed/org/apache/cassandra/distributed/test/thresholds/TombstoneCountWarningTest.java similarity index 98% rename from test/distributed/org/apache/cassandra/distributed/test/trackwarnings/TombstoneCountWarningTest.java rename to test/distributed/org/apache/cassandra/distributed/test/thresholds/TombstoneCountWarningTest.java index 66bd60d5e7..04668a9589 100644 --- a/test/distributed/org/apache/cassandra/distributed/test/trackwarnings/TombstoneCountWarningTest.java +++ b/test/distributed/org/apache/cassandra/distributed/test/thresholds/TombstoneCountWarningTest.java @@ -16,7 +16,7 @@ * limitations under the License. */ -package org.apache.cassandra.distributed.test.trackwarnings; +package org.apache.cassandra.distributed.test.thresholds; import java.io.IOException; import java.net.InetAddress; @@ -51,7 +51,7 @@ import org.apache.cassandra.exceptions.RequestFailureReason; import org.apache.cassandra.exceptions.TombstoneAbortException; import org.apache.cassandra.service.ClientWarn; import org.apache.cassandra.service.QueryState; -import org.apache.cassandra.service.reads.trackwarnings.CoordinatorWarnings; +import org.apache.cassandra.service.reads.thresholds.CoordinatorWarnings; import org.assertj.core.api.Assertions; import org.assertj.core.api.Condition; @@ -96,7 +96,7 @@ public class TombstoneCountWarningTest extends TestBaseImpl private static void enable(boolean value) { - CLUSTER.stream().forEach(i -> i.runOnInstance(() -> DatabaseDescriptor.setTrackWarningsEnabled(value))); + CLUSTER.stream().forEach(i -> i.runOnInstance(() -> DatabaseDescriptor.setReadThresholdsEnabled(value))); } @Test diff --git a/test/unit/org/apache/cassandra/config/DatabaseDescriptorTest.java b/test/unit/org/apache/cassandra/config/DatabaseDescriptorTest.java index 1c7cf0a945..aedaf49991 100644 --- a/test/unit/org/apache/cassandra/config/DatabaseDescriptorTest.java +++ b/test/unit/org/apache/cassandra/config/DatabaseDescriptorTest.java @@ -621,153 +621,122 @@ public class DatabaseDescriptorTest } // coordinator read - @Test - public void testClientLargeReadWarnAndAbortNegative() - { - Config conf = new Config(); - conf.track_warnings.coordinator_read_size.warn_threshold_kb = -2; - conf.track_warnings.coordinator_read_size.abort_threshold_kb = -2; - DatabaseDescriptor.applyTrackWarningsValidations(conf); - Assertions.assertThat(conf.track_warnings.coordinator_read_size.warn_threshold_kb).isEqualTo(0); - Assertions.assertThat(conf.track_warnings.coordinator_read_size.abort_threshold_kb).isEqualTo(0); - } - @Test public void testClientLargeReadWarnGreaterThanAbort() { Config conf = new Config(); - conf.track_warnings.coordinator_read_size.warn_threshold_kb = 2; - conf.track_warnings.coordinator_read_size.abort_threshold_kb = 1; - Assertions.assertThatThrownBy(() -> DatabaseDescriptor.applyTrackWarningsValidations(conf)) + conf.coordinator_read_size_warn_threshold = DataStorageSpec.inKibibytes(2); + conf.coordinator_read_size_fail_threshold = DataStorageSpec.inKibibytes(1); + Assertions.assertThatThrownBy(() -> DatabaseDescriptor.applyReadThresholdsValidations(conf)) .isInstanceOf(ConfigurationException.class) - .hasMessage("abort_threshold_kb (1) must be greater than or equal to warn_threshold_kb (2); see track_warnings.coordinator_read_size"); + .hasMessage("coordinator_read_size_fail_threshold (1KiB) must be greater than or equal to coordinator_read_size_warn_threshold (2KiB)"); } @Test public void testClientLargeReadWarnEqAbort() { Config conf = new Config(); - conf.track_warnings.coordinator_read_size.warn_threshold_kb = 2; - conf.track_warnings.coordinator_read_size.abort_threshold_kb = 2; - DatabaseDescriptor.applyTrackWarningsValidations(conf); + conf.coordinator_read_size_warn_threshold = DataStorageSpec.inKibibytes(2); + conf.coordinator_read_size_fail_threshold = DataStorageSpec.inKibibytes(2); + DatabaseDescriptor.applyReadThresholdsValidations(conf); } @Test public void testClientLargeReadWarnEnabledAbortDisabled() { Config conf = new Config(); - conf.track_warnings.coordinator_read_size.warn_threshold_kb = 2; - conf.track_warnings.coordinator_read_size.abort_threshold_kb = 0; - DatabaseDescriptor.applyTrackWarningsValidations(conf); + conf.coordinator_read_size_warn_threshold = DataStorageSpec.inKibibytes(2); + conf.coordinator_read_size_fail_threshold = null; + DatabaseDescriptor.applyReadThresholdsValidations(conf); } @Test public void testClientLargeReadAbortEnabledWarnDisabled() { Config conf = new Config(); - conf.track_warnings.coordinator_read_size.warn_threshold_kb = 0; - conf.track_warnings.coordinator_read_size.abort_threshold_kb = 2; - DatabaseDescriptor.applyTrackWarningsValidations(conf); + conf.coordinator_read_size_warn_threshold = DataStorageSpec.inKibibytes(0); + conf.coordinator_read_size_fail_threshold = DataStorageSpec.inKibibytes(2); + DatabaseDescriptor.applyReadThresholdsValidations(conf); } // local read - @Test - public void testLocalLargeReadWarnAndAbortNegative() - { - Config conf = new Config(); - conf.track_warnings.local_read_size.warn_threshold_kb = -2; - conf.track_warnings.local_read_size.abort_threshold_kb = -2; - DatabaseDescriptor.applyTrackWarningsValidations(conf); - Assertions.assertThat(conf.track_warnings.local_read_size.warn_threshold_kb).isEqualTo(0); - Assertions.assertThat(conf.track_warnings.local_read_size.abort_threshold_kb).isEqualTo(0); - } @Test public void testLocalLargeReadWarnGreaterThanAbort() { Config conf = new Config(); - conf.track_warnings.local_read_size.warn_threshold_kb = 2; - conf.track_warnings.local_read_size.abort_threshold_kb = 1; - Assertions.assertThatThrownBy(() -> DatabaseDescriptor.applyTrackWarningsValidations(conf)) + conf.local_read_size_warn_threshold = DataStorageSpec.inKibibytes(2); + conf.local_read_size_fail_threshold = DataStorageSpec.inKibibytes(1); + Assertions.assertThatThrownBy(() -> DatabaseDescriptor.applyReadThresholdsValidations(conf)) .isInstanceOf(ConfigurationException.class) - .hasMessage("abort_threshold_kb (1) must be greater than or equal to warn_threshold_kb (2); see track_warnings.local_read_size"); + .hasMessage("local_read_size_fail_threshold (1KiB) must be greater than or equal to local_read_size_warn_threshold (2KiB)"); } @Test public void testLocalLargeReadWarnEqAbort() { Config conf = new Config(); - conf.track_warnings.local_read_size.warn_threshold_kb = 2; - conf.track_warnings.local_read_size.abort_threshold_kb = 2; - DatabaseDescriptor.applyTrackWarningsValidations(conf); + conf.local_read_size_warn_threshold = DataStorageSpec.inKibibytes(2); + conf.local_read_size_fail_threshold = DataStorageSpec.inKibibytes(2); + DatabaseDescriptor.applyReadThresholdsValidations(conf); } @Test public void testLocalLargeReadWarnEnabledAbortDisabled() { Config conf = new Config(); - conf.track_warnings.local_read_size.warn_threshold_kb = 2; - conf.track_warnings.local_read_size.abort_threshold_kb = 0; - DatabaseDescriptor.applyTrackWarningsValidations(conf); + conf.local_read_size_warn_threshold = DataStorageSpec.inKibibytes(2); + conf.local_read_size_fail_threshold = null; + DatabaseDescriptor.applyReadThresholdsValidations(conf); } @Test public void testLocalLargeReadAbortEnabledWarnDisabled() { Config conf = new Config(); - conf.track_warnings.local_read_size.warn_threshold_kb = 0; - conf.track_warnings.local_read_size.abort_threshold_kb = 2; - DatabaseDescriptor.applyTrackWarningsValidations(conf); + conf.local_read_size_warn_threshold = DataStorageSpec.inKibibytes(0); + conf.local_read_size_fail_threshold = DataStorageSpec.inKibibytes(2); + DatabaseDescriptor.applyReadThresholdsValidations(conf); } // row index entry - @Test - public void testRowIndexSizeWarnAndAbortNegative() - { - Config conf = new Config(); - conf.track_warnings.row_index_size.warn_threshold_kb = -2; - conf.track_warnings.row_index_size.abort_threshold_kb = -2; - DatabaseDescriptor.applyTrackWarningsValidations(conf); - Assertions.assertThat(conf.track_warnings.row_index_size.warn_threshold_kb).isEqualTo(0); - Assertions.assertThat(conf.track_warnings.row_index_size.abort_threshold_kb).isEqualTo(0); - } @Test public void testRowIndexSizeWarnGreaterThanAbort() { Config conf = new Config(); - conf.track_warnings.row_index_size.warn_threshold_kb = 2; - conf.track_warnings.row_index_size.abort_threshold_kb = 1; - Assertions.assertThatThrownBy(() -> DatabaseDescriptor.applyTrackWarningsValidations(conf)) + conf.row_index_read_size_warn_threshold = DataStorageSpec.inKibibytes(2); + conf.row_index_read_size_fail_threshold = DataStorageSpec.inKibibytes(1); + Assertions.assertThatThrownBy(() -> DatabaseDescriptor.applyReadThresholdsValidations(conf)) .isInstanceOf(ConfigurationException.class) - .hasMessage("abort_threshold_kb (1) must be greater than or equal to warn_threshold_kb (2); see track_warnings.row_index_size"); + .hasMessage("row_index_read_size_fail_threshold (1KiB) must be greater than or equal to row_index_read_size_warn_threshold (2KiB)"); } @Test public void testRowIndexSizeWarnEqAbort() { Config conf = new Config(); - conf.track_warnings.row_index_size.warn_threshold_kb = 2; - conf.track_warnings.row_index_size.abort_threshold_kb = 2; - DatabaseDescriptor.applyTrackWarningsValidations(conf); + conf.row_index_read_size_warn_threshold = DataStorageSpec.inKibibytes(2); + conf.row_index_read_size_fail_threshold = DataStorageSpec.inKibibytes(2); + DatabaseDescriptor.applyReadThresholdsValidations(conf); } @Test public void testRowIndexSizeWarnEnabledAbortDisabled() { Config conf = new Config(); - conf.track_warnings.row_index_size.warn_threshold_kb = 2; - conf.track_warnings.row_index_size.abort_threshold_kb = 0; - DatabaseDescriptor.applyTrackWarningsValidations(conf); + conf.row_index_read_size_warn_threshold = DataStorageSpec.inKibibytes(2); + conf.row_index_read_size_fail_threshold = null; + DatabaseDescriptor.applyReadThresholdsValidations(conf); } @Test public void testRowIndexSizeAbortEnabledWarnDisabled() { Config conf = new Config(); - conf.track_warnings.row_index_size.warn_threshold_kb = 0; - conf.track_warnings.row_index_size.abort_threshold_kb = 2; - DatabaseDescriptor.applyTrackWarningsValidations(conf); + conf.row_index_read_size_warn_threshold = DataStorageSpec.inKibibytes(0); + conf.row_index_read_size_fail_threshold = DataStorageSpec.inKibibytes(2); + DatabaseDescriptor.applyReadThresholdsValidations(conf); } @Test diff --git a/test/unit/org/apache/cassandra/config/YamlConfigurationLoaderTest.java b/test/unit/org/apache/cassandra/config/YamlConfigurationLoaderTest.java index 1fc13dd8d5..321315313b 100644 --- a/test/unit/org/apache/cassandra/config/YamlConfigurationLoaderTest.java +++ b/test/unit/org/apache/cassandra/config/YamlConfigurationLoaderTest.java @@ -38,45 +38,45 @@ import static org.junit.Assert.assertEquals; public class YamlConfigurationLoaderTest { @Test - public void trackWarningsFromConfig() + public void readThresholdsFromConfig() { - // this test just makes sure snakeyaml loads the test config properly and populates the fields (track warnings uses final in some places) - // if the config is changed, its ok to update this test to reflect that change - TrackWarnings tw = load("test/conf/cassandra.yaml").track_warnings; - assertThat(tw.enabled).isTrue(); + Config c = load("test/conf/cassandra.yaml"); - assertThat(tw.coordinator_read_size.warn_threshold_kb).isGreaterThan(0); - assertThat(tw.coordinator_read_size.abort_threshold_kb).isGreaterThan(0); + assertThat(c.read_thresholds_enabled).isTrue(); - assertThat(tw.local_read_size.warn_threshold_kb).isGreaterThan(0); - assertThat(tw.local_read_size.abort_threshold_kb).isGreaterThan(0); + assertThat(c.coordinator_read_size_warn_threshold).isEqualTo(DataStorageSpec.inKibibytes(1 << 10)); + assertThat(c.coordinator_read_size_fail_threshold).isEqualTo(DataStorageSpec.inKibibytes(1 << 12)); - assertThat(tw.row_index_size.warn_threshold_kb).isGreaterThan(0); - assertThat(tw.row_index_size.abort_threshold_kb).isGreaterThan(0); + assertThat(c.local_read_size_warn_threshold).isEqualTo(DataStorageSpec.inKibibytes(1 << 12)); + assertThat(c.local_read_size_fail_threshold).isEqualTo(DataStorageSpec.inKibibytes(1 << 13)); + + assertThat(c.row_index_read_size_warn_threshold).isEqualTo(DataStorageSpec.inKibibytes(1 << 12)); + assertThat(c.row_index_read_size_fail_threshold).isEqualTo(DataStorageSpec.inKibibytes(1 << 13)); } @Test - public void trackWarningsFromMap() + public void readThresholdsFromMap() { - Map<String, Object> map = ImmutableMap.of("track_warnings", ImmutableMap.of( - "enabled", true, - "coordinator_read_size", ImmutableMap.of("warn_threshold_kb", 1024), - "local_read_size", ImmutableMap.of("abort_threshold_kb", 1024), - "row_index_size", ImmutableMap.of("warn_threshold_kb", 1024, "abort_threshold_kb", 1024) - )); - Config config = YamlConfigurationLoader.fromMap(map, Config.class); - TrackWarnings tw = config.track_warnings; - assertThat(tw.enabled).isTrue(); + Map<String, Object> map = ImmutableMap.of( + "read_thresholds_enabled", true, + "coordinator_read_size_warn_threshold", "1024KiB", + "local_read_size_fail_threshold", "1024KiB", + "row_index_read_size_warn_threshold", "1024KiB", + "row_index_read_size_fail_threshold", "1024KiB" + ); + + Config c = YamlConfigurationLoader.fromMap(map, Config.class); + assertThat(c.read_thresholds_enabled).isTrue(); - assertThat(tw.coordinator_read_size.warn_threshold_kb).isEqualTo(1024); - assertThat(tw.coordinator_read_size.abort_threshold_kb).isEqualTo(0); + assertThat(c.coordinator_read_size_warn_threshold).isEqualTo(DataStorageSpec.inKibibytes(1024)); + assertThat(c.coordinator_read_size_fail_threshold).isNull(); - assertThat(tw.local_read_size.warn_threshold_kb).isEqualTo(0); - assertThat(tw.local_read_size.abort_threshold_kb).isEqualTo(1024); + assertThat(c.local_read_size_warn_threshold).isNull(); + assertThat(c.local_read_size_fail_threshold).isEqualTo(DataStorageSpec.inKibibytes(1024)); - assertThat(tw.row_index_size.warn_threshold_kb).isEqualTo(1024); - assertThat(tw.row_index_size.abort_threshold_kb).isEqualTo(1024); + assertThat(c.row_index_read_size_warn_threshold).isEqualTo(DataStorageSpec.inKibibytes(1024)); + assertThat(c.row_index_read_size_fail_threshold).isEqualTo(DataStorageSpec.inKibibytes(1024)); } @Test diff --git a/test/unit/org/apache/cassandra/service/reads/trackwarnings/WarningsSnapshotTest.java b/test/unit/org/apache/cassandra/service/reads/thresholds/WarningsSnapshotTest.java similarity index 98% rename from test/unit/org/apache/cassandra/service/reads/trackwarnings/WarningsSnapshotTest.java rename to test/unit/org/apache/cassandra/service/reads/thresholds/WarningsSnapshotTest.java index f9428d8446..2102b0ba1c 100644 --- a/test/unit/org/apache/cassandra/service/reads/trackwarnings/WarningsSnapshotTest.java +++ b/test/unit/org/apache/cassandra/service/reads/thresholds/WarningsSnapshotTest.java @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.cassandra.service.reads.trackwarnings; +package org.apache.cassandra.service.reads.thresholds; import java.net.InetAddress; import java.net.UnknownHostException; @@ -28,7 +28,7 @@ import org.quicktheories.core.Gen; import org.quicktheories.generators.SourceDSL; import org.quicktheories.impl.Constraint; -import static org.apache.cassandra.service.reads.trackwarnings.WarningsSnapshot.*; +import static org.apache.cassandra.service.reads.thresholds.WarningsSnapshot.*; import static org.assertj.core.api.Assertions.assertThat; import static org.quicktheories.QuickTheory.qt; --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org