You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by yu...@apache.org on 2015/08/11 03:50:04 UTC

[1/3] cassandra git commit: 2.1 format sstable filenames with tmp are not handled by 3.0

Repository: cassandra
Updated Branches:
  refs/heads/cassandra-3.0 1a9286c07 -> 76ca69717
  refs/heads/trunk 1a1c5a008 -> e8ac7edb7


2.1 format sstable filenames with tmp are not handled by 3.0

patch by stefania; reviewed by yukim for CASSANDRA-10006


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

Branch: refs/heads/cassandra-3.0
Commit: 76ca69717c3072996095057115133ca3b6ca25cd
Parents: 1a9286c
Author: Stefania Alborghetti <st...@datastax.com>
Authored: Mon Aug 10 20:21:47 2015 -0500
Committer: Yuki Morishita <yu...@apache.org>
Committed: Mon Aug 10 20:21:47 2015 -0500

----------------------------------------------------------------------
 CHANGES.txt                                     |   1 +
 .../org/apache/cassandra/db/SystemKeyspace.java |   6 ++---
 .../apache/cassandra/io/sstable/Descriptor.java |  27 ++++++++++++-------
 ...pactions_in_progress-ka-1-CompressionInfo.db | Bin 0 -> 43 bytes
 .../system-compactions_in_progress-ka-1-Data.db | Bin 0 -> 146 bytes
 ...tem-compactions_in_progress-ka-1-Digest.sha1 |   1 +
 ...ystem-compactions_in_progress-ka-1-Filter.db | Bin 0 -> 16 bytes
 ...system-compactions_in_progress-ka-1-Index.db | Bin 0 -> 30 bytes
 ...m-compactions_in_progress-ka-1-Statistics.db | Bin 0 -> 4450 bytes
 ...stem-compactions_in_progress-ka-1-Summary.db | Bin 0 -> 116 bytes
 .../system-compactions_in_progress-ka-1-TOC.txt |   8 ++++++
 .../test-foo-ka-3-CompressionInfo.db            | Bin 0 -> 43 bytes
 .../test-foo-ka-3-Data.db                       | Bin 0 -> 141 bytes
 .../test-foo-ka-3-Digest.sha1                   |   1 +
 .../test-foo-ka-3-Filter.db                     | Bin 0 -> 176 bytes
 .../test-foo-ka-3-Index.db                      | Bin 0 -> 90 bytes
 .../test-foo-ka-3-Statistics.db                 | Bin 0 -> 4458 bytes
 .../test-foo-ka-3-Summary.db                    | Bin 0 -> 80 bytes
 .../test-foo-ka-3-TOC.txt                       |   8 ++++++
 .../test-foo-tmp-ka-4-Data.db                   | Bin 0 -> 141 bytes
 .../test-foo-tmp-ka-4-Index.db                  | Bin 0 -> 90 bytes
 .../test-foo-tmplink-ka-4-Data.db               | Bin 0 -> 141 bytes
 .../test-foo-tmplink-ka-4-Index.db              | Bin 0 -> 90 bytes
 .../apache/cassandra/db/SystemKeyspaceTest.java |  19 ++++++++++---
 24 files changed, 55 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ca6971/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index eacc110..b23c2d1 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -12,6 +12,7 @@
  * Bytecode inspection for Java-UDFs (CASSANDRA-9890)
  * Use byte to serialize MT hash length (CASSANDRA-9792)
  * Replace usage of Adler32 with CRC32 (CASSANDRA-8684)
+ * Fix migration to new format from 2.1 SSTable (CASSANDRA-10006)
 Merged from 2.2:
  * Add checksum to saved cache files (CASSANDRA-9265)
  * Log warning when using an aggregate without partition key (CASSANDRA-9737)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ca6971/src/java/org/apache/cassandra/db/SystemKeyspace.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/SystemKeyspace.java b/src/java/org/apache/cassandra/db/SystemKeyspace.java
index bc0be65..d24b18b 100644
--- a/src/java/org/apache/cassandra/db/SystemKeyspace.java
+++ b/src/java/org/apache/cassandra/db/SystemKeyspace.java
@@ -1307,7 +1307,7 @@ public final class SystemKeyspace
     }
 
     /**
-     * Check data directories for old files that can be removed when migrating from 2.2 to 3.0,
+     * Check data directories for old files that can be removed when migrating from 2.1 or 2.2 to 3.0,
      * these checks can be removed in 4.0, see CASSANDRA-7066
      */
     public static void migrateDataDirs()
