cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From marc...@apache.org
Subject [1/2] cassandra git commit: Make sstablescrub check both the repaired and unrepaired leveled manifests
Date Wed, 17 Dec 2014 11:37:07 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk e6c5982fa -> 417563a59


Make sstablescrub check both the repaired and unrepaired leveled manifests

Patch by marcuse; reviewed by cyeksigian for CASSANDRA-8432


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

Branch: refs/heads/trunk
Commit: 6f98c6c4ed2e2b3d427cd10c2b2ada9c60b35acd
Parents: d5e5f98
Author: Marcus Eriksson <marcuse@apache.org>
Authored: Mon Dec 8 11:45:59 2014 +0100
Committer: Marcus Eriksson <marcuse@apache.org>
Committed: Wed Dec 17 12:31:40 2014 +0100

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../cassandra/tools/StandaloneScrubber.java     | 52 ++++++++++++++------
 2 files changed, 38 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/6f98c6c4/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 410d49a..9ec3585 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.1.3
+ * Make sstablescrub check leveled manifest again (CASSANDRA-8432)
  * Check first/last keys in sstable when giving out positions (CASSANDRA-8458)
  * Disable mmap on Windows (CASSANDRA-6993)
  * Add missing ConsistencyLevels to cassandra-stress (CASSANDRA-8253)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6f98c6c4/src/java/org/apache/cassandra/tools/StandaloneScrubber.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/tools/StandaloneScrubber.java b/src/java/org/apache/cassandra/tools/StandaloneScrubber.java
index 42799a5..2a9763b 100644
--- a/src/java/org/apache/cassandra/tools/StandaloneScrubber.java
+++ b/src/java/org/apache/cassandra/tools/StandaloneScrubber.java
@@ -21,6 +21,10 @@ package org.apache.cassandra.tools;
 import java.io.File;
 import java.util.*;
 
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
 import org.apache.commons.cli.*;
 
 import org.apache.cassandra.config.DatabaseDescriptor;
@@ -28,9 +32,11 @@ import org.apache.cassandra.config.Schema;
 import org.apache.cassandra.db.ColumnFamilyStore;
 import org.apache.cassandra.db.Directories;
 import org.apache.cassandra.db.Keyspace;
+import org.apache.cassandra.db.compaction.AbstractCompactionStrategy;
 import org.apache.cassandra.db.compaction.LeveledCompactionStrategy;
 import org.apache.cassandra.db.compaction.LeveledManifest;
 import org.apache.cassandra.db.compaction.Scrubber;
+import org.apache.cassandra.db.compaction.WrappingCompactionStrategy;
 import org.apache.cassandra.io.sstable.*;
 import org.apache.cassandra.utils.JVMStabilityInspector;
 import org.apache.cassandra.utils.OutputHandler;
@@ -95,14 +101,6 @@ public class StandaloneScrubber
             }
             System.out.println(String.format("Pre-scrub sstables snapshotted into snapshot
%s", snapshotName));
 
-            LeveledManifest manifest = null;
-            // If leveled, load the manifest
-            if (cfs.getCompactionStrategy() instanceof LeveledCompactionStrategy)
-            {
-                int maxSizeInMB = (int)((cfs.getCompactionStrategy().getMaxSSTableBytes())
/ (1024L * 1024L));
-                manifest = LeveledManifest.create(cfs, maxSizeInMB, sstables);
-            }
-
             if (!options.manifestCheckOnly)
             {
                 for (SSTableReader sstable : sstables)
@@ -131,9 +129,8 @@ public class StandaloneScrubber
                 }
             }
 
-            // Check (and repair) manifest
-            if (manifest != null)
-                checkManifest(manifest);
+            // Check (and repair) manifests
+            checkManifest(cfs.getCompactionStrategy(), cfs, sstables);
 
             SSTableDeletingTask.waitForDeletions();
             System.exit(0); // We need that to stop non daemonized threads
@@ -147,11 +144,36 @@ public class StandaloneScrubber
         }
     }
 
-    private static void checkManifest(LeveledManifest manifest)
+    private static void checkManifest(AbstractCompactionStrategy strategy, ColumnFamilyStore
cfs, Collection<SSTableReader> sstables)
     {
-        System.out.println(String.format("Checking leveled manifest"));
-        for (int i = 1; i <= manifest.getLevelCount(); ++i)
-            manifest.repairOverlappingSSTables(i);
+        WrappingCompactionStrategy wrappingStrategy = (WrappingCompactionStrategy)strategy;
+        int maxSizeInMB = (int)((cfs.getCompactionStrategy().getMaxSSTableBytes()) / (1024L
* 1024L));
+        if (wrappingStrategy.getWrappedStrategies().size() == 2 && wrappingStrategy.getWrappedStrategies().iterator().next()
instanceof LeveledCompactionStrategy)
+        {
+            System.out.println("Checking leveled manifest");
+            Predicate<SSTableReader> repairedPredicate = new Predicate<SSTableReader>()
+            {
+                @Override
+                public boolean apply(SSTableReader sstable)
+                {
+                    return sstable.isRepaired();
+                }
+            };
+
+            List<SSTableReader> repaired = Lists.newArrayList(Iterables.filter(sstables,
repairedPredicate));
+            List<SSTableReader> unRepaired = Lists.newArrayList(Iterables.filter(sstables,
Predicates.not(repairedPredicate)));
+
+            LeveledManifest repairedManifest = LeveledManifest.create(cfs, maxSizeInMB, repaired);
+            for (int i = 1; i < repairedManifest.getLevelCount(); i++)
+            {
+                repairedManifest.repairOverlappingSSTables(i);
+            }
+            LeveledManifest unRepairedManifest = LeveledManifest.create(cfs, maxSizeInMB,
unRepaired);
+            for (int i = 1; i < unRepairedManifest.getLevelCount(); i++)
+            {
+                unRepairedManifest.repairOverlappingSSTables(i);
+            }
+        }
     }
 
     private static class Options


Mime
View raw message