From 1315d0c96f4625a76296f58d431f97669e5178c2 Mon Sep 17 00:00:00 2001
From: Ekaterina Dimitrova
Date: Thu, 3 Feb 2022 22:28:41 -0500
Subject: [PATCH] Transfer parameters to the newly introduced configuration
framework (5) patch by Ekaterina Dimitrova; reviewed by Caleb Rackliffe,
David Capwell, Michael Semb Wever and Benjamin Lerer for CASSANDRA-15234
---
conf/cassandra.yaml | 40 +--
.../org/apache/cassandra/config/Config.java | 79 +++--
.../cassandra/config/DatabaseDescriptor.java | 272 ++++++++++--------
.../config/SmallestDataStorageMebibytes.java | 11 +
.../cql3/statements/BatchStatement.java | 4 +-
.../org/apache/cassandra/db/ColumnIndex.java | 12 +-
.../org/apache/cassandra/db/Memtable.java | 4 +-
.../apache/cassandra/db/RowIndexEntry.java | 16 +-
.../cassandra/db/marshal/AbstractType.java | 2 +-
.../cassandra/io/sstable/IndexInfo.java | 2 +-
.../apache/cassandra/io/util/FileUtils.java | 10 +-
.../cassandra/repair/ValidationManager.java | 2 +-
.../service/ActiveRepairService.java | 20 +-
.../service/ActiveRepairServiceMBean.java | 5 +
.../cassandra/service/StorageService.java | 18 +-
.../cassandra/streaming/StreamSession.java | 2 +-
.../tools/nodetool/GetColumnIndexSize.java | 2 +-
.../tools/nodetool/SetColumnIndexSize.java | 6 +-
test/conf/cassandra-murmur.yaml | 2 +-
test/conf/cassandra-old.yaml | 3 +-
...slcontextfactory-invalidconfiguration.yaml | 2 +-
test/conf/cassandra-sslcontextfactory.yaml | 2 +-
.../conf/unit-test-conf/test-native-port.yaml | 2 +-
.../distributed/impl/InstanceConfig.java | 2 +-
.../distributed/test/LargeColumnTest.java | 8 +-
.../simulator/ClusterSimulation.java | 2 +-
.../config/DatabaseDescriptorTest.java | 39 +--
.../LoadOldYAMLBackwardCompatibilityTest.java | 13 +-
.../config/YamlConfigurationLoaderTest.java | 8 +-
.../db/compaction/CompactionsCQLTest.java | 6 +-
.../io/sstable/SSTableWriterTestBase.java | 2 +-
.../cassandra/repair/ValidatorTest.java | 16 +-
.../cassandra/service/ClientWarningsTest.java | 2 +-
.../service/ProtocolBetaVersionTest.java | 2 +-
.../nodetool/SetGetColumnIndexSizeTest.java | 12 +-
.../transport/CQLConnectionTest.java | 4 +-
36 files changed, 365 insertions(+), 269 deletions(-)
diff --git a/conf/cassandra.yaml b/conf/cassandra.yaml
index 3d8168bf8e..0c4acb8fc1 100644
--- a/conf/cassandra.yaml
+++ b/conf/cassandra.yaml
@@ -582,8 +582,8 @@ concurrent_materialized_view_writes: 32
# accepting writes when the limit is exceeded until a flush completes,
# and will trigger a flush based on memtable_cleanup_threshold
# If omitted, Cassandra will set both to 1/4 the size of the heap.
-# memtable_heap_space_in_mb: 2048
-# memtable_offheap_space_in_mb: 2048
+# memtable_heap_space: 2048MiB
+# memtable_offheap_space: 2048MiB
# memtable_cleanup_threshold is deprecated. The default calculation
# is the only reasonable choice. See the comments on memtable_flush_writers
@@ -620,7 +620,7 @@ memtable_allocation_type: heap_buffers
#
# For more details see https://issues.apache.org/jira/browse/CASSANDRA-14096.
#
-# repair_session_space_in_mb:
+# repair_session_space:
# Total space to use for commit logs on disk.
#
@@ -771,7 +771,7 @@ native_transport_port: 9042
# The maximum size of allowed frame. Frame (requests) larger than this will
# be rejected as invalid. The default is 16MB. If you're changing this parameter,
# you may want to adjust max_value_size_in_mb accordingly. This should be positive and less than 2048.
-# native_transport_max_frame_size_in_mb: 16
+# native_transport_max_frame_size: 16MiB
# The maximum number of concurrent client connections.
# The default is -1, which means unlimited.
@@ -836,7 +836,7 @@ rpc_keepalive: true
# /proc/sys/net/ipv4/tcp_wmem
# /proc/sys/net/ipv4/tcp_wmem
# and 'man tcp'
-# internode_socket_send_buffer_size_in_bytes:
+# internode_socket_send_buffer_size:
# Uncomment to set socket buffer size for internode communication
# Note that when setting this, the buffer size is limited by net.core.wmem_max
@@ -878,7 +878,7 @@ snapshot_links_per_second: 0
# - but, Cassandra will keep the collation index in memory for hot
# rows (as part of the key cache), so a larger granularity means
# you can cache more hot rows
-column_index_size_in_kb: 64
+column_index_size: 64KiB
# Per sstable indexed key cache entries (the collation index in memory
# mentioned above) exceeding this size will not be held on heap.
@@ -887,7 +887,7 @@ column_index_size_in_kb: 64
#
# Note that this size refers to the size of the
# serialized index information and not the size of the partition.
-column_index_cache_size_in_kb: 2
+column_index_cache_size: 2KiB
# Number of simultaneous compactions to allow, NOT including
# validation "compactions" for anti-entropy repair. Simultaneous
@@ -1011,17 +1011,17 @@ request_timeout: 10000ms
# See (CASSANDRA-14358) for details.
#
# The amount of time to wait for internode tcp connections to establish.
-# internode_tcp_connect_timeout_in_ms: 2000
+# internode_tcp_connect_timeout: 2000ms
#
# The amount of time unacknowledged data is allowed on a connection before we throw out the connection
# Note this is only supported on Linux + epoll, and it appears to behave oddly above a setting of 30000
# (it takes much longer than 30s) as of Linux 4.12. If you want something that high set this to 0
# which picks up the OS default and configure the net.ipv4.tcp_retries2 sysctl to be ~8.
-# internode_tcp_user_timeout_in_ms: 30000
+# internode_tcp_user_timeout: 30000ms
# The amount of time unacknowledged data is allowed on a streaming connection.
# The default is 5 minutes. Increase it or set it to 0 in order to increase the timeout.
-# internode_streaming_tcp_user_timeout_in_ms: 300000
+# internode_streaming_tcp_user_timeout: 300000ms
# Global, per-endpoint and per-connection limits imposed on messages queued for delivery to other nodes
# and waiting to be processed on arrival from other nodes in the cluster. These limits are applied to the on-wire
@@ -1029,7 +1029,7 @@ request_timeout: 10000ms
#
# The basic per-link limit is consumed in isolation before any endpoint or global limit is imposed.
# Each node-pair has three links: urgent, small and large. So any given node may have a maximum of
-# N*3*(internode_application_send_queue_capacity_in_bytes+internode_application_receive_queue_capacity_in_bytes)
+# N*3*(internode_application_send_queue_capacity+internode_application_receive_queue_capacity)
# messages queued without any coordination between them although in practice, with token-aware routing, only RF*tokens
# nodes should need to communicate with significant bandwidth.
#
@@ -1038,12 +1038,12 @@ request_timeout: 10000ms
# The global limit is imposed on all messages exceeding the per-link limit, simultaneously with the per-endpoint limit,
# on all links to or from any node in the cluster.
#
-# internode_application_send_queue_capacity_in_bytes: 4194304 #4MiB
-# internode_application_send_queue_reserve_endpoint_capacity_in_bytes: 134217728 #128MiB
-# internode_application_send_queue_reserve_global_capacity_in_bytes: 536870912 #512MiB
-# internode_application_receive_queue_capacity_in_bytes: 4194304 #4MiB
-# internode_application_receive_queue_reserve_endpoint_capacity_in_bytes: 134217728 #128MiB
-# internode_application_receive_queue_reserve_global_capacity_in_bytes: 536870912 #512MiB
+# internode_application_send_queue_capacity: 4MiB
+# internode_application_send_queue_reserve_endpoint_capacity: 128MiB
+# internode_application_send_queue_reserve_global_capacity: 512MiB
+# internode_application_receive_queue_capacity: 4MiB
+# internode_application_receive_queue_reserve_endpoint_capacity: 128MiB
+# internode_application_receive_queue_reserve_global_capacity: 512MiB
# How long before a node logs slow queries. Select queries that take longer than
@@ -1385,10 +1385,10 @@ replica_filtering_protection:
# Log WARN on any multiple-partition batch size exceeding this value. 5kb per batch by default.
# Caution should be taken on increasing the size of this threshold as it can lead to node instability.
-batch_size_warn_threshold_in_kb: 5
+batch_size_warn_threshold: 5KiB
# Fail any multiple-partition batch exceeding this value. 50kb (10x warn threshold) by default.
-batch_size_fail_threshold_in_kb: 50
+batch_size_fail_threshold: 50KiB
# Log WARN on any batches not of type LOGGED than span across more partitions than this limit
unlogged_batch_across_partitions_warn_threshold: 10
@@ -1411,7 +1411,7 @@ compaction_tombstone_warning_threshold: 100000
# Maximum size of any value in SSTables. Safety measure to detect SSTable corruption
# early. Any value size larger than this threshold will result into marking an SSTable
# as corrupted. This should be positive and less than 2048.
-# max_value_size_in_mb: 256
+# max_value_size: 256MiB
# ** Impact on keyspace creation **
# If replication factor is not mentioned as part of keyspace creation, default_keyspace_rf would apply.
diff --git a/src/java/org/apache/cassandra/config/Config.java b/src/java/org/apache/cassandra/config/Config.java
index 6c22d5fab3..7ee8c42160 100644
--- a/src/java/org/apache/cassandra/config/Config.java
+++ b/src/java/org/apache/cassandra/config/Config.java
@@ -148,14 +148,17 @@ public class Config
public Integer concurrent_replicates = null;
public int memtable_flush_writers = 0;
- public Integer memtable_heap_space_in_mb;
- public Integer memtable_offheap_space_in_mb;
+ @Replaces(oldName = "memtable_heap_space_in_mb", converter = Converters.MEBIBYTES_DATA_STORAGE, deprecated = true)
+ public SmallestDataStorageMebibytes memtable_heap_space;
+ @Replaces(oldName = "memtable_offheap_space_in_mb", converter = Converters.MEBIBYTES_DATA_STORAGE, deprecated = true)
+ public SmallestDataStorageMebibytes memtable_offheap_space;
public Float memtable_cleanup_threshold = null;
// Limit the maximum depth of repair session merkle trees
@Deprecated
public volatile Integer repair_session_max_tree_depth = null;
- public volatile Integer repair_session_space_in_mb = null;
+ @Replaces(oldName = "repair_session_space_in_mb", converter = Converters.MEBIBYTES_DATA_STORAGE, deprecated = true)
+ public volatile SmallestDataStorageMebibytes repair_session_space = null;
public volatile boolean use_offheap_merkle_trees = true;
@@ -183,39 +186,52 @@ public class Config
public String broadcast_rpc_address;
public boolean rpc_keepalive = true;
- public Integer internode_max_message_size_in_bytes;
+ @Replaces(oldName = "internode_max_message_size_in_bytes", converter = Converters.BYTES_DATASTORAGE, deprecated=true)
+ public DataStorageSpec internode_max_message_size;
- @Replaces(oldName = "internode_send_buff_size_in_bytes", deprecated = true)
- public int internode_socket_send_buffer_size_in_bytes = 0;
- @Replaces(oldName = "internode_recv_buff_size_in_bytes", deprecated = true)
- public int internode_socket_receive_buffer_size_in_bytes = 0;
+ @Replaces(oldName = "internode_socket_send_buffer_size_in_bytes", converter = Converters.BYTES_DATASTORAGE, deprecated = true)
+ @Replaces(oldName = "internode_send_buff_size_in_bytes", converter = Converters.BYTES_DATASTORAGE, deprecated = true)
+ public DataStorageSpec internode_socket_send_buffer_size = new DataStorageSpec("0B");
+ @Replaces(oldName = "internode_socket_receive_buffer_size_in_bytes", converter = Converters.BYTES_DATASTORAGE, deprecated = true)
+ @Replaces(oldName = "internode_recv_buff_size_in_bytes", converter = Converters.BYTES_DATASTORAGE, deprecated = true)
+ public DataStorageSpec internode_socket_receive_buffer_size = new DataStorageSpec("0B");
+
+ @Replaces(oldName = "internode_application_send_queue_capacity_in_bytes", converter = Converters.BYTES_DATASTORAGE, deprecated = true)
+ public DataStorageSpec internode_application_send_queue_capacity = new DataStorageSpec("4MiB");
+ @Replaces(oldName = "internode_application_send_queue_reserve_endpoint_capacity_in_bytes", converter = Converters.BYTES_DATASTORAGE, deprecated = true)
+ public DataStorageSpec internode_application_send_queue_reserve_endpoint_capacity = new DataStorageSpec("128MiB");
+ @Replaces(oldName = "internode_application_send_queue_reserve_global_capacity_in_bytes", converter = Converters.BYTES_DATASTORAGE, deprecated = true)
+ public DataStorageSpec internode_application_send_queue_reserve_global_capacity = new DataStorageSpec("512MiB");
// TODO: derive defaults from system memory settings?
- public int internode_application_send_queue_capacity_in_bytes = 1 << 22; // 4MiB
- public int internode_application_send_queue_reserve_endpoint_capacity_in_bytes = 1 << 27; // 128MiB
- public int internode_application_send_queue_reserve_global_capacity_in_bytes = 1 << 29; // 512MiB
-
- public int internode_application_receive_queue_capacity_in_bytes = 1 << 22; // 4MiB
- public int internode_application_receive_queue_reserve_endpoint_capacity_in_bytes = 1 << 27; // 128MiB
- public int internode_application_receive_queue_reserve_global_capacity_in_bytes = 1 << 29; // 512MiB
+ @Replaces(oldName = "internode_application_receive_queue_capacity_in_bytes", converter = Converters.BYTES_DATASTORAGE, deprecated = true)
+ public DataStorageSpec internode_application_receive_queue_capacity = new DataStorageSpec("4MiB");
+ @Replaces(oldName = "internode_application_receive_queue_reserve_endpoint_capacity_in_bytes", converter = Converters.BYTES_DATASTORAGE, deprecated = true)
+ public DataStorageSpec internode_application_receive_queue_reserve_endpoint_capacity = new DataStorageSpec("128MiB");
+ @Replaces(oldName = "internode_application_receive_queue_reserve_global_capacity_in_bytes", converter = Converters.BYTES_DATASTORAGE, deprecated = true)
+ public DataStorageSpec internode_application_receive_queue_reserve_global_capacity = new DataStorageSpec("512MiB");
// Defensive settings for protecting Cassandra from true network partitions. See (CASSANDRA-14358) for details.
// The amount of time to wait for internode tcp connections to establish.
- public volatile int internode_tcp_connect_timeout_in_ms = 2000;
+ @Replaces(oldName = "internode_tcp_connect_timeout_in_ms", converter = Converters.MILLIS_DURATION, deprecated = true)
+ public volatile SmallestDurationMilliseconds internode_tcp_connect_timeout = new SmallestDurationMilliseconds("2s");
// The amount of time unacknowledged data is allowed on a connection before we throw out the connection
// Note this is only supported on Linux + epoll, and it appears to behave oddly above a setting of 30000
// (it takes much longer than 30s) as of Linux 4.12. If you want something that high set this to 0
// (which picks up the OS default) and configure the net.ipv4.tcp_retries2 sysctl to be ~8.
- public volatile int internode_tcp_user_timeout_in_ms = 30000;
- // Similar to internode_tcp_user_timeout_in_ms but used specifically for streaming connection.
+ @Replaces(oldName = "internode_tcp_user_timeout_in_ms", converter = Converters.MILLIS_DURATION, deprecated = true)
+ public volatile SmallestDurationMilliseconds internode_tcp_user_timeout = new SmallestDurationMilliseconds("30s");
+ // Similar to internode_tcp_user_timeout but used specifically for streaming connection.
// The default is 5 minutes. Increase it or set it to 0 in order to increase the timeout.
- public volatile int internode_streaming_tcp_user_timeout_in_ms = 300_000; // 5 minutes
+ @Replaces(oldName = "internode_streaming_tcp_user_timeout_in_ms", converter = Converters.MILLIS_DURATION, deprecated = true)
+ public volatile SmallestDurationMilliseconds internode_streaming_tcp_user_timeout = new SmallestDurationMilliseconds("300s"); // 5 minutes
public boolean start_native_transport = true;
public int native_transport_port = 9042;
public Integer native_transport_port_ssl = null;
public int native_transport_max_threads = 128;
- public int native_transport_max_frame_size_in_mb = 16;
+ @Replaces(oldName = "native_transport_max_frame_size_in_mb", converter = Converters.MEBIBYTES_DATA_STORAGE, deprecated = true)
+ public SmallestDataStorageMebibytes native_transport_max_frame_size = new SmallestDataStorageMebibytes("16MiB");
public volatile long native_transport_max_concurrent_connections = -1L;
public volatile long native_transport_max_concurrent_connections_per_ip = -1L;
public boolean native_transport_flush_in_batches_legacy = false;
@@ -224,27 +240,34 @@ public class Config
public volatile long native_transport_max_concurrent_requests_in_bytes = -1L;
public volatile boolean native_transport_rate_limiting_enabled = false;
public volatile int native_transport_max_requests_per_second = 1000000;
+ // not exposed in the yaml
public int native_transport_receive_queue_capacity_in_bytes = 1 << 20; // 1MiB
@Deprecated
public Integer native_transport_max_negotiable_protocol_version = null;
/**
- * Max size of values in SSTables, in MegaBytes.
- * Default is the same as the native protocol frame limit: 256Mb.
+ * Max size of values in SSTables, in MebiBytes.
+ * Default is the same as the native protocol frame limit: 256MiB.
* See AbstractType for how it is used.
*/
- public int max_value_size_in_mb = 256;
+ @Replaces(oldName = "max_value_size_in_mb", converter = Converters.MEBIBYTES_DATA_STORAGE, deprecated = true)
+ public SmallestDataStorageMebibytes max_value_size = new SmallestDataStorageMebibytes("256MiB");
public boolean snapshot_before_compaction = false;
public boolean auto_snapshot = true;
public volatile long snapshot_links_per_second = 0;
/* if the size of columns or super-columns are more than this, indexing will kick in */
- public volatile int column_index_size_in_kb = 64;
- public volatile int column_index_cache_size_in_kb = 2;
- public volatile int batch_size_warn_threshold_in_kb = 5;
- public volatile int batch_size_fail_threshold_in_kb = 50;
+ @Replaces(oldName = "column_index_size_in_kb", converter = Converters.KIBIBYTES_DATASTORAGE, deprecated = true)
+ public volatile SmallestDataStorageKibibytes column_index_size = new SmallestDataStorageKibibytes("64KiB");
+ @Replaces(oldName = "column_index_cache_size_in_kb", converter = Converters.KIBIBYTES_DATASTORAGE, deprecated = true)
+ public volatile SmallestDataStorageKibibytes column_index_cache_size = new SmallestDataStorageKibibytes("2KiB");
+ @Replaces(oldName = "batch_size_warn_threshold_in_kb", converter = Converters.KIBIBYTES_DATASTORAGE, deprecated = true)
+ public volatile SmallestDataStorageKibibytes batch_size_warn_threshold = new SmallestDataStorageKibibytes("5KiB");
+ @Replaces(oldName = "batch_size_fail_threshold_in_kb", converter = Converters.KIBIBYTES_DATASTORAGE, deprecated = true)
+ public volatile SmallestDataStorageKibibytes batch_size_fail_threshold = new SmallestDataStorageKibibytes("50KiB");
+
public Integer unlogged_batch_across_partitions_warn_threshold = 10;
public volatile Integer concurrent_compactors;
@Replaces(oldName = "compaction_throughput_mb_per_sec", converter = Converters.MEBIBYTES_PER_SECOND_DATA_RATE, deprecated = true)
@@ -355,8 +378,6 @@ public class Config
public int cache_load_timeout_seconds = 30;
- public Long paxos_cache_size_in_mb = null;
-
private static boolean isClientMode = false;
private static Supplier overrideLoadConfig = null;
diff --git a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
index d573def82e..3b1ef66145 100644
--- a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
+++ b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
@@ -79,7 +79,7 @@ import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.apache.cassandra.config.CassandraRelevantProperties.OS_ARCH;
import static org.apache.cassandra.config.CassandraRelevantProperties.SUN_ARCH_DATA_MODEL;
import static org.apache.cassandra.io.util.FileUtils.ONE_GB;
-import static org.apache.cassandra.io.util.FileUtils.ONE_MB;
+import static org.apache.cassandra.io.util.FileUtils.ONE_MIB;
import static org.apache.cassandra.utils.Clock.Global.logInitializationOutcome;
public class DatabaseDescriptor
@@ -469,24 +469,22 @@ public class DatabaseDescriptor
if (conf.file_cache_round_up == null)
conf.file_cache_round_up = conf.disk_optimization_strategy == Config.DiskOptimizationStrategy.spinning;
- if (conf.memtable_offheap_space_in_mb == null)
- conf.memtable_offheap_space_in_mb = (int) (Runtime.getRuntime().maxMemory() / (4 * 1048576));
- if (conf.memtable_offheap_space_in_mb < 0)
- throw new ConfigurationException("memtable_offheap_space_in_mb must be positive, but was " + conf.memtable_offheap_space_in_mb, false);
+ if (conf.memtable_offheap_space == null)
+ conf.memtable_offheap_space = SmallestDataStorageMebibytes.inMebibytes( (int) (Runtime.getRuntime().maxMemory() / (4 * 1048576)));
// for the moment, we default to twice as much on-heap space as off-heap, as heap overhead is very large
- if (conf.memtable_heap_space_in_mb == null)
- conf.memtable_heap_space_in_mb = (int) (Runtime.getRuntime().maxMemory() / (4 * 1048576));
- if (conf.memtable_heap_space_in_mb <= 0)
- throw new ConfigurationException("memtable_heap_space_in_mb must be positive, but was " + conf.memtable_heap_space_in_mb, false);
- logger.info("Global memtable on-heap threshold is enabled at {}MB", conf.memtable_heap_space_in_mb);
- if (conf.memtable_offheap_space_in_mb == 0)
+ if (conf.memtable_heap_space == null)
+ conf.memtable_heap_space = SmallestDataStorageMebibytes.inMebibytes((int) (Runtime.getRuntime().maxMemory() / (4 * 1048576)));
+ if (conf.memtable_heap_space.toMebibytesAsInt() == 0)
+ throw new ConfigurationException("memtable_heap_space must be positive, but was " + conf.memtable_heap_space, false);
+ logger.info("Global memtable on-heap threshold is enabled at {}", conf.memtable_heap_space);
+ if (conf.memtable_offheap_space.toMebibytesAsInt() == 0)
logger.info("Global memtable off-heap threshold is disabled, HeapAllocator will be used instead");
else
- logger.info("Global memtable off-heap threshold is enabled at {}MB", conf.memtable_offheap_space_in_mb);
+ logger.info("Global memtable off-heap threshold is enabled at {}", conf.memtable_offheap_space);
if (conf.repair_session_max_tree_depth != null)
{
- logger.warn("repair_session_max_tree_depth has been deprecated and should be removed from cassandra.yaml. Use repair_session_space_in_mb instead");
+ logger.warn("repair_session_max_tree_depth has been deprecated and should be removed from cassandra.yaml. Use repair_session_space instead");
if (conf.repair_session_max_tree_depth < 10)
throw new ConfigurationException("repair_session_max_tree_depth should not be < 10, but was " + conf.repair_session_max_tree_depth);
if (conf.repair_session_max_tree_depth > 20)
@@ -497,27 +495,30 @@ public class DatabaseDescriptor
conf.repair_session_max_tree_depth = 20;
}
- if (conf.repair_session_space_in_mb == null)
- conf.repair_session_space_in_mb = Math.max(1, (int) (Runtime.getRuntime().maxMemory() / (16 * 1048576)));
+ if (conf.repair_session_space == null)
+ conf.repair_session_space = SmallestDataStorageMebibytes.inMebibytes(Math.max(1, (int) (Runtime.getRuntime().maxMemory() / (16 * 1048576))));
- if (conf.repair_session_space_in_mb < 1)
- throw new ConfigurationException("repair_session_space_in_mb must be > 0, but was " + conf.repair_session_space_in_mb);
- else if (conf.repair_session_space_in_mb > (int) (Runtime.getRuntime().maxMemory() / (4 * 1048576)))
- logger.warn("A repair_session_space_in_mb of " + conf.repair_session_space_in_mb + " megabytes is likely to cause heap pressure");
+ if (conf.repair_session_space.toMebibytes() < 1)
+ throw new ConfigurationException("repair_session_space must be > 0, but was " + conf.repair_session_space);
+ else if (conf.repair_session_space.toMebibytesAsInt() > (int) (Runtime.getRuntime().maxMemory() / (4 * 1048576)))
+ logger.warn("A repair_session_space of " + conf.repair_session_space+ " mebibytes is likely to cause heap pressure");
checkForLowestAcceptedTimeouts(conf);
- checkValidForByteConversion(conf.native_transport_max_frame_size_in_mb,
- "native_transport_max_frame_size_in_mb", ByteUnit.MEBI_BYTES);
+ long valueInBytes = conf.native_transport_max_frame_size.toBytes();
+ if (valueInBytes < 0 || valueInBytes > Integer.MAX_VALUE)
+ {
+ throw new ConfigurationException(String.format("%s must be positive value < %dB, but was %dB",
+ "native_transport_max_frame_size",
+ conf.native_transport_max_frame_size.getUnit()
+ .convert(Integer.MAX_VALUE, DataStorageSpec.DataStorageUnit.BYTES),
+ valueInBytes),
+ false);
+ }
- checkValidForByteConversion(conf.column_index_size_in_kb,
- "column_index_size_in_kb", ByteUnit.KIBI_BYTES);
-
- checkValidForByteConversion(conf.column_index_cache_size_in_kb,
- "column_index_cache_size_in_kb", ByteUnit.KIBI_BYTES);
-
- checkValidForByteConversion(conf.batch_size_warn_threshold_in_kb,
- "batch_size_warn_threshold_in_kb", ByteUnit.KIBI_BYTES);
+ checkValidForByteConversion(conf.column_index_size, "column_index_size");
+ checkValidForByteConversion(conf.column_index_cache_size, "column_index_cache_size");
+ checkValidForByteConversion(conf.batch_size_warn_threshold, "batch_size_warn_threshold");
if (conf.native_transport_max_negotiable_protocol_version != null)
logger.warn("The configuration option native_transport_max_negotiable_protocol_version has been deprecated " +
@@ -770,11 +771,11 @@ public class DatabaseDescriptor
if (conf.snapshot_links_per_second < 0)
throw new ConfigurationException("snapshot_links_per_second must be >= 0");
- if (conf.max_value_size_in_mb <= 0)
- throw new ConfigurationException("max_value_size_in_mb must be positive", false);
- else if (conf.max_value_size_in_mb >= 2048)
- throw new ConfigurationException("max_value_size_in_mb must be smaller than 2048, but was "
- + conf.max_value_size_in_mb, false);
+ if (conf.max_value_size.toMebibytesAsInt() == 0)
+ throw new ConfigurationException("max_value_size must be positive", false);
+ else if (conf.max_value_size.toMebibytesAsInt() >= 2048)
+ throw new ConfigurationException("max_value_size must be smaller than 2048, but was "
+ + conf.max_value_size.toString(), false);
switch (conf.disk_optimization_strategy)
{
@@ -796,26 +797,30 @@ public class DatabaseDescriptor
throw new ConfigurationException("legacy_ssl_storage_port_enabled is true (enabled) with internode encryption disabled (none). Enable encryption or disable the legacy ssl storage port.");
}
}
- Integer maxMessageSize = conf.internode_max_message_size_in_bytes;
- if (maxMessageSize != null)
+
+ if (conf.internode_max_message_size != null)
{
- if (maxMessageSize > conf.internode_application_receive_queue_reserve_endpoint_capacity_in_bytes)
- throw new ConfigurationException("internode_max_message_size_in_mb must no exceed internode_application_receive_queue_reserve_endpoint_capacity_in_bytes", false);
+ long maxMessageSize = conf.internode_max_message_size.toBytes();
- if (maxMessageSize > conf.internode_application_receive_queue_reserve_global_capacity_in_bytes)
- throw new ConfigurationException("internode_max_message_size_in_mb must no exceed internode_application_receive_queue_reserve_global_capacity_in_bytes", false);
+ if (maxMessageSize > conf.internode_application_receive_queue_reserve_endpoint_capacity.toBytes())
+ throw new ConfigurationException("internode_max_message_size must no exceed internode_application_receive_queue_reserve_endpoint_capacity", false);
- if (maxMessageSize > conf.internode_application_send_queue_reserve_endpoint_capacity_in_bytes)
- throw new ConfigurationException("internode_max_message_size_in_mb must no exceed internode_application_send_queue_reserve_endpoint_capacity_in_bytes", false);
+ if (maxMessageSize > conf.internode_application_receive_queue_reserve_global_capacity.toBytes())
+ throw new ConfigurationException("internode_max_message_size must no exceed internode_application_receive_queue_reserve_global_capacity", false);
- if (maxMessageSize > conf.internode_application_send_queue_reserve_global_capacity_in_bytes)
- throw new ConfigurationException("internode_max_message_size_in_mb must no exceed internode_application_send_queue_reserve_global_capacity_in_bytes", false);
+ if (maxMessageSize > conf.internode_application_send_queue_reserve_endpoint_capacity.toBytes())
+ throw new ConfigurationException("internode_max_message_size must no exceed internode_application_send_queue_reserve_endpoint_capacity", false);
+
+ if (maxMessageSize > conf.internode_application_send_queue_reserve_global_capacity.toBytes())
+ throw new ConfigurationException("internode_max_message_size must no exceed internode_application_send_queue_reserve_global_capacity", false);
}
else
{
- conf.internode_max_message_size_in_bytes =
- Math.min(conf.internode_application_receive_queue_reserve_endpoint_capacity_in_bytes,
- conf.internode_application_send_queue_reserve_endpoint_capacity_in_bytes);
+ long maxMessageSizeInBytes =
+ Math.min(conf.internode_application_receive_queue_reserve_endpoint_capacity.toBytes(),
+ conf.internode_application_send_queue_reserve_endpoint_capacity.toBytes());
+
+ conf.internode_max_message_size = DataStorageSpec.inBytes(maxMessageSizeInBytes);
}
validateMaxConcurrentAutoUpgradeTasksConf(conf.max_concurrent_automatic_sstable_upgrades);
@@ -901,7 +906,7 @@ public class DatabaseDescriptor
static int calculateDefaultSpaceInMB(String type, String path, String setting, int preferredSizeInMB, long totalSpaceInBytes, long totalSpaceNumerator, long totalSpaceDenominator)
{
- final long totalSizeInMB = totalSpaceInBytes / ONE_MB;
+ final long totalSizeInMB = totalSpaceInBytes / ONE_MIB;
final int minSizeInMB = Ints.saturatedCast(totalSpaceNumerator * totalSizeInMB / totalSpaceDenominator);
if (minSizeInMB < preferredSizeInMB)
@@ -1061,13 +1066,46 @@ public class DatabaseDescriptor
@VisibleForTesting
static void checkForLowestAcceptedTimeouts(Config conf)
{
- conf.read_request_timeout = max("read_request_timeout", conf.read_request_timeout, LOWEST_ACCEPTED_TIMEOUT);
- conf.range_request_timeout = max("range_request_timeout", conf.range_request_timeout, LOWEST_ACCEPTED_TIMEOUT);
- conf.request_timeout = max("request_timeout", conf.request_timeout, LOWEST_ACCEPTED_TIMEOUT);
- conf.write_request_timeout = max("write_request_timeout", conf.write_request_timeout, LOWEST_ACCEPTED_TIMEOUT);
- conf.cas_contention_timeout = max("cas_contention_timeout", conf.cas_contention_timeout, LOWEST_ACCEPTED_TIMEOUT);
- conf.counter_write_request_timeout = max("counter_write_request_timeout", conf.counter_write_request_timeout, LOWEST_ACCEPTED_TIMEOUT);
- conf.truncate_request_timeout = max("truncate_request_timeout", conf.truncate_request_timeout, LOWEST_ACCEPTED_TIMEOUT);
+ if(conf.read_request_timeout.toMillisecondsAsInt() < LOWEST_ACCEPTED_TIMEOUT.toMillisecondsAsInt())
+ {
+ logInfo("read_request_timeout", conf.read_request_timeout, LOWEST_ACCEPTED_TIMEOUT);
+ conf.read_request_timeout = new SmallestDurationMilliseconds("10ms");
+ }
+
+ if(conf.range_request_timeout.toMillisecondsAsInt() < LOWEST_ACCEPTED_TIMEOUT.toMillisecondsAsInt())
+ {
+ logInfo("range_request_timeout", conf.range_request_timeout, LOWEST_ACCEPTED_TIMEOUT);
+ conf.range_request_timeout = new SmallestDurationMilliseconds("10ms");
+ }
+
+ if(conf.request_timeout.toMillisecondsAsInt() < LOWEST_ACCEPTED_TIMEOUT.toMillisecondsAsInt())
+ {
+ logInfo("request_timeout", conf.request_timeout, LOWEST_ACCEPTED_TIMEOUT);
+ conf.request_timeout = new SmallestDurationMilliseconds("10ms");
+ }
+
+ if(conf.write_request_timeout.toMillisecondsAsInt() < LOWEST_ACCEPTED_TIMEOUT.toMillisecondsAsInt())
+ {
+ logInfo("write_request_timeout", conf.write_request_timeout, LOWEST_ACCEPTED_TIMEOUT);
+ conf.write_request_timeout = new SmallestDurationMilliseconds("10ms");
+ }
+
+ if(conf.cas_contention_timeout.toMillisecondsAsInt() < LOWEST_ACCEPTED_TIMEOUT.toMillisecondsAsInt())
+ {
+ logInfo("cas_contention_timeout", conf.cas_contention_timeout, LOWEST_ACCEPTED_TIMEOUT);
+ conf.cas_contention_timeout = new SmallestDurationMilliseconds("10ms");
+ }
+
+ if(conf.counter_write_request_timeout.toMillisecondsAsInt()< LOWEST_ACCEPTED_TIMEOUT.toMillisecondsAsInt())
+ {
+ logInfo("counter_write_request_timeout", conf.counter_write_request_timeout, LOWEST_ACCEPTED_TIMEOUT);
+ conf.counter_write_request_timeout = new SmallestDurationMilliseconds("10ms");
+ }
+ if(conf.truncate_request_timeout.toMillisecondsAsInt() < LOWEST_ACCEPTED_TIMEOUT.toMillisecondsAsInt())
+ {
+ logInfo("truncate_request_timeout", conf.truncate_request_timeout, LOWEST_ACCEPTED_TIMEOUT);
+ conf.truncate_request_timeout = LOWEST_ACCEPTED_TIMEOUT;
+ }
}
private static void logInfo(String property, SmallestDurationMilliseconds actualValue, SmallestDurationMilliseconds lowestAcceptedValue)
@@ -1378,12 +1416,12 @@ public class DatabaseDescriptor
public static int getMaxValueSize()
{
- return conf.max_value_size_in_mb * 1024 * 1024;
+ return conf.max_value_size.toBytesAsInt();
}
public static void setMaxValueSize(int maxValueSizeInBytes)
{
- conf.max_value_size_in_mb = maxValueSizeInBytes / 1024 / 1024;
+ conf.max_value_size = SmallestDataStorageMebibytes.inBytes(maxValueSizeInBytes);
}
/**
@@ -1470,54 +1508,56 @@ public class DatabaseDescriptor
public static int getColumnIndexSize()
{
- return (int) ByteUnit.KIBI_BYTES.toBytes(conf.column_index_size_in_kb);
+ return conf.column_index_size.toBytesAsInt();
}
- public static int getColumnIndexSizeInKB()
+ public static int getColumnIndexSizeInKiB()
{
- return conf.column_index_size_in_kb;
+ return conf.column_index_size.toKibibytesAsInt();
}
public static void setColumnIndexSize(int val)
{
- checkValidForByteConversion(val, "column_index_size_in_kb", ByteUnit.KIBI_BYTES);
- conf.column_index_size_in_kb = val;
+ SmallestDataStorageKibibytes memory = SmallestDataStorageKibibytes.inKibibytes(val);
+ checkValidForByteConversion(memory, "column_index_size");
+ conf.column_index_size = SmallestDataStorageKibibytes.inKibibytes(val);
}
public static int getColumnIndexCacheSize()
{
- return (int) ByteUnit.KIBI_BYTES.toBytes(conf.column_index_cache_size_in_kb);
+ return conf.column_index_cache_size.toBytesAsInt();
}
- public static int getColumnIndexCacheSizeInKB()
+ public static int getColumnIndexCacheSizeInKiB()
{
- return conf.column_index_cache_size_in_kb;
+ return conf.column_index_cache_size.toKibibytesAsInt();
}
public static void setColumnIndexCacheSize(int val)
{
- checkValidForByteConversion(val, "column_index_cache_size_in_kb", ByteUnit.KIBI_BYTES);
- conf.column_index_cache_size_in_kb = val;
+ SmallestDataStorageKibibytes memory = SmallestDataStorageKibibytes.inKibibytes(val);
+ checkValidForByteConversion(memory, "column_index_cache_size");
+ conf.column_index_cache_size = SmallestDataStorageKibibytes.inKibibytes(val);
}
public static int getBatchSizeWarnThreshold()
{
- return (int) ByteUnit.KIBI_BYTES.toBytes(conf.batch_size_warn_threshold_in_kb);
+ return conf.batch_size_warn_threshold.toBytesAsInt();
}
- public static int getBatchSizeWarnThresholdInKB()
+ public static int getBatchSizeWarnThresholdInKiB()
{
- return conf.batch_size_warn_threshold_in_kb;
+ return conf.batch_size_warn_threshold.toKibibytesAsInt();
}
public static long getBatchSizeFailThreshold()
{
- return ByteUnit.KIBI_BYTES.toBytes(conf.batch_size_fail_threshold_in_kb);
+ return conf.batch_size_fail_threshold.toBytesAsInt();
}
public static int getBatchSizeFailThresholdInKB()
{
- return conf.batch_size_fail_threshold_in_kb;
+ return conf.batch_size_fail_threshold.toKibibytesAsInt();
}
public static int getUnloggedBatchAcrossPartitionsWarnThreshold()
@@ -1525,15 +1565,16 @@ public class DatabaseDescriptor
return conf.unlogged_batch_across_partitions_warn_threshold;
}
- public static void setBatchSizeWarnThresholdInKB(int threshold)
+ public static void setBatchSizeWarnThresholdInKiB(int threshold)
{
- checkValidForByteConversion(threshold, "batch_size_warn_threshold_in_kb", ByteUnit.KIBI_BYTES);
- conf.batch_size_warn_threshold_in_kb = threshold;
+ SmallestDataStorageKibibytes storage = SmallestDataStorageKibibytes.inKibibytes(threshold);
+ checkValidForByteConversion(storage, "batch_size_warn_threshold");
+ conf.batch_size_warn_threshold = SmallestDataStorageKibibytes.inKibibytes(threshold);
}
public static void setBatchSizeFailThresholdInKB(int threshold)
{
- conf.batch_size_fail_threshold_in_kb = threshold;
+ conf.batch_size_fail_threshold = SmallestDataStorageKibibytes.inKibibytes(threshold);
}
public static Collection getInitialTokens()
@@ -2198,83 +2239,83 @@ public class DatabaseDescriptor
public static int getInternodeSocketSendBufferSizeInBytes()
{
- return conf.internode_socket_send_buffer_size_in_bytes;
+ return conf.internode_socket_send_buffer_size.toBytesAsInt();
}
public static int getInternodeSocketReceiveBufferSizeInBytes()
{
- return conf.internode_socket_receive_buffer_size_in_bytes;
+ return conf.internode_socket_receive_buffer_size.toBytesAsInt();
}
public static int getInternodeApplicationSendQueueCapacityInBytes()
{
- return conf.internode_application_send_queue_capacity_in_bytes;
+ return conf.internode_application_send_queue_capacity.toBytesAsInt();
}
public static int getInternodeApplicationSendQueueReserveEndpointCapacityInBytes()
{
- return conf.internode_application_send_queue_reserve_endpoint_capacity_in_bytes;
+ return conf.internode_application_send_queue_reserve_endpoint_capacity.toBytesAsInt();
}
public static int getInternodeApplicationSendQueueReserveGlobalCapacityInBytes()
{
- return conf.internode_application_send_queue_reserve_global_capacity_in_bytes;
+ return conf.internode_application_send_queue_reserve_global_capacity.toBytesAsInt();
}
public static int getInternodeApplicationReceiveQueueCapacityInBytes()
{
- return conf.internode_application_receive_queue_capacity_in_bytes;
+ return conf.internode_application_receive_queue_capacity.toBytesAsInt();
}
public static int getInternodeApplicationReceiveQueueReserveEndpointCapacityInBytes()
{
- return conf.internode_application_receive_queue_reserve_endpoint_capacity_in_bytes;
+ return conf.internode_application_receive_queue_reserve_endpoint_capacity.toBytesAsInt();
}
public static int getInternodeApplicationReceiveQueueReserveGlobalCapacityInBytes()
{
- return conf.internode_application_receive_queue_reserve_global_capacity_in_bytes;
+ return conf.internode_application_receive_queue_reserve_global_capacity.toBytesAsInt();
}
public static int getInternodeTcpConnectTimeoutInMS()
{
- return conf.internode_tcp_connect_timeout_in_ms;
+ return conf.internode_tcp_connect_timeout.toMillisecondsAsInt();
}
public static void setInternodeTcpConnectTimeoutInMS(int value)
{
- conf.internode_tcp_connect_timeout_in_ms = value;
+ conf.internode_tcp_connect_timeout = SmallestDurationMilliseconds.inMilliseconds(value);
}
public static int getInternodeTcpUserTimeoutInMS()
{
- return conf.internode_tcp_user_timeout_in_ms;
+ return conf.internode_tcp_user_timeout.toMillisecondsAsInt();
}
public static void setInternodeTcpUserTimeoutInMS(int value)
{
- conf.internode_tcp_user_timeout_in_ms = value;
+ conf.internode_tcp_user_timeout = SmallestDurationMilliseconds.inMilliseconds(value);
}
public static int getInternodeStreamingTcpUserTimeoutInMS()
{
- return conf.internode_streaming_tcp_user_timeout_in_ms;
+ return conf.internode_streaming_tcp_user_timeout.toMillisecondsAsInt();
}
public static void setInternodeStreamingTcpUserTimeoutInMS(int value)
{
- conf.internode_streaming_tcp_user_timeout_in_ms = value;
+ conf.internode_streaming_tcp_user_timeout = SmallestDurationMilliseconds.inMilliseconds(value);
}
public static int getInternodeMaxMessageSizeInBytes()
{
- return conf.internode_max_message_size_in_bytes;
+ return conf.internode_max_message_size.toBytesAsInt();
}
@VisibleForTesting
public static void setInternodeMaxMessageSizeInBytes(int value)
{
- conf.internode_max_message_size_in_bytes = value;
+ conf.internode_max_message_size = DataStorageSpec.inBytes(value);
}
public static boolean startNativeTransport()
@@ -2320,12 +2361,12 @@ public class DatabaseDescriptor
public static int getNativeTransportMaxFrameSize()
{
- return (int) ByteUnit.MEBI_BYTES.toBytes(conf.native_transport_max_frame_size_in_mb);
+ return conf.native_transport_max_frame_size.toBytesAsInt();
}
public static void setNativeTransportMaxFrameSize(int bytes)
{
- conf.native_transport_max_frame_size_in_mb = (int) ByteUnit.MEBI_BYTES.fromBytes(bytes);
+ conf.native_transport_max_frame_size = SmallestDataStorageMebibytes.inMebibytes(bytes);
}
public static long getNativeTransportMaxConcurrentConnections()
@@ -2953,14 +2994,14 @@ public class DatabaseDescriptor
return conf.inter_dc_tcp_nodelay;
}
- public static long getMemtableHeapSpaceInMb()
+ public static long getMemtableHeapSpaceInMiB()
{
- return conf.memtable_heap_space_in_mb;
+ return conf.memtable_heap_space.toMebibytes();
}
- public static long getMemtableOffheapSpaceInMb()
+ public static long getMemtableOffheapSpaceInMiB()
{
- return conf.memtable_offheap_space_in_mb;
+ return conf.memtable_offheap_space.toMebibytes();
}
public static Config.MemtableAllocationType getMemtableAllocationType()
@@ -2984,21 +3025,21 @@ public class DatabaseDescriptor
conf.repair_session_max_tree_depth = depth;
}
- public static int getRepairSessionSpaceInMegabytes()
+ public static int getRepairSessionSpaceInMiB()
{
- return conf.repair_session_space_in_mb;
+ return conf.repair_session_space.toMebibytesAsInt();
}
- public static void setRepairSessionSpaceInMegabytes(int sizeInMegabytes)
+ public static void setRepairSessionSpaceInMiB(int sizeInMiB)
{
- if (sizeInMegabytes < 1)
- throw new ConfigurationException("Cannot set repair_session_space_in_mb to " + sizeInMegabytes +
- " < 1 megabyte");
- else if (sizeInMegabytes > (int) (Runtime.getRuntime().maxMemory() / (4 * 1048576)))
- logger.warn("A repair_session_space_in_mb of " + conf.repair_session_space_in_mb +
- " megabytes is likely to cause heap pressure.");
+ if (sizeInMiB < 1)
+ throw new ConfigurationException("Cannot set repair_session_space to " + sizeInMiB +
+ " < 1 mebibyte");
+ else if (sizeInMiB > (int) (Runtime.getRuntime().maxMemory() / (4 * 1048576)))
+ logger.warn("A repair_session_space of " + conf.repair_session_space +
+ " is likely to cause heap pressure.");
- conf.repair_session_space_in_mb = sizeInMegabytes;
+ conf.repair_session_space = SmallestDataStorageMebibytes.inMebibytes(sizeInMiB);
}
public static Float getMemtableCleanupThreshold()
@@ -3420,11 +3461,18 @@ public class DatabaseDescriptor
/**
* Ensures passed in configuration value is positive and will not overflow when converted to Bytes
*/
- private static void checkValidForByteConversion(int val, final String name, final ByteUnit unit)
+ private static void checkValidForByteConversion(final SmallestDataStorageKibibytes value, String name)
{
- if (val < 0 || unit.willOverflowInBytes(val))
- throw new ConfigurationException(String.format("%s must be positive value < %d, but was %d",
- name, unit.overflowThreshold(), val), false);
+ long valueInBytes = value.toBytes();
+ if (valueInBytes < 0 || valueInBytes > Integer.MAX_VALUE)
+ {
+ throw new ConfigurationException(String.format("%s must be positive value < %dB, but was %dB",
+ name,
+ value.getUnit()
+ .convert(Integer.MAX_VALUE, DataStorageSpec.DataStorageUnit.BYTES),
+ valueInBytes),
+ false);
+ }
}
public static int getValidationPreviewPurgeHeadStartInSec()
diff --git a/src/java/org/apache/cassandra/config/SmallestDataStorageMebibytes.java b/src/java/org/apache/cassandra/config/SmallestDataStorageMebibytes.java
index 8f549365bd..514d1bc18a 100644
--- a/src/java/org/apache/cassandra/config/SmallestDataStorageMebibytes.java
+++ b/src/java/org/apache/cassandra/config/SmallestDataStorageMebibytes.java
@@ -52,4 +52,15 @@ public final class SmallestDataStorageMebibytes extends DataStorageSpec
{
return new SmallestDataStorageMebibytes(mebibytes, DataStorageSpec.DataStorageUnit.MEBIBYTES);
}
+
+ /**
+ * Creates a {@code SmallestDataStorageMebibytes} of the specified amount of bytes.
+ *
+ * @param bytes the amount of bytes
+ * @return a data storage
+ */
+ public static SmallestDataStorageMebibytes inBytes(long bytes)
+ {
+ return new SmallestDataStorageMebibytes(bytes, DataStorageSpec.DataStorageUnit.BYTES);
+ }
}
diff --git a/src/java/org/apache/cassandra/cql3/statements/BatchStatement.java b/src/java/org/apache/cassandra/cql3/statements/BatchStatement.java
index dabe05efce..b7e9c07ec0 100644
--- a/src/java/org/apache/cassandra/cql3/statements/BatchStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/BatchStatement.java
@@ -350,9 +350,9 @@ public class BatchStatement implements CQLStatement
if (size > failThreshold)
{
Tracing.trace(format, tableNames, FBUtilities.prettyPrintMemory(size), FBUtilities.prettyPrintMemory(failThreshold),
- FBUtilities.prettyPrintMemory(size - failThreshold), " (see batch_size_fail_threshold_in_kb)");
+ FBUtilities.prettyPrintMemory(size - failThreshold), " (see batch_size_fail_threshold)");
logger.error(format, tableNames, FBUtilities.prettyPrintMemory(size), FBUtilities.prettyPrintMemory(failThreshold),
- FBUtilities.prettyPrintMemory(size - failThreshold), " (see batch_size_fail_threshold_in_kb)");
+ FBUtilities.prettyPrintMemory(size - failThreshold), " (see batch_size_fail_threshold)");
throw new InvalidRequestException("Batch too large");
}
else if (logger.isWarnEnabled())
diff --git a/src/java/org/apache/cassandra/db/ColumnIndex.java b/src/java/org/apache/cassandra/db/ColumnIndex.java
index b87230083d..15405bda66 100644
--- a/src/java/org/apache/cassandra/db/ColumnIndex.java
+++ b/src/java/org/apache/cassandra/db/ColumnIndex.java
@@ -36,16 +36,16 @@ import org.apache.cassandra.utils.ByteBufferUtil;
/**
* Column index builder used by {@link org.apache.cassandra.io.sstable.format.big.BigTableWriter}.
- * For index entries that exceed {@link org.apache.cassandra.config.Config#column_index_cache_size_in_kb},
+ * For index entries that exceed {@link org.apache.cassandra.config.Config#column_index_cache_size},
* this uses the serialization logic as in {@link RowIndexEntry}.
*/
public class ColumnIndex
{
- // used, if the row-index-entry reaches config column_index_cache_size_in_kb
+ // used, if the row-index-entry reaches config column_index_cache_size
private DataOutputBuffer buffer;
// used to track the size of the serialized size of row-index-entry (unused for buffer)
private int indexSamplesSerializedSize;
- // used, until the row-index-entry reaches config column_index_cache_size_in_kb
+ // used, until the row-index-entry reaches config column_index_cache_size
private final List indexSamples = new ArrayList<>();
private DataOutputBuffer reusableBuffer;
@@ -199,8 +199,8 @@ public class ColumnIndex
}
columnIndexCount++;
- // First, we collect the IndexInfo objects until we reach Config.column_index_cache_size_in_kb in an ArrayList.
- // When column_index_cache_size_in_kb is reached, we switch to byte-buffer mode.
+ // First, we collect the IndexInfo objects until we reach Config.column_index_cache_size in an ArrayList.
+ // When column_index_cache_size is reached, we switch to byte-buffer mode.
if (buffer == null)
{
indexSamplesSerializedSize += idxSerializer.serializedSize(cIndexInfo);
@@ -285,7 +285,7 @@ public class ColumnIndex
// If we serialize the IndexInfo objects directly in the code above into 'buffer',
// we have to write the offsts to these here. The offsets have already been are collected
- // in indexOffsets[]. buffer is != null, if it exceeds Config.column_index_cache_size_in_kb.
+ // in indexOffsets[]. buffer is != null, if it exceeds Config.column_index_cache_size.
// In the other case, when buffer==null, the offsets are serialized in RowIndexEntry.IndexedEntry.serialize().
if (buffer != null)
RowIndexEntry.Serializer.serializeOffsets(buffer, indexOffsets, columnIndexCount);
diff --git a/src/java/org/apache/cassandra/db/Memtable.java b/src/java/org/apache/cassandra/db/Memtable.java
index c755591938..21bf31a182 100644
--- a/src/java/org/apache/cassandra/db/Memtable.java
+++ b/src/java/org/apache/cassandra/db/Memtable.java
@@ -87,8 +87,8 @@ public class Memtable implements Comparable
private static MemtablePool createMemtableAllocatorPool()
{
- long heapLimit = DatabaseDescriptor.getMemtableHeapSpaceInMb() << 20;
- long offHeapLimit = DatabaseDescriptor.getMemtableOffheapSpaceInMb() << 20;
+ long heapLimit = DatabaseDescriptor.getMemtableHeapSpaceInMiB() << 20;
+ long offHeapLimit = DatabaseDescriptor.getMemtableOffheapSpaceInMiB() << 20;
final float cleaningThreshold = DatabaseDescriptor.getMemtableCleanupThreshold();
final MemtableCleaner cleaner = ColumnFamilyStore::flushLargestMemtable;
switch (DatabaseDescriptor.getMemtableAllocationType())
diff --git a/src/java/org/apache/cassandra/db/RowIndexEntry.java b/src/java/org/apache/cassandra/db/RowIndexEntry.java
index 895bea9ab0..153dbac687 100644
--- a/src/java/org/apache/cassandra/db/RowIndexEntry.java
+++ b/src/java/org/apache/cassandra/db/RowIndexEntry.java
@@ -76,7 +76,7 @@ import static org.apache.cassandra.metrics.CassandraMetricsRegistry.Metrics;
* samples (list of {@link IndexInfo} objects) and those who don't.
* For each portion of data for a single partition in the data file,
* an index sample is created. The size of that portion is defined
- * by {@link org.apache.cassandra.config.Config#column_index_size_in_kb}.
+ * by {@link org.apache.cassandra.config.Config#column_index_size}.
*
*
* Index entries with less than 2 index samples, will just store the
@@ -97,9 +97,9 @@ import static org.apache.cassandra.metrics.CassandraMetricsRegistry.Metrics;
* "acceptable" amount of index samples per partition and those
* with an "enormous" amount of index samples. The barrier
* is controlled by the configuration parameter
- * {@link org.apache.cassandra.config.Config#column_index_cache_size_in_kb}.
+ * {@link org.apache.cassandra.config.Config#column_index_cache_size}.
* Index entries with a total serialized size of index samples up to
- * {@code column_index_cache_size_in_kb} will be held in an array.
+ * {@code column_index_cache_size} will be held in an array.
* Index entries exceeding that value will always be accessed from
* disk.
*
@@ -110,9 +110,9 @@ import static org.apache.cassandra.metrics.CassandraMetricsRegistry.Metrics;
* {@link RowIndexEntry} just stores the offset in the data file.
* {@link IndexedEntry} is for index entries with index samples
* and used for both current and legacy sstables, which do not exceed
- * {@link org.apache.cassandra.config.Config#column_index_cache_size_in_kb}.
+ * {@link org.apache.cassandra.config.Config#column_index_cache_size}.
* {@link ShallowIndexedEntry} is for index entries with index samples
- * that exceed {@link org.apache.cassandra.config.Config#column_index_cache_size_in_kb}
+ * that exceed {@link org.apache.cassandra.config.Config#column_index_cache_size}
* for sstables with an offset table to the index samples.
*
*
@@ -193,7 +193,7 @@ public class RowIndexEntry implements IMeasurableMemory
* @param headerLength deletion time of {@link RowIndexEntry}
* @param columnIndexCount number of {@link IndexInfo} entries in the {@link RowIndexEntry}
* @param indexedPartSize serialized size of all serialized {@link IndexInfo} objects and their offsets
- * @param indexSamples list with IndexInfo offsets (if total serialized size is less than {@link org.apache.cassandra.config.Config#column_index_cache_size_in_kb}
+ * @param indexSamples list with IndexInfo offsets (if total serialized size is less than {@link org.apache.cassandra.config.Config#column_index_cache_size}
* @param offsets offsets of IndexInfo offsets
* @param idxInfoSerializer the {@link IndexInfo} serializer
*/
@@ -205,14 +205,14 @@ public class RowIndexEntry implements IMeasurableMemory
{
// If the "partition building code" in BigTableWriter.append() via ColumnIndex returns a list
// of IndexInfo objects, which is the case if the serialized size is less than
- // Config.column_index_cache_size_in_kb, AND we have more than one IndexInfo object, we
+ // Config.column_index_cache_size, AND we have more than one IndexInfo object, we
// construct an IndexedEntry object. (note: indexSamples.size() and columnIndexCount have the same meaning)
if (indexSamples != null && indexSamples.size() > 1)
return new IndexedEntry(dataFilePosition, deletionTime, headerLength,
indexSamples.toArray(new IndexInfo[indexSamples.size()]), offsets,
indexedPartSize, idxInfoSerializer);
// Here we have to decide whether we have serialized IndexInfo objects that exceeds
- // Config.column_index_cache_size_in_kb (not exceeding case covered above).
+ // Config.column_index_cache_size (not exceeding case covered above).
// Such a "big" indexed-entry is represented as a shallow one.
if (columnIndexCount > 1)
return new ShallowIndexedEntry(dataFilePosition, indexFilePosition,
diff --git a/src/java/org/apache/cassandra/db/marshal/AbstractType.java b/src/java/org/apache/cassandra/db/marshal/AbstractType.java
index 3a18f76f93..c8eca39c9d 100644
--- a/src/java/org/apache/cassandra/db/marshal/AbstractType.java
+++ b/src/java/org/apache/cassandra/db/marshal/AbstractType.java
@@ -514,7 +514,7 @@ public abstract class AbstractType implements Comparator, Assignm
if (l > maxValueSize)
throw new IOException(String.format("Corrupt value length %d encountered, as it exceeds the maximum of %d, " +
- "which is set via max_value_size_in_mb in cassandra.yaml",
+ "which is set via max_value_size in cassandra.yaml",
l, maxValueSize));
return accessor.read(in, l);
diff --git a/src/java/org/apache/cassandra/io/sstable/IndexInfo.java b/src/java/org/apache/cassandra/io/sstable/IndexInfo.java
index e74415052a..fa0fb2c20e 100644
--- a/src/java/org/apache/cassandra/io/sstable/IndexInfo.java
+++ b/src/java/org/apache/cassandra/io/sstable/IndexInfo.java
@@ -35,7 +35,7 @@ import org.apache.cassandra.utils.ObjectSizes;
/**
* {@code IndexInfo} is embedded in the indexed version of {@link RowIndexEntry}.
- * Each instance roughly covers a range of {@link org.apache.cassandra.config.Config#column_index_size_in_kb column_index_size_in_kb} kB
+ * Each instance roughly covers a range of {@link org.apache.cassandra.config.Config#column_index_size column_index_size} KiB
* and contains the first and last clustering value (or slice bound), its offset in the data file and width in the data file.
*
* Each {@code IndexInfo} object is serialized as follows.
diff --git a/src/java/org/apache/cassandra/io/util/FileUtils.java b/src/java/org/apache/cassandra/io/util/FileUtils.java
index ea54497fed..063e3fb40a 100644
--- a/src/java/org/apache/cassandra/io/util/FileUtils.java
+++ b/src/java/org/apache/cassandra/io/util/FileUtils.java
@@ -76,8 +76,8 @@ public final class FileUtils
private static final Logger logger = LoggerFactory.getLogger(FileUtils.class);
public static final long ONE_KB = 1024;
- public static final long ONE_MB = 1024 * ONE_KB;
- public static final long ONE_GB = 1024 * ONE_MB;
+ public static final long ONE_MIB = 1024 * ONE_KB;
+ public static final long ONE_GB = 1024 * ONE_MIB;
public static final long ONE_TB = 1024 * ONE_GB;
private static final DecimalFormat df = new DecimalFormat("#.##");
@@ -405,7 +405,7 @@ public final class FileUtils
}
else if (value.endsWith(" MiB"))
{
- result = Math.round(Double.valueOf(value.replace(" MiB", "")) * ONE_MB);
+ result = Math.round(Double.valueOf(value.replace(" MiB", "")) * ONE_MIB);
return result;
}
else if (value.endsWith(" bytes"))
@@ -434,9 +434,9 @@ public final class FileUtils
String val = df.format(d);
return val + " GiB";
}
- else if ( value >= ONE_MB )
+ else if (value >= ONE_MIB)
{
- d = value / ONE_MB;
+ d = value / ONE_MIB;
String val = df.format(d);
return val + " MiB";
}
diff --git a/src/java/org/apache/cassandra/repair/ValidationManager.java b/src/java/org/apache/cassandra/repair/ValidationManager.java
index 7077dd3626..2897aea6cb 100644
--- a/src/java/org/apache/cassandra/repair/ValidationManager.java
+++ b/src/java/org/apache/cassandra/repair/ValidationManager.java
@@ -57,7 +57,7 @@ public class ValidationManager
// The repair coordinator must hold RF trees in memory at once, so a given validation compaction can only
// use 1 / RF of the allowed space.
- long availableBytes = (DatabaseDescriptor.getRepairSessionSpaceInMegabytes() * 1048576) /
+ long availableBytes = (DatabaseDescriptor.getRepairSessionSpaceInMiB() * 1048576) /
cfs.keyspace.getReplicationStrategy().getReplicationFactor().allReplicas;
for (Range range : ranges)
diff --git a/src/java/org/apache/cassandra/service/ActiveRepairService.java b/src/java/org/apache/cassandra/service/ActiveRepairService.java
index cc72430fe4..ae57bf9ecc 100644
--- a/src/java/org/apache/cassandra/service/ActiveRepairService.java
+++ b/src/java/org/apache/cassandra/service/ActiveRepairService.java
@@ -238,16 +238,28 @@ public class ActiveRepairService implements IEndpointStateChangeSubscriber, IFai
consistent.local.cancelSession(sessionID, force);
}
- @Override
+ @Deprecated
public void setRepairSessionSpaceInMegabytes(int sizeInMegabytes)
{
- DatabaseDescriptor.setRepairSessionSpaceInMegabytes(sizeInMegabytes);
+ DatabaseDescriptor.setRepairSessionSpaceInMiB(sizeInMegabytes);
+ }
+
+ @Deprecated
+ public int getRepairSessionSpaceInMegabytes()
+ {
+ return DatabaseDescriptor.getRepairSessionSpaceInMiB();
}
@Override
- public int getRepairSessionSpaceInMegabytes()
+ public void setRepairSessionSpaceInMebibytes(int sizeInMebibytes)
{
- return DatabaseDescriptor.getRepairSessionSpaceInMegabytes();
+ DatabaseDescriptor.setRepairSessionSpaceInMiB(sizeInMebibytes);
+ }
+
+ @Override
+ public int getRepairSessionSpaceInMebibytes()
+ {
+ return DatabaseDescriptor.getRepairSessionSpaceInMiB();
}
public List getRepairStats(List schemaArgs, String rangeString)
diff --git a/src/java/org/apache/cassandra/service/ActiveRepairServiceMBean.java b/src/java/org/apache/cassandra/service/ActiveRepairServiceMBean.java
index b68cb6f507..3f03602039 100644
--- a/src/java/org/apache/cassandra/service/ActiveRepairServiceMBean.java
+++ b/src/java/org/apache/cassandra/service/ActiveRepairServiceMBean.java
@@ -29,9 +29,14 @@ public interface ActiveRepairServiceMBean
public List