@@ -1323,13 +1323,13 @@ public final class SystemKeyspace
             {
                 for (File cfdir : ksdir.listFiles((d, n) -> d.isDirectory()))
                 {
-                    if (Descriptor.isLegacyFile(cfdir.getName()))
+                    if (Descriptor.isLegacyFile(cfdir))
                     {
                         FileUtils.deleteRecursive(cfdir);
                     }
                     else
                     {
-                        FileUtils.delete(cfdir.listFiles((d, n) -> Descriptor.isLegacyFile(n)));
+                        FileUtils.delete(cfdir.listFiles((d, n) -> Descriptor.isLegacyFile(new File(d, n))));
                     }
                 }
             }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ca6971/src/java/org/apache/cassandra/io/sstable/Descriptor.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/sstable/Descriptor.java b/src/java/org/apache/cassandra/io/sstable/Descriptor.java
index 519f14e..38829df 100644
--- a/src/java/org/apache/cassandra/io/sstable/Descriptor.java
+++ b/src/java/org/apache/cassandra/io/sstable/Descriptor.java
@@ -19,6 +19,7 @@ package org.apache.cassandra.io.sstable;
 
 import java.io.File;
 import java.util.*;
+import java.util.regex.Pattern;
 
 import com.google.common.base.CharMatcher;
 import com.google.common.base.Objects;
@@ -30,7 +31,6 @@ import org.apache.cassandra.io.sstable.format.Version;
 import org.apache.cassandra.io.sstable.metadata.IMetadataSerializer;
 import org.apache.cassandra.io.sstable.metadata.LegacyMetadataSerializer;
 import org.apache.cassandra.io.sstable.metadata.MetadataSerializer;
-import org.apache.cassandra.net.MessagingService;
 import org.apache.cassandra.utils.Pair;
 
 import static org.apache.cassandra.io.sstable.Component.separator;
@@ -163,20 +163,29 @@ public class Descriptor
     }
 
     /**
-     *  Files obsoleted by CASSANDRA-7066 :
-     *  - temporary files used to start with either tmp or tmplink
-     *  - system.compactions_in_progress sstable files
+     *  Files obsoleted by CASSANDRA-7066 : temporary files and compactions_in_progress. We support
+     *  versions 2.1 (ka) and 2.2 (la).
+     *  Temporary files have tmp- or tmplink- at the beginning for 2.2 sstables or after ks-cf- for 2.1 sstables
      */
