cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yu...@apache.org
Subject [3/5] git commit: Fix user defined compaction
Date Wed, 15 Jan 2014 03:13:24 GMT
Fix user defined compaction


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

Branch: refs/heads/trunk
Commit: be2141757010aacbcb2c6ebaa00623db14e192bd
Parents: 0bfe9ef
Author: Yuki Morishita <yukim@apache.org>
Authored: Thu Jan 9 15:23:11 2014 -0600
Committer: Yuki Morishita <yukim@apache.org>
Committed: Tue Jan 14 20:23:22 2014 -0600

----------------------------------------------------------------------
 .../org/apache/cassandra/db/Directories.java    | 10 +++++++++
 .../db/compaction/CompactionManager.java        | 23 ++++++--------------
 2 files changed, 17 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/be214175/src/java/org/apache/cassandra/db/Directories.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/Directories.java b/src/java/org/apache/cassandra/db/Directories.java
index 9eb254e..a124d67 100644
--- a/src/java/org/apache/cassandra/db/Directories.java
+++ b/src/java/org/apache/cassandra/db/Directories.java
@@ -248,6 +248,16 @@ public class Directories
         return null;
     }
 
+    public Descriptor find(String filename)
+    {
+        for (File dir : sstableDirectories)
+        {
+            if (new File(dir, filename).exists())
+                return Descriptor.fromFilename(dir, filename).left;
+        }
+        return null;
+    }
+
     public File getDirectoryForNewSSTables()
     {
         File path = getWriteableLocationAsFile();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/be214175/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 e4f5237..7927574 100644
--- a/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
+++ b/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
@@ -303,7 +303,7 @@ public class CompactionManager implements CompactionManagerMBean
     public void forceUserDefinedCompaction(String dataFiles)
     {
         String[] filenames = dataFiles.split(",");
-        Multimap<Pair<String, String>, Descriptor> descriptors = ArrayListMultimap.create();
+        Multimap<ColumnFamilyStore, Descriptor> descriptors = ArrayListMultimap.create();
 
         for (String filename : filenames)
         {
@@ -314,19 +314,14 @@ public class CompactionManager implements CompactionManagerMBean
                 logger.warn("Schema does not exist for file {}. Skipping.", filename);
                 continue;
             }
-            File directory = new File(desc.ksname + File.separator + desc.cfname);
             // group by keyspace/columnfamily
-            Pair<Descriptor, String> p = Descriptor.fromFilename(directory, filename.trim());
-            Pair<String, String> key = Pair.create(p.left.ksname, p.left.cfname);
-            descriptors.put(key, p.left);
+            ColumnFamilyStore cfs = Keyspace.open(desc.ksname).getColumnFamilyStore(desc.cfname);
+            descriptors.put(cfs, cfs.directories.find(filename.trim()));
         }
 
         List<Future<?>> futures = new ArrayList<>();
-        for (Pair<String, String> key : descriptors.keySet())
-        {
-            ColumnFamilyStore cfs = Keyspace.open(key.left).getColumnFamilyStore(key.right);
-            futures.add(submitUserDefined(cfs, descriptors.get(key), getDefaultGcBefore(cfs)));
-        }
+        for (ColumnFamilyStore cfs : descriptors.keySet())
+            futures.add(submitUserDefined(cfs, descriptors.get(cfs), getDefaultGcBefore(cfs)));
         FBUtilities.waitOnFutures(futures);
     }
 
@@ -369,16 +364,12 @@ public class CompactionManager implements CompactionManagerMBean
     }
 
     // This acquire a reference on the sstable
-    // This is not efficent, do not use in any critical path
+    // This is not efficient, do not use in any critical path
     private SSTableReader lookupSSTable(final ColumnFamilyStore cfs, Descriptor descriptor)
     {
         for (SSTableReader sstable : cfs.getSSTables())
         {
-            // .equals() with no other changes won't work because in sstable.descriptor,
the directory is an absolute path.
-            // We could construct descriptor with an absolute path too but I haven't found
any satisfying way to do that
-            // (DB.getDataFileLocationForTable() may not return the right path if you have
multiple volumes). Hence the
-            // endsWith.
-            if (sstable.descriptor.toString().endsWith(descriptor.toString()))
+            if (sstable.descriptor.equals(descriptor))
                 return sstable;
         }
         return null;


Mime
View raw message