Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(in-tree work) Remove enum Versions.Major, replacing all usages with Semver4j #1

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .build/build-resolver.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
<resolver:remoterepos id="all">
<remoterepo id="resolver-central" url="${artifact.remoteRepository.central}"/>
<remoterepo id="resolver-apache" url="${artifact.remoteRepository.apache}"/>
<remoterepo id="resolver-apache-snapshots" url="${artifact.remoteRepository.apache-snaphot}" snapshots="true"/>
</resolver:remoterepos>

<macrodef name="resolve">
Expand Down
5 changes: 3 additions & 2 deletions build.properties.default
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Maven2 Repository Locations (you can override these in "build.properties" to point to a local proxy, e.g. Nexus)
artifact.remoteRepository.central: https://repo1.maven.org/maven2
artifact.remoteRepository.apache: https://repo.maven.apache.org/maven2
artifact.remoteRepository.central: https://repo1.maven.org/maven2
artifact.remoteRepository.apache: https://repo.maven.apache.org/maven2
artifact.remoteRepository.apache-snaphot: https://repository.apache.org/content/groups/snapshots/

2 changes: 1 addition & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@
<dependency groupId="org.mockito" artifactId="mockito-core" version="3.2.4" scope="test"/>
<dependency groupId="org.quicktheories" artifactId="quicktheories" version="0.26" scope="test"/>
<dependency groupId="com.google.code.java-allocation-instrumenter" artifactId="java-allocation-instrumenter" version="${allocation-instrumenter.version}" />
<dependency groupId="org.apache.cassandra" artifactId="dtest-api" version="0.0.7" scope="test"/>
<dependency groupId="org.apache.cassandra" artifactId="dtest-api" version="0.0.8-SNAPSHOT" scope="test"/>
<dependency groupId="org.reflections" artifactId="reflections" version="0.9.12" />
<dependency groupId="org.apache.hadoop" artifactId="hadoop-core" version="1.0.3" scope="provided">
<exclusion groupId="org.mortbay.jetty" artifactId="servlet-api"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ private IInvokableInstance newInstance(int generation)
if (instanceInitializer != null)
instanceInitializer.accept(classLoader, config.num());
return Instance.transferAdhoc((SerializableBiFunction<IInstanceConfig, ClassLoader, Instance>)Instance::new, classLoader)
.apply(config.forVersion(version.major), classLoader);
.apply(config.forVersion(version.version), classLoader);
}

public IInstanceConfig config()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,24 @@
package org.apache.cassandra.distributed.impl;

import java.io.File;
import java.lang.reflect.Field;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
import java.util.Arrays;
import java.util.Collections;
import java.util.EnumSet;
import java.util.Map;
import java.util.TreeMap;
import java.util.UUID;
import java.util.function.Function;

import com.vdurmont.semver4j.Semver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.apache.cassandra.config.YamlConfigurationLoader;
import org.apache.cassandra.distributed.api.Feature;
import org.apache.cassandra.distributed.api.IInstanceConfig;
import org.apache.cassandra.distributed.shared.NetworkTopology;
import org.apache.cassandra.distributed.shared.Shared;
import org.apache.cassandra.distributed.shared.Versions;
import org.apache.cassandra.distributed.upgrade.UpgradeTestBase;
import org.apache.cassandra.locator.InetAddressAndPort;
import org.apache.cassandra.locator.SimpleSeedProvider;

Expand Down Expand Up @@ -284,15 +282,15 @@ private static String[] datadirs(int datadirCount, File root, int nodeNum)
return datadirs;
}

public InstanceConfig forVersion(Versions.Major major)
public InstanceConfig forVersion(Semver version)
{
switch (major)
{
case v4: return this;
default: return new InstanceConfig(this)
// Versions before 4.0 need to set 'seed_provider' without specifying the port
if (UpgradeTestBase.v40.compareTo(version) < 0)
return this;
else
return new InstanceConfig(this)
.set("seed_provider", new ParameterizedClass(SimpleSeedProvider.class.getName(),
Collections.singletonMap("seeds", "127.0.0.1")));
}
}