-    public static boolean isLegacyFile(String fileName)
+
+    private final static String LEGACY_COMP_IN_PROG_REGEX_STR = "^compactions_in_progress(\\-[\\d,a-f]{32})?$";
+    private final static Pattern LEGACY_COMP_IN_PROG_REGEX = Pattern.compile(LEGACY_COMP_IN_PROG_REGEX_STR);
+    private final static String LEGACY_TMP_REGEX_STR = "^((.*)\\-(.*)\\-)?tmp(link)?\\-(la|ka)\\-(\\d)*\\-(.*)$";
+    private final static Pattern LEGACY_TMP_REGEX = Pattern.compile(LEGACY_TMP_REGEX_STR);
+
+    public static boolean isLegacyFile(File file)
     {
-        return fileName.startsWith("compactions_in_progress") ||
-               fileName.startsWith("tmp") ||
-               fileName.startsWith("tmplink");
+        if (file.isDirectory())
+            return file.getParentFile() != null &&
+                   file.getParentFile().getName().equalsIgnoreCase("system") &&
+                   LEGACY_COMP_IN_PROG_REGEX.matcher(file.getName()).matches();
+        else
+            return LEGACY_TMP_REGEX.matcher(file.getName()).matches();
     }
 
     public static boolean isValidFile(String fileName)
     {
-        return fileName.endsWith(".db") && !isLegacyFile(fileName);
+        return fileName.endsWith(".db") && !LEGACY_TMP_REGEX.matcher(fileName).matches();
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ca6971/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-CompressionInfo.db
----------------------------------------------------------------------
diff --git a/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-CompressionInfo.db b/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-CompressionInfo.db
new file mode 100644
index 0000000..d9446df
Binary files /dev/null and b/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-CompressionInfo.db differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ca6971/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-Data.db
----------------------------------------------------------------------
diff --git a/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-Data.db b/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-Data.db
new file mode 100644
index 0000000..f7b696d
Binary files /dev/null and b/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-Data.db differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ca6971/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-Digest.sha1
----------------------------------------------------------------------
diff --git a/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-Digest.sha1 b/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-Digest.sha1
new file mode 100644
index 0000000..55756dd
--- /dev/null
+++ b/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-Digest.sha1
@@ -0,0 +1 @@
+3043896114
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ca6971/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-Filter.db
----------------------------------------------------------------------
diff --git a/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-Filter.db b/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-Filter.db
new file mode 100644
index 0000000..3015f10
Binary files /dev/null and b/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-Filter.db differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ca6971/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-Index.db
----------------------------------------------------------------------
diff --git a/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-Index.db b/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-Index.db
new file mode 100644
index 0000000..c8b59fb
Binary files /dev/null and b/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-Index.db differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ca6971/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-Statistics.db
----------------------------------------------------------------------
diff --git a/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-Statistics.db b/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-Statistics.db
new file mode 100644
index 0000000..8535f6a
Binary files /dev/null and b/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-Statistics.db differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ca6971/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-Summary.db
----------------------------------------------------------------------
diff --git a/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-Summary.db b/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-Summary.db
new file mode 100644
index 0000000..d9ce8c2
Binary files /dev/null and b/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-Summary.db differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ca6971/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-TOC.txt
----------------------------------------------------------------------
diff --git a/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-TOC.txt b/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-TOC.txt
new file mode 100644
index 0000000..7dc8930
--- /dev/null
+++ b/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-TOC.txt
@@ -0,0 +1,8 @@
+Data.db
+TOC.txt
+Filter.db
+Statistics.db
+Summary.db
+Index.db
+Digest.sha1
+CompressionInfo.db

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ca6971/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-CompressionInfo.db
----------------------------------------------------------------------
diff --git a/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-CompressionInfo.db b/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-CompressionInfo.db
new file mode 100644
index 0000000..b867db8
Binary files /dev/null and b/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-CompressionInfo.db differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ca6971/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-Data.db
----------------------------------------------------------------------
diff --git a/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-Data.db b/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-Data.db
new file mode 100644
index 0000000..f14d86d
Binary files /dev/null and b/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-Data.db differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ca6971/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-Digest.sha1
----------------------------------------------------------------------
diff --git a/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-Digest.sha1 b/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-Digest.sha1
new file mode 100644
index 0000000..2f4daa9
--- /dev/null
+++ b/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-Digest.sha1
@@ -0,0 +1 @@
+4283441474
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ca6971/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-Filter.db
----------------------------------------------------------------------
diff --git a/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-Filter.db b/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-Filter.db
new file mode 100644
index 0000000..a5bdd8e
Binary files /dev/null and b/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-Filter.db differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ca6971/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-Index.db
----------------------------------------------------------------------
diff --git a/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-Index.db b/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-Index.db
new file mode 100644
index 0000000..5d71315
Binary files /dev/null and b/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-Index.db differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ca6971/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-Statistics.db
----------------------------------------------------------------------
diff --git a/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-Statistics.db b/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-Statistics.db
new file mode 100644
index 0000000..aeb2bb8
Binary files /dev/null and b/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-Statistics.db differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ca6971/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-Summary.db
----------------------------------------------------------------------
diff --git a/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-Summary.db b/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-Summary.db
new file mode 100644
index 0000000..602ec06
Binary files /dev/null and b/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-Summary.db differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ca6971/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-TOC.txt
----------------------------------------------------------------------
diff --git a/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-TOC.txt b/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-TOC.txt
new file mode 100644
index 0000000..7dc8930
--- /dev/null
+++ b/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-TOC.txt
@@ -0,0 +1,8 @@
+Data.db
+TOC.txt
+Filter.db
+Statistics.db
+Summary.db
+Index.db
+Digest.sha1
+CompressionInfo.db

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ca6971/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-tmp-ka-4-Data.db
----------------------------------------------------------------------
diff --git a/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-tmp-ka-4-Data.db b/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-tmp-ka-4-Data.db
new file mode 100644
index 0000000..f14d86d
Binary files /dev/null and b/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-tmp-ka-4-Data.db differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ca6971/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-tmp-ka-4-Index.db
----------------------------------------------------------------------
diff --git a/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-tmp-ka-4-Index.db b/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-tmp-ka-4-Index.db
new file mode 100644
index 0000000..5d71315
Binary files /dev/null and b/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-tmp-ka-4-Index.db differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ca6971/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-tmplink-ka-4-Data.db
----------------------------------------------------------------------
diff --git a/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-tmplink-ka-4-Data.db b/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-tmplink-ka-4-Data.db
new file mode 100644
index 0000000..f14d86d
Binary files /dev/null and b/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-tmplink-ka-4-Data.db differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ca6971/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-tmplink-ka-4-Index.db
----------------------------------------------------------------------
diff --git a/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-tmplink-ka-4-Index.db b/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-tmplink-ka-4-Index.db
new file mode 100644
index 0000000..5d71315
Binary files /dev/null and b/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-tmplink-ka-4-Index.db differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ca6971/test/unit/org/apache/cassandra/db/SystemKeyspaceTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/SystemKeyspaceTest.java b/test/unit/org/apache/cassandra/db/SystemKeyspaceTest.java
index d58985c..9fc3503 100644
--- a/test/unit/org/apache/cassandra/db/SystemKeyspaceTest.java
+++ b/test/unit/org/apache/cassandra/db/SystemKeyspaceTest.java
@@ -153,9 +153,20 @@ public class SystemKeyspaceTest
     }
 
     @Test
-    public void testMigrateDataDirs() throws IOException
+    public void testMigrateDataDirs_2_1() throws IOException
     {
-        Path migrationSSTableRoot = Paths.get(System.getProperty(MIGRATION_SSTABLES_ROOT), "2.2");
+        testMigrateDataDirs("2.1");
+    }
+
+    @Test
+    public void testMigrateDataDirs_2_2() throws IOException
+    {
+        testMigrateDataDirs("2.2");
+    }
+
+    private void testMigrateDataDirs(String version) throws IOException
+    {
+        Path migrationSSTableRoot = Paths.get(System.getProperty(MIGRATION_SSTABLES_ROOT), version);
         Path dataDir = Paths.get(DatabaseDescriptor.getAllDataFileLocations()[0]);
 
         FileUtils.copyDirectory(migrationSSTableRoot.toFile(), dataDir.toFile());
@@ -178,13 +189,13 @@ public class SystemKeyspaceTest
             {
                 for (File cfdir : ksdir.listFiles((d, n) -> d.isDirectory()))
                 {
-                    if (Descriptor.isLegacyFile(cfdir.getName()))
+                    if (Descriptor.isLegacyFile(cfdir))
                     {
                         ret++;
                     }
                     else
                     {
-                        File[] legacyFiles = cfdir.listFiles((d, n) -> Descriptor.isLegacyFile(n));
+                        File[] legacyFiles = cfdir.listFiles((d, n) -> Descriptor.isLegacyFile(new File(d, n)));
                         ret += legacyFiles.length;
                     }
                 }


[3/3] cassandra git commit: Merge branch 'cassandra-3.0' into trunk

Posted by yu...@apache.org.
Merge branch 'cassandra-3.0' into trunk


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

Branch: refs/heads/trunk
Commit: e8ac7edb736359cad442d2a5469de4bd5d711bd8
Parents: 1a1c5a0 76ca697
Author: Yuki Morishita <yu...@apache.org>
Authored: Mon Aug 10 20:37:23 2015 -0500
Committer: Yuki Morishita <yu...@apache.org>
Committed: Mon Aug 10 20:37:23 2015 -0500

----------------------------------------------------------------------
 CHANGES.txt                                     |   1 +
 .../org/apache/cassandra/db/SystemKeyspace.java |   6 ++---
 .../apache/cassandra/io/sstable/Descriptor.java |  27 ++++++++++++-------
 ...pactions_in_progress-ka-1-CompressionInfo.db | Bin 0 -> 43 bytes
 .../system-compactions_in_progress-ka-1-Data.db | Bin 0 -> 146 bytes
 ...tem-compactions_in_progress-ka-1-Digest.sha1 |   1 +
 ...ystem-compactions_in_progress-ka-1-Filter.db | Bin 0 -> 16 bytes
 ...system-compactions_in_progress-ka-1-Index.db | Bin 0 -> 30 bytes
 ...m-compactions_in_progress-ka-1-Statistics.db | Bin 0 -> 4450 bytes
 ...stem-compactions_in_progress-ka-1-Summary.db | Bin 0 -> 116 bytes
 .../system-compactions_in_progress-ka-1-TOC.txt |   8 ++++++
 .../test-foo-ka-3-CompressionInfo.db            | Bin 0 -> 43 bytes
 .../test-foo-ka-3-Data.db                       | Bin 0 -> 141 bytes
 .../test-foo-ka-3-Digest.sha1                   |   1 +
 .../test-foo-ka-3-Filter.db                     | Bin 0 -> 176 bytes
 .../test-foo-ka-3-Index.db                      | Bin 0 -> 90 bytes
 .../test-foo-ka-3-Statistics.db                 | Bin 0 -> 4458 bytes
 .../test-foo-ka-3-Summary.db                    | Bin 0 -> 80 bytes
 .../test-foo-ka-3-TOC.txt                       |   8 ++++++
 .../test-foo-tmp-ka-4-Data.db                   | Bin 0 -> 141 bytes
 .../test-foo-tmp-ka-4-Index.db                  | Bin 0 -> 90 bytes
 .../test-foo-tmplink-ka-4-Data.db               | Bin 0 -> 141 bytes
 .../test-foo-tmplink-ka-4-Index.db              | Bin 0 -> 90 bytes
 .../apache/cassandra/db/SystemKeyspaceTest.java |  19 ++++++++++---
 24 files changed, 55 insertions(+), 16 deletions(-)
----------------------------------------------------------------------



[2/3] cassandra git commit: 2.1 format sstable filenames with tmp are not handled by 3.0

Posted by yu...@apache.org.
2.1 format sstable filenames with tmp are not handled by 3.0

patch by stefania; reviewed by yukim for CASSANDRA-10006


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

Branch: refs/heads/trunk
Commit: 76ca69717c3072996095057115133ca3b6ca25cd
Parents: 1a9286c
Author: Stefania Alborghetti <st...@datastax.com>
Authored: Mon Aug 10 20:21:47 2015 -0500
Committer: Yuki Morishita <yu...@apache.org>
Committed: Mon Aug 10 20:21:47 2015 -0500

----------------------------------------------------------------------
 CHANGES.txt                                     |   1 +
 .../org/apache/cassandra/db/SystemKeyspace.java |   6 ++---
 .../apache/cassandra/io/sstable/Descriptor.java |  27 ++++++++++++-------
 ...pactions_in_progress-ka-1-CompressionInfo.db | Bin 0 -> 43 bytes
 .../system-compactions_in_progress-ka-1-Data.db | Bin 0 -> 146 bytes
 ...tem-compactions_in_progress-ka-1-Digest.sha1 |   1 +
 ...ystem-compactions_in_progress-ka-1-Filter.db | Bin 0 -> 16 bytes
 ...system-compactions_in_progress-ka-1-Index.db | Bin 0 -> 30 bytes
 ...m-compactions_in_progress-ka-1-Statistics.db | Bin 0 -> 4450 bytes
 ...stem-compactions_in_progress-ka-1-Summary.db | Bin 0 -> 116 bytes
 .../system-compactions_in_progress-ka-1-TOC.txt |   8 ++++++
 .../test-foo-ka-3-CompressionInfo.db            | Bin 0 -> 43 bytes
 .../test-foo-ka-3-Data.db                       | Bin 0 -> 141 bytes
 .../test-foo-ka-3-Digest.sha1                   |   1 +
 .../test-foo-ka-3-Filter.db                     | Bin 0 -> 176 bytes
 .../test-foo-ka-3-Index.db                      | Bin 0 -> 90 bytes
 .../test-foo-ka-3-Statistics.db                 | Bin 0 -> 4458 bytes
 .../test-foo-ka-3-Summary.db                    | Bin 0 -> 80 bytes
 .../test-foo-ka-3-TOC.txt                       |   8 ++++++
 .../test-foo-tmp-ka-4-Data.db                   | Bin 0 -> 141 bytes
 .../test-foo-tmp-ka-4-Index.db                  | Bin 0 -> 90 bytes
 .../test-foo-tmplink-ka-4-Data.db               | Bin 0 -> 141 bytes
 .../test-foo-tmplink-ka-4-Index.db              | Bin 0 -> 90 bytes
 .../apache/cassandra/db/SystemKeyspaceTest.java |  19 ++++++++++---
 24 files changed, 55 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ca6971/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index eacc110..b23c2d1 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -12,6 +12,7 @@
  * Bytecode inspection for Java-UDFs (CASSANDRA-9890)
  * Use byte to serialize MT hash length (CASSANDRA-9792)
  * Replace usage of Adler32 with CRC32 (CASSANDRA-8684)
+ * Fix migration to new format from 2.1 SSTable (CASSANDRA-10006)
 Merged from 2.2:
  * Add checksum to saved cache files (CASSANDRA-9265)
  * Log warning when using an aggregate without partition key (CASSANDRA-9737)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ca6971/src/java/org/apache/cassandra/db/SystemKeyspace.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/SystemKeyspace.java b/src/java/org/apache/cassandra/db/SystemKeyspace.java
index bc0be65..d24b18b 100644
--- a/src/java/org/apache/cassandra/db/SystemKeyspace.java
+++ b/src/java/org/apache/cassandra/db/SystemKeyspace.java
@@ -1307,7 +1307,7 @@ public final class SystemKeyspace
     }
 
     /**
-     * Check data directories for old files that can be removed when migrating from 2.2 to 3.0,
+     * Check data directories for old files that can be removed when migrating from 2.1 or 2.2 to 3.0,
      * these checks can be removed in 4.0, see CASSANDRA-7066
      */
     public static void migrateDataDirs()
@@ -1323,13 +1323,13 @@ public final class SystemKeyspace
             {
                 for (File cfdir : ksdir.listFiles((d, n) -> d.isDirectory()))
                 {
-                    if (Descriptor.isLegacyFile(cfdir.getName()))
+                    if (Descriptor.isLegacyFile(cfdir))
                     {
                         FileUtils.deleteRecursive(cfdir);
                     }
                     else
                     {
-                        FileUtils.delete(cfdir.listFiles((d, n) -> Descriptor.isLegacyFile(n)));
+                        FileUtils.delete(cfdir.listFiles((d, n) -> Descriptor.isLegacyFile(new File(d, n))));
                     }
                 }
             }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ca6971/src/java/org/apache/cassandra/io/sstable/Descriptor.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/sstable/Descriptor.java b/src/java/org/apache/cassandra/io/sstable/Descriptor.java
index 519f14e..38829df 100644
--- a/src/java/org/apache/cassandra/io/sstable/Descriptor.java
+++ b/src/java/org/apache/cassandra/io/sstable/Descriptor.java
@@ -19,6 +19,7 @@ package org.apache.cassandra.io.sstable;
 
 import java.io.File;
 import java.util.*;
+import java.util.regex.Pattern;
 
 import com.google.common.base.CharMatcher;
 import com.google.common.base.Objects;
@@ -30,7 +31,6 @@ import org.apache.cassandra.io.sstable.format.Version;
 import org.apache.cassandra.io.sstable.metadata.IMetadataSerializer;
 import org.apache.cassandra.io.sstable.metadata.LegacyMetadataSerializer;
 import org.apache.cassandra.io.sstable.metadata.MetadataSerializer;
-import org.apache.cassandra.net.MessagingService;
 import org.apache.cassandra.utils.Pair;
 
 import static org.apache.cassandra.io.sstable.Component.separator;
@@ -163,20 +163,29 @@ public class Descriptor
     }
 
     /**
-     *  Files obsoleted by CASSANDRA-7066 :
-     *  - temporary files used to start with either tmp or tmplink
-     *  - system.compactions_in_progress sstable files
+     *  Files obsoleted by CASSANDRA-7066 : temporary files and compactions_in_progress. We support
+     *  versions 2.1 (ka) and 2.2 (la).
+     *  Temporary files have tmp- or tmplink- at the beginning for 2.2 sstables or after ks-cf- for 2.1 sstables
      */
