You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by sl...@apache.org on 2012/01/04 16:09:52 UTC

[2/2] Finer-grained control over data directories

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9a76e646/test/data/legacy-sstables/hb/Keyspace1/Indexed1.626972746864617465-hb-1-Statistics.db
----------------------------------------------------------------------
diff --git a/test/data/legacy-sstables/hb/Keyspace1/Indexed1.626972746864617465-hb-1-Statistics.db b/test/data/legacy-sstables/hb/Keyspace1/Indexed1.626972746864617465-hb-1-Statistics.db
deleted file mode 100644
index 78c4ed3..0000000
Binary files a/test/data/legacy-sstables/hb/Keyspace1/Indexed1.626972746864617465-hb-1-Statistics.db and /dev/null differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9a76e646/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Indexed1-hb-1-Data.db
----------------------------------------------------------------------
diff --git a/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Indexed1-hb-1-Data.db b/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Indexed1-hb-1-Data.db
new file mode 100644
index 0000000..896897a
Binary files /dev/null and b/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Indexed1-hb-1-Data.db differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9a76e646/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Indexed1-hb-1-Digest.sha1
----------------------------------------------------------------------
diff --git a/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Indexed1-hb-1-Digest.sha1 b/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Indexed1-hb-1-Digest.sha1
new file mode 100644
index 0000000..bc0c4e4
--- /dev/null
+++ b/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Indexed1-hb-1-Digest.sha1
@@ -0,0 +1 @@
+095dd05150d499846782cdf1c77544048477cc9b  Indexed1-hb-1-Data.db
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9a76e646/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Indexed1-hb-1-Filter.db
----------------------------------------------------------------------
diff --git a/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Indexed1-hb-1-Filter.db b/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Indexed1-hb-1-Filter.db
new file mode 100644
index 0000000..4b61a27
Binary files /dev/null and b/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Indexed1-hb-1-Filter.db differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9a76e646/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Indexed1-hb-1-Index.db
----------------------------------------------------------------------
diff --git a/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Indexed1-hb-1-Index.db b/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Indexed1-hb-1-Index.db
new file mode 100644
index 0000000..03b3dc8
Binary files /dev/null and b/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Indexed1-hb-1-Index.db differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9a76e646/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Indexed1-hb-1-Statistics.db
----------------------------------------------------------------------
diff --git a/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Indexed1-hb-1-Statistics.db b/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Indexed1-hb-1-Statistics.db
new file mode 100644
index 0000000..78c4ed3
Binary files /dev/null and b/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Indexed1-hb-1-Statistics.db differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9a76e646/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Indexed1.626972746864617465-hb-1-Data.db
----------------------------------------------------------------------
diff --git a/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Indexed1.626972746864617465-hb-1-Data.db b/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Indexed1.626972746864617465-hb-1-Data.db
new file mode 100644
index 0000000..2bdae87
Binary files /dev/null and b/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Indexed1.626972746864617465-hb-1-Data.db differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9a76e646/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Indexed1.626972746864617465-hb-1-Digest.sha1
----------------------------------------------------------------------
diff --git a/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Indexed1.626972746864617465-hb-1-Digest.sha1 b/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Indexed1.626972746864617465-hb-1-Digest.sha1
new file mode 100644
index 0000000..7af63e1
--- /dev/null
+++ b/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Indexed1.626972746864617465-hb-1-Digest.sha1
@@ -0,0 +1 @@
+a6a32d25ca3cdf76ac5a1a6bffa78936463f9648  Indexed1.626972746864617465-hb-1-Data.db
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9a76e646/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Indexed1.626972746864617465-hb-1-Filter.db
----------------------------------------------------------------------
diff --git a/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Indexed1.626972746864617465-hb-1-Filter.db b/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Indexed1.626972746864617465-hb-1-Filter.db
new file mode 100644
index 0000000..1fd5362
Binary files /dev/null and b/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Indexed1.626972746864617465-hb-1-Filter.db differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9a76e646/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Indexed1.626972746864617465-hb-1-Index.db
----------------------------------------------------------------------
diff --git a/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Indexed1.626972746864617465-hb-1-Index.db b/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Indexed1.626972746864617465-hb-1-Index.db
new file mode 100644
index 0000000..d9a482f
Binary files /dev/null and b/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Indexed1.626972746864617465-hb-1-Index.db differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9a76e646/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Indexed1.626972746864617465-hb-1-Statistics.db
----------------------------------------------------------------------
diff --git a/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Indexed1.626972746864617465-hb-1-Statistics.db b/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Indexed1.626972746864617465-hb-1-Statistics.db
new file mode 100644
index 0000000..78c4ed3
Binary files /dev/null and b/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Indexed1.626972746864617465-hb-1-Statistics.db differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9a76e646/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Standard1-hb-0-Data.db
----------------------------------------------------------------------
diff --git a/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Standard1-hb-0-Data.db b/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Standard1-hb-0-Data.db
new file mode 100644
index 0000000..1cd5d15
Binary files /dev/null and b/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Standard1-hb-0-Data.db differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9a76e646/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Standard1-hb-0-Digest.sha1
----------------------------------------------------------------------
diff --git a/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Standard1-hb-0-Digest.sha1 b/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Standard1-hb-0-Digest.sha1
new file mode 100644
index 0000000..fa25470
--- /dev/null
+++ b/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Standard1-hb-0-Digest.sha1
@@ -0,0 +1 @@
+72295cc1b64e6ffdb67a39dec9996c4ff0363cce  Standard1-hb-0-Data.db
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9a76e646/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Standard1-hb-0-Filter.db
----------------------------------------------------------------------
diff --git a/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Standard1-hb-0-Filter.db b/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Standard1-hb-0-Filter.db
new file mode 100644
index 0000000..1fc4460
Binary files /dev/null and b/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Standard1-hb-0-Filter.db differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9a76e646/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Standard1-hb-0-Index.db
----------------------------------------------------------------------
diff --git a/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Standard1-hb-0-Index.db b/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Standard1-hb-0-Index.db
new file mode 100644
index 0000000..bfe71f5
Binary files /dev/null and b/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Standard1-hb-0-Index.db differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9a76e646/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Standard1-hb-0-Statistics.db
----------------------------------------------------------------------
diff --git a/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Standard1-hb-0-Statistics.db b/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Standard1-hb-0-Statistics.db
new file mode 100644
index 0000000..8c256e9
Binary files /dev/null and b/test/data/legacy-sstables/hb/Keyspace1/Keyspace1-Standard1-hb-0-Statistics.db differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9a76e646/test/data/legacy-sstables/hb/Keyspace1/Standard1-hb-0-Data.db
----------------------------------------------------------------------
diff --git a/test/data/legacy-sstables/hb/Keyspace1/Standard1-hb-0-Data.db b/test/data/legacy-sstables/hb/Keyspace1/Standard1-hb-0-Data.db
deleted file mode 100644
index 1cd5d15..0000000
Binary files a/test/data/legacy-sstables/hb/Keyspace1/Standard1-hb-0-Data.db and /dev/null differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9a76e646/test/data/legacy-sstables/hb/Keyspace1/Standard1-hb-0-Digest.sha1
----------------------------------------------------------------------
diff --git a/test/data/legacy-sstables/hb/Keyspace1/Standard1-hb-0-Digest.sha1 b/test/data/legacy-sstables/hb/Keyspace1/Standard1-hb-0-Digest.sha1
deleted file mode 100644
index fa25470..0000000
--- a/test/data/legacy-sstables/hb/Keyspace1/Standard1-hb-0-Digest.sha1
+++ /dev/null
@@ -1 +0,0 @@
-72295cc1b64e6ffdb67a39dec9996c4ff0363cce  Standard1-hb-0-Data.db
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9a76e646/test/data/legacy-sstables/hb/Keyspace1/Standard1-hb-0-Filter.db
----------------------------------------------------------------------
diff --git a/test/data/legacy-sstables/hb/Keyspace1/Standard1-hb-0-Filter.db b/test/data/legacy-sstables/hb/Keyspace1/Standard1-hb-0-Filter.db
deleted file mode 100644
index 1fc4460..0000000
Binary files a/test/data/legacy-sstables/hb/Keyspace1/Standard1-hb-0-Filter.db and /dev/null differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9a76e646/test/data/legacy-sstables/hb/Keyspace1/Standard1-hb-0-Index.db
----------------------------------------------------------------------
diff --git a/test/data/legacy-sstables/hb/Keyspace1/Standard1-hb-0-Index.db b/test/data/legacy-sstables/hb/Keyspace1/Standard1-hb-0-Index.db
deleted file mode 100644
index bfe71f5..0000000
Binary files a/test/data/legacy-sstables/hb/Keyspace1/Standard1-hb-0-Index.db and /dev/null differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9a76e646/test/data/legacy-sstables/hb/Keyspace1/Standard1-hb-0-Statistics.db
----------------------------------------------------------------------
diff --git a/test/data/legacy-sstables/hb/Keyspace1/Standard1-hb-0-Statistics.db b/test/data/legacy-sstables/hb/Keyspace1/Standard1-hb-0-Statistics.db
deleted file mode 100644
index 8c256e9..0000000
Binary files a/test/data/legacy-sstables/hb/Keyspace1/Standard1-hb-0-Statistics.db and /dev/null differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9a76e646/test/unit/org/apache/cassandra/Util.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/Util.java b/test/unit/org/apache/cassandra/Util.java
index 0248869..68ae228 100644
--- a/test/unit/org/apache/cassandra/Util.java
+++ b/test/unit/org/apache/cassandra/Util.java
@@ -231,7 +231,7 @@ public class Util
     public static void compact(ColumnFamilyStore cfs, Collection<SSTableReader> sstables, boolean forceDeserialize) throws IOException
     {
         CompactionTask task = new CompactionTask(cfs, sstables, (int) (System.currentTimeMillis() / 1000) - cfs.metadata.getGcGraceSeconds());
-        task.isUserDefined(forceDeserialize).compactionFileLocation(cfs.table.getDataFileLocation(1));
+        task.isUserDefined(forceDeserialize);
         task.execute(null);
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9a76e646/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java b/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
index 60ffe59..c5c4273 100644
--- a/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
+++ b/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
@@ -686,13 +686,12 @@ public class ColumnFamilyStoreTest extends CleanupHelper
     @Test
     public void testBackupAfterFlush() throws Throwable
     {
-        insertKey1Key2();
-
-        File backupDir = new File(DatabaseDescriptor.getDataFileLocationForTable("Keyspace2", 0), "backups");
+        ColumnFamilyStore cfs = insertKey1Key2();
 
         for (int version = 1; version <= 2; ++version)
         {
-            Descriptor desc = new Descriptor(backupDir, "Keyspace2", "Standard1", version, false);
+            Descriptor existing = new Descriptor(cfs.directories.getDirectoryForNewSSTables(1), "Keyspace2", "Standard1", version, false);
+            Descriptor desc = new Descriptor(Directories.getBackupsDirectory(existing), "Keyspace2", "Standard1", version, false);
             for (Component c : new Component[]{ Component.DATA, Component.PRIMARY_INDEX, Component.FILTER, Component.STATS })
                 assertTrue("can not find backedup file:" + desc.filenameFor(c), new File(desc.filenameFor(c)).exists());
         }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9a76e646/test/unit/org/apache/cassandra/db/DefsTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/DefsTest.java b/test/unit/org/apache/cassandra/db/DefsTest.java
index 8b7cabe..481b07c 100644
--- a/test/unit/org/apache/cassandra/db/DefsTest.java
+++ b/test/unit/org/apache/cassandra/db/DefsTest.java
@@ -56,7 +56,7 @@ import org.apache.cassandra.utils.ByteBufferUtil;
 
 
 public class DefsTest extends CleanupHelper
-{   
+{
     @Test
     public void testZeroInjection() throws IOException
     {
@@ -293,7 +293,7 @@ public class DefsTest extends CleanupHelper
         assert store != null;
         store.forceBlockingFlush();
         store.getFlushPath(1024, Descriptor.CURRENT_VERSION);
-        assert DefsTable.getFiles(cfm.ksName, cfm.cfName).size() > 0;
+        assert store.directories.sstableLister().list().size() > 0;
         
         new DropColumnFamily(ks.name, cfm.cfName).apply();
 
@@ -314,7 +314,7 @@ public class DefsTest extends CleanupHelper
         assert !success : "This mutation should have failed since the CF no longer exists.";
 
         // verify that the files are gone.
-        for (File file : DefsTable.getFiles(cfm.ksName, cfm.cfName))
+        for (File file : store.directories.sstableLister().listFiles())
         {
             if (file.getPath().endsWith("Data.db") && !new File(file.getPath().replace("Data.db", "Compacted")).exists())
                 throw new AssertionError("undeleted file " + file);
@@ -366,7 +366,7 @@ public class DefsTest extends CleanupHelper
         ColumnFamilyStore store = Table.open(cfm.ksName).getColumnFamilyStore(cfm.cfName);
         assert store != null;
         store.forceBlockingFlush();
-        assert DefsTable.getFiles(cfm.ksName, cfm.cfName).size() > 0;
+        assert store.directories.sstableLister().list().size() > 0;
         
         new DropKeyspace(ks.name).apply();
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9a76e646/test/unit/org/apache/cassandra/db/DirectoriesTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/DirectoriesTest.java b/test/unit/org/apache/cassandra/db/DirectoriesTest.java
new file mode 100644
index 0000000..cf8c450
--- /dev/null
+++ b/test/unit/org/apache/cassandra/db/DirectoriesTest.java
@@ -0,0 +1,183 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cassandra.db;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.*;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+
+import org.apache.cassandra.db.compaction.LeveledManifest;
+import org.apache.cassandra.io.util.FileUtils;
+import org.apache.cassandra.io.sstable.*;
+import org.apache.cassandra.utils.Pair;
+
+public class DirectoriesTest
+{
+    private static File tempDataDir;
+    private static String KS = "ks";
+    private static String[] CFS = new String[] { "cf1", "ks" };
+
+    private static Map<String, List<File>> files = new HashMap<String, List<File>>();
+
+    @BeforeClass
+    public static void beforeClass() throws IOException
+    {
+        tempDataDir = File.createTempFile("cassandra", "unittest");
+        tempDataDir.delete(); // hack to create a temp dir
+        tempDataDir.mkdir();
+
+        Directories.overrideDataDirectoriesForTest(tempDataDir.getPath());
+        // Create two fake data dir for tests, one using CF directories, one that do not.
+        createTestFiles();
+    }
+
+    @AfterClass
+    public static void afterClass() throws IOException
+    {
+        Directories.resetDataDirectoriesAfterTest();
+        FileUtils.deleteRecursive(tempDataDir);
+    }
+
+    private static void createTestFiles() throws IOException
+    {
+        for (String cf : CFS)
+        {
+            List<File> fs = new ArrayList<File>();
+            files.put(cf, fs);
+            File dir = cfDir(cf);
+            dir.mkdirs();
+
+            createFakeSSTable(dir, cf, 1, false, false, fs);
+            createFakeSSTable(dir, cf, 2, true, false, fs);
+            createFakeSSTable(dir, cf, 3, false, true, fs);
+            // leveled manifest
+            new File(dir, cf + LeveledManifest.EXTENSION).createNewFile();
+
+            File backupDir = new File(dir, Directories.BACKUPS_SUBDIR);
+            backupDir.mkdir();
+            createFakeSSTable(backupDir, cf, 1, false, false, fs);
+
+            File snapshotDir = new File(dir, Directories.SNAPSHOT_SUBDIR + File.separator + "42");
+            snapshotDir.mkdirs();
+            createFakeSSTable(snapshotDir, cf, 1, false, false, fs);
+        }
+    }
+
+    private static void createFakeSSTable(File dir, String cf, int gen, boolean temp, boolean compacted, List<File> addTo) throws IOException
+    {
+        Descriptor desc = new Descriptor(dir, KS, cf, gen, temp);
+        for (Component c : new Component[]{ Component.DATA, Component.PRIMARY_INDEX, Component.FILTER })
+        {
+            File f = new File(desc.filenameFor(c));
+            f.createNewFile();
+            addTo.add(f);
+        }
+        if (compacted)
+        {
+            File f = new File(desc.filenameFor(Component.COMPACTED_MARKER));
+            f.createNewFile();
+            addTo.add(f);
+        }
+    }
+
+    private static File cfDir(String cf)
+    {
+        return new File(tempDataDir, KS + File.separator + cf);
+    }
+
+    @Test
+    public void testStandardDirs()
+    {
+        for (String cf : CFS)
+        {
+            Directories directories = Directories.create(KS, cf);
+            assertEquals(cfDir(cf), directories.getDirectoryForNewSSTables(0));
+
+            Descriptor desc = new Descriptor(cfDir(cf), KS, cf, 1, false);
+            File snapshotDir = new File(cfDir(cf),  File.separator + Directories.SNAPSHOT_SUBDIR + File.separator + "42");
+            assertEquals(snapshotDir, directories.getSnapshotDirectory(desc, "42"));
+
+            File backupsDir = new File(cfDir(cf),  File.separator + Directories.BACKUPS_SUBDIR);
+            assertEquals(backupsDir, directories.getBackupsDirectory(desc));
+        }
+    }
+
+    @Test
+    public void testSSTableLister()
+    {
+        for (String cf : CFS)
+        {
+            Directories directories = Directories.create(KS, cf);
+            Directories.SSTableLister lister;
+            Set<File> listed;
+
+            // List all but no snapshot, backup
+            lister = directories.sstableLister();
+            listed = new HashSet<File>(lister.listFiles());
+            for (File f : files.get(cf))
+            {
+                if (f.getPath().contains(Directories.SNAPSHOT_SUBDIR) || f.getPath().contains(Directories.BACKUPS_SUBDIR))
+                    assert !listed.contains(f) : f + " should not be listed";
+                else
+                    assert listed.contains(f) : f + " is missing";
+            }
+
+            // List all but including backup (but no snapshot)
+            lister = directories.sstableLister().includeBackups(true);
+            listed = new HashSet<File>(lister.listFiles());
+            for (File f : files.get(cf))
+            {
+                if (f.getPath().contains(Directories.SNAPSHOT_SUBDIR))
+                    assert !listed.contains(f) : f + " should not be listed";
+                else
+                    assert listed.contains(f) : f + " is missing";
+            }
+
+            // Skip temporary and compacted
+            lister = directories.sstableLister().skipTemporary(true).skipCompacted(true);
+            listed = new HashSet<File>(lister.listFiles());
+            for (File f : files.get(cf))
+            {
+                if (f.getPath().contains(Directories.SNAPSHOT_SUBDIR) || f.getPath().contains(Directories.BACKUPS_SUBDIR))
+                    assert !listed.contains(f) : f + " should not be listed";
+                else if (f.getName().contains("-tmp-"))
+                    assert !listed.contains(f) : f + " should not be listed";
+                else if (f.getName().endsWith("Compacted") || new File(f.getPath().replaceFirst("-[a-zA-Z]+.db", "-Compacted")).exists())
+                    assert !listed.contains(f) : f + " should not be listed";
+                else
+                    assert listed.contains(f) : f + " is missing";
+            }
+        }
+    }
+
+    @Test
+    public void testLeveledManifestPath()
+    {
+        for (String cf : CFS)
+        {
+            Directories directories = Directories.create(KS, cf);
+            File manifest = new File(cfDir(cf), cf + LeveledManifest.EXTENSION);
+            assertEquals(manifest, directories.tryGetLeveledManifest());
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9a76e646/test/unit/org/apache/cassandra/db/ScrubTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/ScrubTest.java b/test/unit/org/apache/cassandra/db/ScrubTest.java
index c549d1b..f8620f7 100644
--- a/test/unit/org/apache/cassandra/db/ScrubTest.java
+++ b/test/unit/org/apache/cassandra/db/ScrubTest.java
@@ -58,20 +58,16 @@ public class ScrubTest extends CleanupHelper
         File rootDir = new File(root);
         assert rootDir.isDirectory();
         
-        String[] destDirs = DatabaseDescriptor.getAllDataFileLocationsForTable(TABLE);
-        assert destDirs != null;
-        assert destDirs.length > 0;
+        File destDir = Directories.create(TABLE, CF2).getDirectoryForNewSSTables(1);
        
-        FileUtils.createDirectory(destDirs[0]);
+        FileUtils.createDirectory(destDir);
         for (File srcFile : rootDir.listFiles())
         {
             if (srcFile.getName().equals(".svn"))
                 continue;
-            File destFile = new File(destDirs[0]+File.separator+srcFile.getName());
+            File destFile = new File(destDir, srcFile.getName());
             CLibrary.createHardLinkWithExec(srcFile, destFile);
                         
-            destFile = new File(destDirs[0]+File.separator+srcFile.getName());
-                        
             assert destFile.exists() : destFile.getAbsoluteFile();
             
             if(destFile.getName().endsWith("Data.db"))

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9a76e646/test/unit/org/apache/cassandra/io/sstable/DescriptorTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/io/sstable/DescriptorTest.java b/test/unit/org/apache/cassandra/io/sstable/DescriptorTest.java
index 4ffca5a..d0568a5 100644
--- a/test/unit/org/apache/cassandra/io/sstable/DescriptorTest.java
+++ b/test/unit/org/apache/cassandra/io/sstable/DescriptorTest.java
@@ -25,58 +25,35 @@ import java.io.File;
 
 import org.junit.Test;
 
-import org.apache.cassandra.db.Table;
+import org.apache.cassandra.db.Directories;
 
 public class DescriptorTest
 {
     @Test
     public void testLegacy()
     {
-        Descriptor descriptor = Descriptor.fromFilename(new File("Keyspace1"), "userActionUtilsKey-9-Data.db").left;
+        Descriptor descriptor = Descriptor.fromFilename("Keyspace1-userActionUtilsKey-9-Data.db");
+
         assert descriptor.version.equals(Descriptor.LEGACY_VERSION);
         assert descriptor.usesOldBloomFilter;
     }
 
     @Test
-    public void testExtractKeyspace()
-    {
-        // Test a path representing a SNAPSHOT directory
-        String dirPath = "Keyspace10" + File.separator + Table.SNAPSHOT_SUBDIR_NAME + File.separator + System.currentTimeMillis();
-        assertKeyspace("Keyspace10", dirPath);
-
-        // Test a path representing a regular SSTables directory
-        dirPath = "Keyspace11";
-        assertKeyspace("Keyspace11", dirPath);
-    }
-
-    @Test
     public void testVersion()
     {
         // letter only
-        Descriptor desc = Descriptor.fromFilename(new File("Keyspace1"), "Standard1-h-1-Data.db").left;
+        Descriptor desc = Descriptor.fromFilename("Keyspace1-Standard1-h-1-Data.db");
         assert "h".equals(desc.version);
         assert desc.tracksMaxTimestamp;
 
         // multiple letters
-        desc = Descriptor.fromFilename(new File("Keyspace1"), "Standard1-ha-1-Data.db").left;
+        desc = Descriptor.fromFilename("Keyspace1-Standard1-ha-1-Data.db");
         assert "ha".equals(desc.version);
         assert desc.tracksMaxTimestamp;
 
         // hypothetical two-letter g version
-        desc = Descriptor.fromFilename(new File("Keyspace1"), "Standard1-gz-1-Data.db").left;
+        desc = Descriptor.fromFilename("Keyspace1-Standard1-gz-1-Data.db");
         assert "gz".equals(desc.version);
         assert !desc.tracksMaxTimestamp;
     }
-
-    private void assertKeyspace(String expectedKsName, String dirPath) {
-        File dir = new File(dirPath);
-        dir.deleteOnExit();
-
-        // Create and check.
-        if (!dir.mkdirs())
-            throw new RuntimeException("Unable to create directories:" + dirPath);
-
-        String currentKsName = Descriptor.extractKeyspaceName(dir);
-        assert expectedKsName.equals(currentKsName);
-    }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9a76e646/test/unit/org/apache/cassandra/io/sstable/SSTableReaderTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/io/sstable/SSTableReaderTest.java b/test/unit/org/apache/cassandra/io/sstable/SSTableReaderTest.java
index 86d9bb4..81cc016 100644
--- a/test/unit/org/apache/cassandra/io/sstable/SSTableReaderTest.java
+++ b/test/unit/org/apache/cassandra/io/sstable/SSTableReaderTest.java
@@ -221,20 +221,17 @@ public class SSTableReaderTest extends CleanupHelper
         File rootDir = new File(root + File.separator + "hb" + File.separator + "Keyspace1");
         assert rootDir.isDirectory();
 
-        String[] destDirs = DatabaseDescriptor.getAllDataFileLocationsForTable("Keyspace1");
-        assert destDirs != null;
-        assert destDirs.length > 0;
+        File destDir = Directories.create("Keyspace1", "Indexed1").getDirectoryForNewSSTables(0);
+        assert destDir != null;
 
-        FileUtils.createDirectory(destDirs[0]);
+        FileUtils.createDirectory(destDir);
         for (File srcFile : rootDir.listFiles())
         {
             if (!srcFile.getName().startsWith("Indexed1"))
                 continue;
-            File destFile = new File(destDirs[0] + File.separator + srcFile.getName());
+            File destFile = new File(destDir, srcFile.getName());
             CLibrary.createHardLinkWithExec(srcFile, destFile);
 
-            destFile = new File(destDirs[0] + File.separator + srcFile.getName());
-
             assert destFile.exists() : destFile.getAbsoluteFile();
         }
         ColumnFamilyStore store = Table.open("Keyspace1").getColumnFamilyStore("Indexed1");

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9a76e646/test/unit/org/apache/cassandra/io/sstable/SSTableSimpleWriterTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/io/sstable/SSTableSimpleWriterTest.java b/test/unit/org/apache/cassandra/io/sstable/SSTableSimpleWriterTest.java
index b0b129a..613eed4 100644
--- a/test/unit/org/apache/cassandra/io/sstable/SSTableSimpleWriterTest.java
+++ b/test/unit/org/apache/cassandra/io/sstable/SSTableSimpleWriterTest.java
@@ -37,12 +37,11 @@ public class SSTableSimpleWriterTest extends CleanupHelper
         final int INC = 5;
         final int NBCOL = 10;
 
-
         String tablename = "Keyspace1";
         String cfname = "StandardInteger1";
 
         Table t = Table.open(tablename); // make sure we create the directory
-        File dir = new File(t.getDataFileLocation(0));
+        File dir = Directories.create(tablename, cfname).getDirectoryForNewSSTables(0);
         assert dir.exists();
 
         SSTableSimpleUnsortedWriter writer = new SSTableSimpleUnsortedWriter(dir, tablename, cfname, IntegerType.instance, null, 16);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9a76e646/test/unit/org/apache/cassandra/streaming/BootstrapTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/streaming/BootstrapTest.java b/test/unit/org/apache/cassandra/streaming/BootstrapTest.java
index 7ae6504..b2d24f4 100644
--- a/test/unit/org/apache/cassandra/streaming/BootstrapTest.java
+++ b/test/unit/org/apache/cassandra/streaming/BootstrapTest.java
@@ -36,7 +36,7 @@ public class BootstrapTest extends SchemaLoader
     @Test
     public void testGetNewNames() throws IOException
     {
-        Descriptor desc = Descriptor.fromFilename(new File("Keyspace1", "Standard1-f-500-Data.db").toString());
+        Descriptor desc = Descriptor.fromFilename(new File("Keyspace1", "Keyspace1-Standard1-f-500-Data.db").toString());
         assert !desc.isLatestVersion; // deliberately test old version
         PendingFile inContext = new PendingFile(null, desc, "Data.db", Arrays.asList(new Pair<Long,Long>(0L, 1L)), OperationType.BOOTSTRAP);