public String toString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class CompactStorage3to4UpgradeTest extends UpgradeTestBase
public void testNullClusteringValues() throws Throwable
{
new TestCase().nodes(1)
.upgrade(Versions.Major.v30, Versions.Major.v4)
.upgradesFrom(v30)
.withConfig(config -> config.with(GOSSIP, NETWORK, NATIVE_PROTOCOL))
.setup(cluster -> {
String create = "CREATE TABLE %s.%s(k int, c1 int, c2 int, v int, PRIMARY KEY (k, c1, c2)) " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void compactStorageColumnDeleteTest() throws Throwable
new TestCase()
.nodes(2)
.nodesToUpgrade(2)
.upgrade(Versions.Major.v30, Versions.Major.v4)
.upgradesFrom(v30)
.setup((cluster) -> {
cluster.schemaChange("CREATE TABLE " + KEYSPACE + ".tbl (pk int, ck int, v int, PRIMARY KEY (pk, ck)) WITH COMPACT STORAGE");
})
Expand Down Expand Up @@ -68,7 +68,7 @@ public void compactStoragePagingTest() throws Throwable
new TestCase()
.nodes(2)
.nodesToUpgrade(2)
.upgrade(Versions.Major.v30, Versions.Major.v4)
.upgradesFrom(v30)
.setup((cluster) -> {
cluster.schemaChange("CREATE TABLE " + KEYSPACE + ".tbl (pk int, ck int, v int, PRIMARY KEY (pk, ck)) WITH COMPACT STORAGE");
for (int i = 1; i < 10; i++)
Expand All @@ -94,7 +94,7 @@ public void compactStorageImplicitNullInClusteringTest() throws Throwable
new TestCase()
.nodes(2)
.nodesToUpgrade(2)
.upgrade(Versions.Major.v30, Versions.Major.v4)
.upgradesFrom(v30)
.setup((cluster) -> {
cluster.schemaChange("CREATE TABLE " + KEYSPACE + ".tbl (pk int, ck1 int, ck2 int, v int, PRIMARY KEY (pk, ck1, ck2)) WITH COMPACT STORAGE");
})
Expand All @@ -113,7 +113,7 @@ public void compactStorageHiddenColumnTest() throws Throwable
new TestCase()
.nodes(2)
.nodesToUpgrade(2)
.upgrade(Versions.Major.v30, Versions.Major.v4)
.upgradesFrom(v30)
.setup((cluster) -> {
cluster.schemaChange("CREATE TABLE " + KEYSPACE + ".tbl (pk int, ck int, PRIMARY KEY (pk, ck)) WITH COMPACT STORAGE");
})
Expand Down Expand Up @@ -145,7 +145,7 @@ public void compactStorageUpgradeTest() throws Throwable
new TestCase()
.nodes(2)
.nodesToUpgrade(1, 2)
.upgrade(Versions.Major.v30, Versions.Major.v4)
.upgradesFrom(v30)
.withConfig(config -> config.with(GOSSIP, NETWORK))
.setup((cluster) -> {
cluster.schemaChange("CREATE TABLE " + KEYSPACE + ".tbl (pk int, ck int, PRIMARY KEY (pk, ck)) WITH COMPACT STORAGE");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void testReads() throws Throwable
// CASSANDRA-16582: group-by across mixed version cluster would fail with ArrayIndexOutOfBoundException
new UpgradeTestBase.TestCase()
.nodes(2)
.upgrade(Versions.Major.v3X, Versions.Major.v4)
.upgradesFrom(v3X)
.nodesToUpgrade(1)
.withConfig(config -> config.with(GOSSIP, NETWORK))
.setup(cluster -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@
import java.util.List;
import java.util.UUID;

import com.vdurmont.semver4j.Semver;

import org.apache.cassandra.distributed.api.ConsistencyLevel;
import org.apache.cassandra.distributed.api.ICoordinator;
import org.apache.cassandra.distributed.shared.Versions;
import org.apache.cassandra.exceptions.ReadTimeoutException;
import org.apache.cassandra.exceptions.WriteTimeoutException;
import org.apache.cassandra.net.Verb;
Expand All @@ -40,6 +41,7 @@
import static org.junit.Assert.assertFalse;
import static java.lang.String.format;


public class MixedModeAvailabilityTestBase extends UpgradeTestBase
{
private static final int NUM_NODES = 3;
Expand All @@ -49,20 +51,25 @@ public class MixedModeAvailabilityTestBase extends UpgradeTestBase
new Tester(ALL, ONE));


protected static void testAvailability(Versions.Major initial, Versions.Major... upgrade) throws Throwable
protected static void testAvailability(Semver initial) throws Throwable
{
testAvailability(initial, UpgradeTestBase.CURRENT);
}

protected static void testAvailability(Semver initial, Semver upgrade) throws Throwable
{
testAvailability(true, initial, upgrade);
testAvailability(false, initial, upgrade);
}

private static void testAvailability(boolean upgradedCoordinator,
Versions.Major initial,
Versions.Major... upgrade) throws Throwable
Semver initial,
Semver upgrade) throws Throwable
{
new TestCase()
.nodes(NUM_NODES)
.nodesToUpgrade(upgradedCoordinator ? 1 : 2)
.upgrade(initial, upgrade)
.upgrades(initial, upgrade)
.withConfig(config -> config.set("read_request_timeout_in_ms", SECONDS.toMillis(2))
.set("write_request_timeout_in_ms", SECONDS.toMillis(2)))
.setup(c -> c.schemaChange(withKeyspace("CREATE TABLE %s.t (k uuid, c int, v int, PRIMARY KEY (k, c))")))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ public class MixedModeAvailabilityV22Test extends MixedModeAvailabilityTestBase
@Test
public void testAvailabilityV22ToV30() throws Throwable
{
testAvailability(Versions.Major.v22, Versions.Major.v30);
testAvailability(v22, v30);
}

@Test
public void testAvailabilityV22ToV3X() throws Throwable
{
testAvailability(Versions.Major.v22, Versions.Major.v3X);
testAvailability(v22, v3X);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,8 @@
public class MixedModeAvailabilityV30Test extends MixedModeAvailabilityTestBase
{
@Test
public void testAvailabilityV30ToV3X() throws Throwable
public void testAvailability() throws Throwable
{
testAvailability(Versions.Major.v30, Versions.Major.v3X);
}

@Test
public void testAvailabilityV30ToV4() throws Throwable
{
testAvailability(Versions.Major.v30, Versions.Major.v4);
testAvailability(v30);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
public class MixedModeAvailabilityV3XTest extends MixedModeAvailabilityTestBase
{
@Test
public void testAvailabilityV3XToV4() throws Throwable
public void testAvailability() throws Throwable
{
testAvailability(Versions.Major.v3X, Versions.Major.v4);
testAvailability(v3X);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@
import java.util.ArrayList;
import java.util.List;

import com.vdurmont.semver4j.Semver;

import org.apache.cassandra.distributed.UpgradeableCluster;
import org.apache.cassandra.distributed.api.ConsistencyLevel;
import org.apache.cassandra.distributed.api.IMessageFilters;
import org.apache.cassandra.distributed.shared.Versions;
import org.apache.cassandra.exceptions.WriteFailureException;
import org.apache.cassandra.exceptions.WriteTimeoutException;

Expand All @@ -42,15 +43,20 @@ public class MixedModeBatchTestBase extends UpgradeTestBase
{
private static final int KEYS_PER_BATCH = 10;

protected void testSimpleStrategy(Versions.Major from, Versions.Major to, boolean isLogged) throws Throwable
protected void testSimpleStrategy(Semver from, boolean isLogged) throws Throwable
{
testSimpleStrategy(from, UpgradeTestBase.CURRENT, isLogged);
}

protected void testSimpleStrategy(Semver from, Semver to, boolean isLogged) throws Throwable
{
String insert = "INSERT INTO test_simple.names (key, name) VALUES (%d, '%s')";
String select = "SELECT * FROM test_simple.names WHERE key = ?";

new TestCase()
.nodes(3)
.nodesToUpgrade(1, 2)
.upgrade(from, to)
.upgrades(from, to)
.setup(cluster -> {
cluster.schemaChange("CREATE KEYSPACE test_simple WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 2};");
cluster.schemaChange("CREATE TABLE test_simple.names (key int PRIMARY KEY, name text)");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import com.vdurmont.semver4j.Semver;

import org.apache.cassandra.distributed.UpgradeableCluster;
import org.apache.cassandra.distributed.api.ConsistencyLevel;
import org.apache.cassandra.distributed.api.IUpgradeableInstance;
import org.apache.cassandra.distributed.shared.Versions;

import static java.lang.String.format;
import static java.util.concurrent.TimeUnit.SECONDS;
Expand All @@ -39,7 +40,12 @@

public class MixedModeConsistencyTestBase extends UpgradeTestBase
{
protected static void testConsistency(Versions.Major initial, Versions.Major... upgrade) throws Throwable
protected static void testConsistency(Semver initial) throws Throwable
{
testConsistency(initial, UpgradeTestBase.CURRENT);
}

protected static void testConsistency(Semver initial, Semver upgrade) throws Throwable
{
List<Tester> testers = new ArrayList<>();
testers.addAll(Tester.create(1, ALL));
Expand All @@ -49,7 +55,7 @@ protected static void testConsistency(Versions.Major initial, Versions.Major...
new TestCase()
.nodes(3)
.nodesToUpgrade(1)
.upgrade(initial, upgrade)
.upgrades(initial, upgrade)
.withConfig(config -> config.set("read_request_timeout_in_ms", SECONDS.toMillis(30))
.set("write_request_timeout_in_ms", SECONDS.toMillis(30)))
.setup(cluster -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ public class MixedModeConsistencyV22Test extends MixedModeConsistencyTestBase
@Test
public void testConsistencyV22ToV30() throws Throwable
{
testConsistency(Versions.Major.v22, Versions.Major.v30);
testConsistency(v22, v30);
}

@Test
public void testConsistencyV22ToV3X() throws Throwable
{
testConsistency(Versions.Major.v22, Versions.Major.v3X);
testConsistency(v22, v3X);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,8 @@
public class MixedModeConsistencyV30Test extends MixedModeConsistencyTestBase
{
@Test
public void testConsistencyV30ToV3X() throws Throwable
public void testConsistency() throws Throwable
{
testConsistency(Versions.Major.v30, Versions.Major.v3X);
}

@Test
public void testConsistencyV30ToV4() throws Throwable
{
testConsistency(Versions.Major.v30, Versions.Major.v4);
testConsistency(v30);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
public class MixedModeConsistencyV3XTest extends MixedModeConsistencyTestBase
{
@Test
public void testConsistencyV3XToV4() throws Throwable
public void testConsistency() throws Throwable
{
testConsistency(Versions.Major.v3X, Versions.Major.v4);
testConsistency(v3X);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ public class MixedModeFrom2LoggedBatchTest extends MixedModeBatchTestBase
@Test
public void testSimpleStrategy22to30() throws Throwable
{
testSimpleStrategy(Versions.Major.v22, Versions.Major.v30, true);
testSimpleStrategy(v22, v30, true);
}

@Test
public void testSimpleStrategy22to3X() throws Throwable
{
testSimpleStrategy(Versions.Major.v22, Versions.Major.v3X, true);
testSimpleStrategy(v22, v3X, true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ public class MixedModeFrom2ReplicationTest extends MixedModeReplicationTestBase
@Test
public void testSimpleStrategy22to30() throws Throwable
{
testSimpleStrategy(Versions.Major.v22, Versions.Major.v30);
testSimpleStrategy(v22, v30);
}

@Test
public void testSimpleStrategy22to3X() throws Throwable
{
testSimpleStrategy(Versions.Major.v22, Versions.Major.v3X);
testSimpleStrategy(v22, v3X);
}
}
Loading