-    public static boolean isLegacyFile(String fileName)
+
+    private final static String LEGACY_COMP_IN_PROG_REGEX_STR = "^compactions_in_progress(\\-[\\d,a-f]{32})?$";
+    private final static Pattern LEGACY_COMP_IN_PROG_REGEX = Pattern.compile(LEGACY_COMP_IN_PROG_REGEX_STR);
+    private final static String LEGACY_TMP_REGEX_STR = "^((.*)\\-(.*)\\-)?tmp(link)?\\-(la|ka)\\-(\\d)*\\-(.*)$";
+    private final static Pattern LEGACY_TMP_REGEX = Pattern.compile(LEGACY_TMP_REGEX_STR);
+
+    public static boolean isLegacyFile(File file)
     {
-        return fileName.startsWith("compactions_in_progress") ||
-               fileName.startsWith("tmp") ||
-               fileName.startsWith("tmplink");
+        if (file.isDirectory())
+            return file.getParentFile() != null &&
+                   file.getParentFile().getName().equalsIgnoreCase("system") &&
+                   LEGACY_COMP_IN_PROG_REGEX.matcher(file.getName()).matches();
+        else
+            return LEGACY_TMP_REGEX.matcher(file.getName()).matches();
     }
 
     public static boolean isValidFile(String fileName)
     {
-        return fileName.endsWith(".db") && !isLegacyFile(fileName);
+        return fileName.endsWith(".db") && !LEGACY_TMP_REGEX.matcher(fileName).matches();
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ca6971/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-CompressionInfo.db
----------------------------------------------------------------------
diff --git a/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-CompressionInfo.db b/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-CompressionInfo.db
new file mode 100644
index 0000000..d9446df
Binary files /dev/null and b/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-CompressionInfo.db differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ca6971/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-Data.db
----------------------------------------------------------------------
diff --git a/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-Data.db b/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-Data.db
new file mode 100644
index 0000000..f7b696d
Binary files /dev/null and b/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-Data.db differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ca6971/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-Digest.sha1
----------------------------------------------------------------------
diff --git a/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-Digest.sha1 b/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-Digest.sha1
new file mode 100644
index 0000000..55756dd
--- /dev/null
+++ b/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-Digest.sha1
@@ -0,0 +1 @@
+3043896114
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ca6971/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-Filter.db
----------------------------------------------------------------------
diff --git a/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-Filter.db b/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-Filter.db
new file mode 100644
index 0000000..3015f10
Binary files /dev/null and b/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-Filter.db differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ca6971/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-Index.db
----------------------------------------------------------------------
diff --git a/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-Index.db b/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-Index.db
new file mode 100644
index 0000000..c8b59fb
Binary files /dev/null and b/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-Index.db differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ca6971/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-Statistics.db
----------------------------------------------------------------------
diff --git a/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-Statistics.db b/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-Statistics.db
new file mode 100644
index 0000000..8535f6a
Binary files /dev/null and b/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-Statistics.db differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ca6971/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-Summary.db
----------------------------------------------------------------------
diff --git a/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-Summary.db b/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-Summary.db
new file mode 100644
index 0000000..d9ce8c2
Binary files /dev/null and b/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-Summary.db differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ca6971/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-TOC.txt
----------------------------------------------------------------------
diff --git a/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-TOC.txt b/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-TOC.txt
new file mode 100644
index 0000000..7dc8930
--- /dev/null
+++ b/test/data/migration-sstables/2.1/system/compactions_in_progress-55080ab05d9c388690a4acb25fe1f77b/system-compactions_in_progress-ka-1-TOC.txt
@@ -0,0 +1,8 @@
+Data.db
+TOC.txt
+Filter.db
+Statistics.db
+Summary.db
+Index.db
+Digest.sha1
+CompressionInfo.db

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ca6971/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-CompressionInfo.db
----------------------------------------------------------------------
diff --git a/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-CompressionInfo.db b/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-CompressionInfo.db
new file mode 100644
index 0000000..b867db8
Binary files /dev/null and b/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-CompressionInfo.db differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ca6971/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-Data.db
----------------------------------------------------------------------
diff --git a/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-Data.db b/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-Data.db
new file mode 100644
index 0000000..f14d86d
Binary files /dev/null and b/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-Data.db differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ca6971/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-Digest.sha1
----------------------------------------------------------------------
diff --git a/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-Digest.sha1 b/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-Digest.sha1
new file mode 100644
index 0000000..2f4daa9
--- /dev/null
+++ b/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-Digest.sha1
@@ -0,0 +1 @@
+4283441474
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ca6971/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-Filter.db
----------------------------------------------------------------------
diff --git a/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-Filter.db b/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-Filter.db
new file mode 100644
index 0000000..a5bdd8e
Binary files /dev/null and b/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-Filter.db differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ca6971/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-Index.db
----------------------------------------------------------------------
diff --git a/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-Index.db b/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-Index.db
new file mode 100644
index 0000000..5d71315
Binary files /dev/null and b/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-Index.db differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ca6971/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-Statistics.db
----------------------------------------------------------------------
diff --git a/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-Statistics.db b/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-Statistics.db
new file mode 100644
index 0000000..aeb2bb8
Binary files /dev/null and b/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-Statistics.db differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ca6971/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-Summary.db
----------------------------------------------------------------------
diff --git a/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-Summary.db b/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-Summary.db
new file mode 100644
index 0000000..602ec06
Binary files /dev/null and b/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-Summary.db differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ca6971/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-TOC.txt
----------------------------------------------------------------------
diff --git a/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-TOC.txt b/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-TOC.txt
new file mode 100644
index 0000000..7dc8930
--- /dev/null
+++ b/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-ka-3-TOC.txt
@@ -0,0 +1,8 @@
+Data.db
+TOC.txt
+Filter.db
+Statistics.db
+Summary.db
+Index.db
+Digest.sha1
+CompressionInfo.db

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ca6971/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-tmp-ka-4-Data.db
----------------------------------------------------------------------
diff --git a/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-tmp-ka-4-Data.db b/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-tmp-ka-4-Data.db
new file mode 100644
index 0000000..f14d86d
Binary files /dev/null and b/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-tmp-ka-4-Data.db differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ca6971/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-tmp-ka-4-Index.db
----------------------------------------------------------------------
diff --git a/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-tmp-ka-4-Index.db b/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-tmp-ka-4-Index.db
new file mode 100644
index 0000000..5d71315
Binary files /dev/null and b/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-tmp-ka-4-Index.db differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ca6971/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-tmplink-ka-4-Data.db
----------------------------------------------------------------------
diff --git a/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-tmplink-ka-4-Data.db b/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-tmplink-ka-4-Data.db
new file mode 100644
index 0000000..f14d86d
Binary files /dev/null and b/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-tmplink-ka-4-Data.db differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ca6971/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-tmplink-ka-4-Index.db
----------------------------------------------------------------------
diff --git a/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-tmplink-ka-4-Index.db b/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-tmplink-ka-4-Index.db
new file mode 100644
index 0000000..5d71315
Binary files /dev/null and b/test/data/migration-sstables/2.1/test/foo-0094ac203e7411e59149ef9f87394ca6/test-foo-tmplink-ka-4-Index.db differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ca6971/test/unit/org/apache/cassandra/db/SystemKeyspaceTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/SystemKeyspaceTest.java b/test/unit/org/apache/cassandra/db/SystemKeyspaceTest.java
index d58985c..9fc3503 100644
--- a/test/unit/org/apache/cassandra/db/SystemKeyspaceTest.java
+++ b/test/unit/org/apache/cassandra/db/SystemKeyspaceTest.java
@@ -153,9 +153,20 @@ public class SystemKeyspaceTest
     }
 
     @Test
