From b83da7d978f1bae5f289f1561dd080d48dc4505b Mon Sep 17 00:00:00 2001 From: Yifan Cai Date: Fri, 25 Feb 2022 14:38:43 -0800 Subject: [PATCH] Correct size unit to mebibypes --- NEWS.txt | 2 +- conf/cassandra.yaml | 2 +- .../org/apache/cassandra/config/DatabaseDescriptor.java | 4 ++-- src/java/org/apache/cassandra/service/StorageProxy.java | 8 ++++---- .../org/apache/cassandra/service/StorageProxyMBean.java | 4 ++-- .../org/apache/cassandra/service/StorageProxyTest.java | 6 +++--- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/NEWS.txt b/NEWS.txt index f9626f158e..05a68868fe 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -57,7 +57,7 @@ using the provided 'sstableupgrade' tool. New features ------------ - Support for String concatenation has been added through the + operator. - - New configuration max_hints_size_per_host to limit the size of local hints files per host in megabytes. Setting to + - New configuration max_hints_size_per_host to limit the size of local hints files per host in mebibytes. Setting to non-positive value disables the limit, which is the default behavior. Setting to a positive value to ensure the total size of the hints files per host does not exceed the limit. - Added ability to configure auth caches through corresponding `nodetool` commands. diff --git a/conf/cassandra.yaml b/conf/cassandra.yaml index 0e21434986..bb8cb288fb 100644 --- a/conf/cassandra.yaml +++ b/conf/cassandra.yaml @@ -86,7 +86,7 @@ hints_flush_period: 10000ms # Maximum size for a single hints file, in megabytes. max_hints_file_size: 128MiB -# The file size limit to store hints for an unreachable host, in megabytes. +# The file size limit to store hints for an unreachable host, in mebibytes. # Once the local hints files have reached the limit, no more new hints will be created. # Set a non-positive value will disable the size limit. # max_hints_size_per_host: 0MiB diff --git a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java index ced4ad3147..af0b67a2de 100644 --- a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java +++ b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java @@ -2645,12 +2645,12 @@ public class DatabaseDescriptor return conf.max_hint_window.toMillisecondsAsInt(); } - public static void setMaxHintsSizePerHostInMb(int value) + public static void setMaxHintsSizePerHostInMiB(int value) { conf.max_hints_size_per_host = DataStorageSpec.inMebibytes(value); } - public static int getMaxHintsSizePerHostInMb() + public static int getMaxHintsSizePerHostInMiB() { return conf.max_hints_size_per_host.toMebibytesAsInt(); } diff --git a/src/java/org/apache/cassandra/service/StorageProxy.java b/src/java/org/apache/cassandra/service/StorageProxy.java index 69c231d34c..a66ccc2c88 100644 --- a/src/java/org/apache/cassandra/service/StorageProxy.java +++ b/src/java/org/apache/cassandra/service/StorageProxy.java @@ -2275,14 +2275,14 @@ public class StorageProxy implements StorageProxyMBean DatabaseDescriptor.setMaxHintWindow(ms); } - public int getMaxHintsSizePerHostInMb() + public int getMaxHintsSizePerHostInMiB() { - return DatabaseDescriptor.getMaxHintsSizePerHostInMb(); + return DatabaseDescriptor.getMaxHintsSizePerHostInMiB(); } - public void setMaxHintsSizePerHostInMb(int value) + public void setMaxHintsSizePerHostInMiB(int value) { - DatabaseDescriptor.setMaxHintsSizePerHostInMb(value); + DatabaseDescriptor.setMaxHintsSizePerHostInMiB(value); } public static boolean shouldHint(Replica replica) diff --git a/src/java/org/apache/cassandra/service/StorageProxyMBean.java b/src/java/org/apache/cassandra/service/StorageProxyMBean.java index 7ac83aec87..0f69032f4b 100644 --- a/src/java/org/apache/cassandra/service/StorageProxyMBean.java +++ b/src/java/org/apache/cassandra/service/StorageProxyMBean.java @@ -32,8 +32,8 @@ public interface StorageProxyMBean public Set getHintedHandoffDisabledDCs(); public int getMaxHintWindow(); public void setMaxHintWindow(int ms); - public int getMaxHintsSizePerHostInMb(); - public void setMaxHintsSizePerHostInMb(int value); + public int getMaxHintsSizePerHostInMiB(); + public void setMaxHintsSizePerHostInMiB(int value); public int getMaxHintsInProgress(); public void setMaxHintsInProgress(int qs); public int getHintsInProgress(); diff --git a/test/unit/org/apache/cassandra/service/StorageProxyTest.java b/test/unit/org/apache/cassandra/service/StorageProxyTest.java index 77e99523a2..1338cd675f 100644 --- a/test/unit/org/apache/cassandra/service/StorageProxyTest.java +++ b/test/unit/org/apache/cassandra/service/StorageProxyTest.java @@ -88,15 +88,15 @@ public class StorageProxyTest public void testShouldHintOnExceedingSize() throws Exception { shouldHintTest(replica -> { - final int originalHintsSizeLimit = DatabaseDescriptor.getMaxHintsSizePerHostInMb(); + final int originalHintsSizeLimit = DatabaseDescriptor.getMaxHintsSizePerHostInMiB(); try { - DatabaseDescriptor.setMaxHintsSizePerHostInMb(1); + DatabaseDescriptor.setMaxHintsSizePerHostInMiB(1); assertThat(StorageProxy.shouldHint(replica)).isFalse(); } finally { - DatabaseDescriptor.setMaxHintsSizePerHostInMb(originalHintsSizeLimit); + DatabaseDescriptor.setMaxHintsSizePerHostInMiB(originalHintsSizeLimit); } }); }