cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject [1/5] cassandra git commit: Avoid exposing compaction strategy index externally
Date Tue, 26 Dec 2017 12:53:09 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-3.11 b28fc1bff -> 9337ca316
  refs/heads/trunk d52326af6 -> 702d9f1f0


Avoid exposing compaction strategy index externally

Patch by Paulo Motta; Reviewed by Marcus Eriksson for CASSANDRA-14082


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

Branch: refs/heads/cassandra-3.11
Commit: e208a6a210d172b991b40fb66a4763e30b3e4d7d
Parents: b28fc1b
Author: Paulo Motta <pauloricardomg@gmail.com>
Authored: Thu Dec 14 08:14:35 2017 +1100
Committer: Paulo Motta <paulo@apache.org>
Committed: Tue Dec 26 23:18:00 2017 +1100

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../db/compaction/CompactionManager.java        | 20 ++++++++++++--------
 .../compaction/CompactionStrategyManager.java   |  6 ------
 .../cassandra/db/compaction/Scrubber.java       |  4 ++--
 4 files changed, 15 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/e208a6a2/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 5a1b891..8a6b61a 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 3.11.2
+ * Avoid exposing compaction strategy index externally (CASSANDRA-14082)
  * Prevent continuous schema exchange between 3.0 and 3.11 nodes (CASSANDRA-14109)
  * Fix imbalanced disks when replacing node with same address with JBOD (CASSANDRA-14084)
  * Reload compaction strategies when disk boundaries are invalidated (CASSANDRA-13948)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e208a6a2/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/compaction/CompactionManager.java b/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
index 9cd18a9..e158982 100644
--- a/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
+++ b/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
@@ -520,7 +520,7 @@ public class CompactionManager implements CompactionManagerMBean
             return AllSSTableOpStatus.ABORTED;
         }
 
-        final List<PartitionPosition> diskBoundaries = cfs.getDiskBoundaries().positions;
+        final DiskBoundaries diskBoundaries = cfs.getDiskBoundaries();
 
         return parallelAllSSTableOperation(cfs, new OneSSTableOperation()
         {
@@ -531,8 +531,7 @@ public class CompactionManager implements CompactionManagerMBean
                 Set<SSTableReader> needsRelocation = originals.stream().filter(s ->
!inCorrectLocation(s)).collect(Collectors.toSet());
                 transaction.cancel(Sets.difference(originals, needsRelocation));
 
-                Map<Integer, List<SSTableReader>> groupedByDisk = needsRelocation.stream().collect(Collectors.groupingBy((s)
->
-                                                                                        
                                cfs.getCompactionStrategyManager().getCompactionStrategyIndex(s)));
+                Map<Integer, List<SSTableReader>> groupedByDisk = groupByDiskIndex(needsRelocation);
 
                 int maxSize = 0;
                 for (List<SSTableReader> diskSSTables : groupedByDisk.values())
@@ -548,18 +547,23 @@ public class CompactionManager implements CompactionManagerMBean
                 return mixedSSTables;
             }
 
+            public Map<Integer, List<SSTableReader>> groupByDiskIndex(Set<SSTableReader>
needsRelocation)
+            {
+                return needsRelocation.stream().collect(Collectors.groupingBy((s) -> diskBoundaries.getDiskIndex(s)));
+            }
+
             private boolean inCorrectLocation(SSTableReader sstable)
             {
                 if (!cfs.getPartitioner().splitter().isPresent())
                     return true;
-                int directoryIndex = cfs.getCompactionStrategyManager().getCompactionStrategyIndex(sstable);
-                Directories.DataDirectory[] locations = cfs.getDirectories().getWriteableLocations();
 
-                Directories.DataDirectory location = locations[directoryIndex];
-                PartitionPosition diskLast = diskBoundaries.get(directoryIndex);
+                int diskIndex = diskBoundaries.getDiskIndex(sstable);
+                File diskLocation = diskBoundaries.directories.get(diskIndex).location;
+                PartitionPosition diskLast = diskBoundaries.positions.get(diskIndex);
+
                 // the location we get from directoryIndex is based on the first key in the
sstable
                 // now we need to make sure the last key is less than the boundary as well:
-                return sstable.descriptor.directory.getAbsolutePath().startsWith(location.location.getAbsolutePath())
&& sstable.last.compareTo(diskLast) <= 0;
+                return sstable.descriptor.directory.getAbsolutePath().startsWith(diskLocation.getAbsolutePath())
&& sstable.last.compareTo(diskLast) <= 0;
             }
 
             @Override

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e208a6a2/src/java/org/apache/cassandra/db/compaction/CompactionStrategyManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/compaction/CompactionStrategyManager.java b/src/java/org/apache/cassandra/db/compaction/CompactionStrategyManager.java
index efaedc8..39d253b 100644
--- a/src/java/org/apache/cassandra/db/compaction/CompactionStrategyManager.java
+++ b/src/java/org/apache/cassandra/db/compaction/CompactionStrategyManager.java
@@ -271,12 +271,6 @@ public class CompactionStrategyManager implements INotificationConsumer
      * @param sstable
      * @return
      */
-    public int getCompactionStrategyIndex(SSTableReader sstable)
-    {
-        maybeReloadDiskBoundaries();
-        return compactionStrategyIndexFor(sstable);
-    }
-
     @VisibleForTesting
     protected int compactionStrategyIndexFor(SSTableReader sstable)
     {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e208a6a2/src/java/org/apache/cassandra/db/compaction/Scrubber.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/compaction/Scrubber.java b/src/java/org/apache/cassandra/db/compaction/Scrubber.java
index c189c0b..ed107d7 100644
--- a/src/java/org/apache/cassandra/db/compaction/Scrubber.java
+++ b/src/java/org/apache/cassandra/db/compaction/Scrubber.java
@@ -99,8 +99,8 @@ public class Scrubber implements Closeable
 
         List<SSTableReader> toScrub = Collections.singletonList(sstable);
 
-        int locIndex = cfs.getCompactionStrategyManager().getCompactionStrategyIndex(sstable);
-        this.destination = cfs.getDirectories().getLocationForDisk(cfs.getDirectories().getWriteableLocations()[locIndex]);
+
+        this.destination = cfs.getDirectories().getLocationForDisk(cfs.getDiskBoundaries().getCorrectDiskForSSTable(sstable));
         this.isCommutative = cfs.metadata.isCounter();
 
         boolean hasIndexFile = (new File(sstable.descriptor.filenameFor(Component.PRIMARY_INDEX))).exists();


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


Mime
View raw message