-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
introduced cassandra-4.1 module, update Cassandra versions
- Loading branch information
1 parent
c992567
commit 2478e55
Showing
13 changed files
with
247 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>com.instaclustr</groupId> | ||
<artifactId>everywhere-strategy-parent</artifactId> | ||
<version>1.0.0</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>everywhere-strategy-cassandra-4.1</artifactId> | ||
<version>1.0.0</version> | ||
|
||
<name>everywhere-strategy-cassandra-4.1</name> | ||
<description>An EverywhereStrategy implementation for Apache Cassandra 4.1</description> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.cassandra</groupId> | ||
<artifactId>cassandra-all</artifactId> | ||
<version>4.1.0</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-release-plugin</artifactId> | ||
|
||
<configuration> | ||
<tagNameFormat>v4.1-@{project.version}</tagNameFormat> | ||
</configuration> | ||
</plugin> | ||
|
||
<plugin> | ||
<artifactId>jdeb</artifactId> | ||
<groupId>org.vafer</groupId> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>de.dentrassi.maven</groupId> | ||
<artifactId>rpm</artifactId> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>rpm</goal> | ||
</goals> | ||
<configuration> | ||
<requires> | ||
<require> | ||
<name>cassandra</name> | ||
<version>4.1</version> | ||
<greaterOrEqual/> | ||
</require> | ||
</requires> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Package: [[name]] | ||
Version: [[version]] | ||
Section: misc | ||
Priority: optional | ||
Architecture: all | ||
Depends: cassandra (>= 4.1) | ||
Maintainer: [[maintainer]] |
87 changes: 87 additions & 0 deletions
87
cassandra-4.1/src/main/java/org/apache/cassandra/locator/EverywhereStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package org.apache.cassandra.locator; | ||
|
||
import java.lang.reflect.Field; | ||
import java.util.Collection; | ||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
import com.google.common.collect.ImmutableMap; | ||
import org.apache.cassandra.dht.Token; | ||
import org.apache.cassandra.exceptions.ConfigurationException; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/* | ||
The strategy should be DC-aware, but DC-awareness is hardcoded to NTS throughout Cassandra. | ||
(see for example org.apache.cassandra.db.ConsistencyLevel) | ||
Hence why this implementation subclasses NTS. | ||
*/ | ||
public class EverywhereStrategy extends NetworkTopologyStrategy { | ||
|
||
private static final Logger logger = LoggerFactory.getLogger(EverywhereStrategy.class); | ||
|
||
protected final Map<String, ReplicationFactor> datacenters; | ||
|
||
public EverywhereStrategy(final String keyspaceName, | ||
final TokenMetadata tokenMetadata, | ||
final IEndpointSnitch snitch, | ||
final Map<String, String> configOptions) throws NoSuchFieldException, IllegalAccessException { | ||
super(keyspaceName, tokenMetadata, snitch, null); | ||
|
||
if (configOptions != null && configOptions.size() != 0) { | ||
throw new ConfigurationException("EverywhereStrategy doesn't accept any options."); | ||
} | ||
|
||
// yuck. but then again, why is this field private? | ||
// also, sucks that its final *and* and an unmodifiable collection. | ||
// lets fix that... | ||
final Field field = NetworkTopologyStrategy.class.getDeclaredField("datacenters"); | ||
field.setAccessible(true); | ||
|
||
this.datacenters = new HashMap<>(); | ||
|
||
field.set(this, this.datacenters); | ||
} | ||
|
||
// this gets called whenever the ring topology changes. | ||
// redetermine the RF for each DC. | ||
@Override | ||
public EndpointsForRange calculateNaturalReplicas(Token searchToken, TokenMetadata tokenMetadata) { | ||
final Set<InetAddressAndPort> endpoints = tokenMetadata.getAllEndpoints(); | ||
|
||
final Map<String, ReplicationFactor> previousDataCenters = ImmutableMap.copyOf(this.datacenters); | ||
|
||
this.datacenters.clear(); | ||
|
||
for (final InetAddressAndPort endpoint : endpoints) { | ||
if (!tokenMetadata.isMember(endpoint)) | ||
continue; | ||
|
||
final String datacenter = this.snitch.getDatacenter(endpoint); | ||
this.datacenters.merge(datacenter, ReplicationFactor.fromString("1"), (rf1, rf2) -> ReplicationFactor.fullOnly(rf1.fullReplicas + rf2.fullReplicas)); | ||
} | ||
|
||
if (!previousDataCenters.equals(this.datacenters)) { | ||
logger.info("Data center replication factors for keyspace '{}' = {}", this.keyspaceName, this.datacenters); | ||
} | ||
|
||
return super.calculateNaturalReplicas(searchToken, tokenMetadata); | ||
} | ||
|
||
@Override | ||
public Collection<String> recognizedOptions() { | ||
return Collections.emptyList(); | ||
} | ||
|
||
@Override | ||
public void validateOptions() throws ConfigurationException { | ||
super.validateOptions(); | ||
} | ||
|
||
@Override | ||
protected void validateExpectedOptions() throws ConfigurationException { | ||
// do nothing, we are not excepting any options and method in super would throw as we have not provided any | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters