Merge branch 'cassandra-3.0' into cassandra-3.11

This commit is contained in:
Caleb Rackliffe 2021-07-15 15:02:34 -05:00
commit de1d7d76a1
3 changed files with 112 additions and 4 deletions

View File

@ -12,6 +12,7 @@
* Make sure sstables with moved starts are removed correctly in LeveledGenerations (CASSANDRA-16552)
* Upgrade jackson-databind to 2.9.10.8 (CASSANDRA-16462)
Merged from 3.0:
* Make speculative retry parameter case-insensitive for backward compatibility with 2.1 (CASSANDRA-16467)
* Push digest mismatch exceptions to trace (CASSANDRA-14900)
* Handle correctly the exceptions thrown by custom QueryHandler constructors (CASSANDRA-16703)
* Adding columns via ALTER TABLE can generate corrupt sstables (CASSANDRA-16735)

View File

@ -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));

View File

@ -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);
}
}
}