You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by ma...@apache.org on 2021/07/15 20:16:19 UTC
[cassandra] branch cassandra-3.0 updated: Make speculative retry
parameter case-insensitive for backward compatibility with 2.1
This is an automated email from the ASF dual-hosted git repository.
maedhroz pushed a commit to branch cassandra-3.0
in repository https://gitbox.apache.org/repos/asf/cassandra.git
The following commit(s) were added to refs/heads/cassandra-3.0 by this push:
new e8f961f Make speculative retry parameter case-insensitive for backward compatibility with 2.1
e8f961f is described below
commit e8f961f403a1a55a4837a576d744288599962d5a
Author: Sumanth Pasupuleti <sp...@netflix.com>
AuthorDate: Fri Feb 19 23:25:02 2021 -0800
Make speculative retry parameter case-insensitive for backward compatibility with 2.1
patch by Sumanth Pasupuleti; reviewed by Caleb Rackliffe and Ekaterina Dimitrova for CASSANDRA-16467
---
CHANGES.txt | 1 +
.../cassandra/schema/SpeculativeRetryParam.java | 9 +-
.../schema/SpeculativeRetryParamParseTest.java | 106 +++++++++++++++++++++
3 files changed, 112 insertions(+), 4 deletions(-)
diff --git a/CHANGES.txt b/CHANGES.txt
index 0c263e8..be040fc 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
3.0.25:
+ * Make speculative retry parameter case-insensitive for backward compatibility with 2.1 (CASSANDRA-16467)
* Push digest mismatch exceptions to trace (CASSANDRA-14900)
* Support long names in nodetool output (CASSANDRA-14162)
* Handle correctly the exceptions thrown by custom QueryHandler constructors (CASSANDRA-16703)
diff --git a/src/java/org/apache/cassandra/schema/SpeculativeRetryParam.java b/src/java/org/apache/cassandra/schema/SpeculativeRetryParam.java
index 43447f0..5ecde41 100644
--- a/src/java/org/apache/cassandra/schema/SpeculativeRetryParam.java
+++ b/src/java/org/apache/cassandra/schema/SpeculativeRetryParam.java
@@ -89,7 +89,8 @@ public final class SpeculativeRetryParam
public static SpeculativeRetryParam fromString(String value)
{
- if (value.toLowerCase(Locale.ENGLISH).endsWith("ms"))
+ String upperCaseValue = value.toUpperCase(Locale.ENGLISH);
+ if (upperCaseValue.endsWith("MS"))
{
try
{
@@ -101,7 +102,7 @@ public final class SpeculativeRetryParam
}
}
- if (value.toUpperCase(Locale.ENGLISH).endsWith(Kind.PERCENTILE.toString()))
+ if (upperCaseValue.endsWith(Kind.PERCENTILE.toString()))
{
double threshold;
try
@@ -121,10 +122,10 @@ public final class SpeculativeRetryParam
TableParams.Option.SPECULATIVE_RETRY));
}
- if (value.equals(Kind.NONE.toString()))
+ if (upperCaseValue.equals(Kind.NONE.toString()))
return NONE;
- if (value.equals(Kind.ALWAYS.toString()))
+ if (upperCaseValue.equals(Kind.ALWAYS.toString()))
return ALWAYS;
throw new ConfigurationException(format("Invalid value %s for option '%s'", value, TableParams.Option.SPECULATIVE_RETRY));
diff --git a/test/unit/org/apache/cassandra/schema/SpeculativeRetryParamParseTest.java b/test/unit/org/apache/cassandra/schema/SpeculativeRetryParamParseTest.java
new file mode 100644
index 0000000..3dd2c29
--- /dev/null
+++ b/test/unit/org/apache/cassandra/schema/SpeculativeRetryParamParseTest.java
@@ -0,0 +1,106 @@
+/*
+ * 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.schema;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.junit.Test;
+import org.junit.experimental.runners.Enclosed;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import org.apache.cassandra.exceptions.ConfigurationException;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.runners.Parameterized.Parameters;
+
+@RunWith(Enclosed.class)
+public class SpeculativeRetryParamParseTest
+{
+
+ @RunWith(Parameterized.class)
+ public static class SuccessfulParseTest
+ {
+ private final String string;
+ private final SpeculativeRetryParam expectedValue;
+
+ public SuccessfulParseTest(String string, SpeculativeRetryParam expectedValue)
+ {
+ this.string = string;
+ this.expectedValue = expectedValue;
+ }
+
+ @Parameters
+ public static Collection<Object[]> generateData()
+ {
+ return Arrays.asList(new Object[][]{
+ { "NONE", SpeculativeRetryParam.none() },
+ { "ALWAYS", SpeculativeRetryParam.always() },
+ { "10PERCENTILE", SpeculativeRetryParam.percentile(10.0) },
+ { "121.1ms", SpeculativeRetryParam.custom(121.1) },
+ { "21.7MS", SpeculativeRetryParam.custom(21.7) },
+ { "None", SpeculativeRetryParam.none() },
+ { "none", SpeculativeRetryParam.none() },
+ { "Always", SpeculativeRetryParam.always() },
+ { "always", SpeculativeRetryParam.always() },
+ { "21.1percentile", SpeculativeRetryParam.percentile(21.1) },
+ }
+ );
+ }
+
+ @Test
+ public void testParameterParse()
+ {
+ assertEquals(expectedValue, SpeculativeRetryParam.fromString(string));
+ }
+ }
+
+ @RunWith(Parameterized.class)
+ public static class FailedParseTest
+ {
+ private final String string;
+
+ public FailedParseTest(String string)
+ {
+ this.string = string;
+ }
+
+ @Parameters
+ public static Collection<Object[]> generateData()
+ {
+ return Arrays.asList(new Object[][]{
+ { "" },
+ { "-0.1PERCENTILE" },
+ { "100.1PERCENTILE" },
+ { "xPERCENTILE" },
+ { "xyzms" },
+ { "X" },
+ { "21.1p" }
+ }
+ );
+ }
+
+ @Test(expected = ConfigurationException.class)
+ public void testParameterParse()
+ {
+ SpeculativeRetryParam.fromString(string);
+ }
+ }
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org