-    public void testMigrateDataDirs() throws IOException
+    public void testMigrateDataDirs_2_1() throws IOException
     {
-        Path migrationSSTableRoot = Paths.get(System.getProperty(MIGRATION_SSTABLES_ROOT), "2.2");
+        testMigrateDataDirs("2.1");
+    }
+
+    @Test
+    public void testMigrateDataDirs_2_2() throws IOException
+    {
+        testMigrateDataDirs("2.2");
+    }
+
+    private void testMigrateDataDirs(String version) throws IOException
+    {
+        Path migrationSSTableRoot = Paths.get(System.getProperty(MIGRATION_SSTABLES_ROOT), version);
         Path dataDir = Paths.get(DatabaseDescriptor.getAllDataFileLocations()[0]);
 
         FileUtils.copyDirectory(migrationSSTableRoot.toFile(), dataDir.toFile());
@@ -178,13 +189,13 @@ public class SystemKeyspaceTest
             {
                 for (File cfdir : ksdir.listFiles((d, n) -> d.isDirectory()))
                 {
-                    if (Descriptor.isLegacyFile(cfdir.getName()))
+                    if (Descriptor.isLegacyFile(cfdir))
                     {
                         ret++;
                     }
                     else
                     {
-                        File[] legacyFiles = cfdir.listFiles((d, n) -> Descriptor.isLegacyFile(n));
+                        File[] legacyFiles = cfdir.listFiles((d, n) -> Descriptor.isLegacyFile(new File(d, n)));
                         ret += legacyFiles.length;
                     }
                 }