cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ifesdj...@apache.org
Subject [1/3] cassandra git commit: Fall back to even ranges calculation in clusters with vnodes when tokens are distributed unevenly
Date Fri, 12 May 2017 06:52:22 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-3.11 28f8fcb04 -> 5af7c5ff5
  refs/heads/trunk 66e5cc0d1 -> c66044f78


Fall back to even ranges calculation in clusters with vnodes when tokens are distributed unevenly

Patch by Alex Petrov; reviewed by Paulo Motta for CASSANDRA-13229.

Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/5af7c5ff
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/5af7c5ff
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/5af7c5ff

Branch: refs/heads/cassandra-3.11
Commit: 5af7c5ff5b287b10a5b49b2bf2890469cb627f2a
Parents: 28f8fcb
Author: Alex Petrov <oleksandr.petrov@gmail.com>
Authored: Fri Mar 24 17:43:02 2017 +0100
Committer: Alex Petrov <oleksandr.petrov@gmail.com>
Committed: Fri May 12 08:51:04 2017 +0200

----------------------------------------------------------------------
 CHANGES.txt                                             |  1 +
 src/java/org/apache/cassandra/dht/Splitter.java         |  7 +++++--
 .../org/apache/cassandra/service/StorageService.java    | 12 ++++++------
 3 files changed, 12 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/5af7c5ff/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 1860fd8..4f26344 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 3.11.0
+ * Fall back to even ranges calculation in clusters with vnodes when tokens are distributed
unevenly (CASSANDRA-13229)
  * Fix duration type validation to prevent overflow (CASSANDRA-13218)
  * Forbid unsupported creation of SASI indexes over partition key columns (CASSANDRA-13228)
  * Reject multiple values for a key in CQL grammar. (CASSANDRA-13369)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/5af7c5ff/src/java/org/apache/cassandra/dht/Splitter.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/dht/Splitter.java b/src/java/org/apache/cassandra/dht/Splitter.java
index 4268e83..4433f97 100644
--- a/src/java/org/apache/cassandra/dht/Splitter.java
+++ b/src/java/org/apache/cassandra/dht/Splitter.java
@@ -77,7 +77,7 @@ public abstract class Splitter
         }
         boundaries.set(boundaries.size() - 1, partitioner.getMaximumToken());
 
-        assert boundaries.size() == parts : boundaries.size() +"!="+parts+" "+boundaries+":"+localRanges;
+        assert boundaries.size() == parts : boundaries.size() + "!=" + parts + " " + boundaries
+ ":" + localRanges;
         return boundaries;
     }
 
@@ -85,8 +85,10 @@ public abstract class Splitter
     {
         List<Token> boundaries = new ArrayList<>(parts);
         BigInteger sum = BigInteger.ZERO;
+
         int i = 0;
-        while (boundaries.size() < parts - 1)
+        final int rangesCount = localRanges.size();
+        while (boundaries.size() < parts - 1 && i < rangesCount - 1)
         {
             Range<Token> r = localRanges.get(i);
             Range<Token> nextRange = localRanges.get(i + 1);
@@ -96,6 +98,7 @@ public abstract class Splitter
             BigInteger currentRangeWidth = valueForToken(right).subtract(valueForToken(r.left));
             BigInteger nextRangeWidth = valueForToken(nextRight).subtract(valueForToken(nextRange.left));
             sum = sum.add(currentRangeWidth);
+
             // does this or next range take us beyond the per part limit?
             if (sum.compareTo(perPart) > 0 || sum.add(nextRangeWidth).compareTo(perPart)
> 0)
             {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/5af7c5ff/src/java/org/apache/cassandra/service/StorageService.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/StorageService.java b/src/java/org/apache/cassandra/service/StorageService.java
index e60924f..749c6a9 100644
--- a/src/java/org/apache/cassandra/service/StorageService.java
+++ b/src/java/org/apache/cassandra/service/StorageService.java
@@ -5200,17 +5200,17 @@ public class StorageService extends NotificationBroadcasterSupport
implements IE
      * etc.
      *
      * The final entry in the returned list will always be the partitioner maximum tokens
upper key bound
-     *
-     * @param localRanges
-     * @param partitioner
-     * @param dataDirectories
-     * @return
      */
     public static List<PartitionPosition> getDiskBoundaries(List<Range<Token>>
localRanges, IPartitioner partitioner, Directories.DataDirectory[] dataDirectories)
     {
         assert partitioner.splitter().isPresent();
         Splitter splitter = partitioner.splitter().get();
-        List<Token> boundaries = splitter.splitOwnedRanges(dataDirectories.length,
localRanges, DatabaseDescriptor.getNumTokens() > 1);
+        boolean dontSplitRanges = DatabaseDescriptor.getNumTokens() > 1;
+        List<Token> boundaries = splitter.splitOwnedRanges(dataDirectories.length,
localRanges, dontSplitRanges);
+        // If we can't split by ranges, split evenly to ensure utilisation of all disks
+        if (dontSplitRanges && boundaries.size() < dataDirectories.length)
+            boundaries = splitter.splitOwnedRanges(dataDirectories.length, localRanges, false);
+
         List<PartitionPosition> diskBoundaries = new ArrayList<>();
         for (int i = 0; i < boundaries.size() - 1; i++)
             diskBoundaries.add(boundaries.get(i).maxKeyBound());


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org


Mime
View raw message