Author: jbellis
Date: Fri Oct 21 16:36:41 2011
New Revision: 1187456

URL: http://svn.apache.org/viewvc?rev=1187456&view=rev
Log:
CompactionManager is now responsible for checking for new candidates post-task 
execution
patch by jbellis; reviewed by slebresne for CASSANDRA-3363

Modified:
    cassandra/branches/cassandra-1.0/CHANGES.txt
    
cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
    
cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/compaction/CompactionTask.java
    
cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/compaction/LeveledCompactionStrategy.java

Modified: cassandra/branches/cassandra-1.0/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/cassandra/branches/cassandra-1.0/CHANGES.txt?rev=1187456&r1=1187455&r2=1187456&view=diff
==============================================================================
--- cassandra/branches/cassandra-1.0/CHANGES.txt (original)
+++ cassandra/branches/cassandra-1.0/CHANGES.txt Fri Oct 21 16:36:41 2011
@@ -18,6 +18,9 @@
  * optimize UUIDGen to avoid lock contention on InetAddress.getLocalHost 
    (CASSANDRA-3387)
  * tolerate index being dropped mid-mutation (CASSANDRA-3334, 3313)
+ * CompactionManager is now responsible for checking for new candidates
+   post-task execution, enabling more consistent leveled compaction 
+   (CASSANDRA-3391)
 Merged from 0.8:
  * (CQL) update grammar to require key clause in DELETE statement
    (CASSANDRA-3349)

Modified: 
cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
URL: 
http://svn.apache.org/viewvc/cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/compaction/CompactionManager.java?rev=1187456&r1=1187455&r2=1187456&view=diff
==============================================================================
--- 
cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
 (original)
+++ 
cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
 Fri Oct 21 16:36:41 2011
@@ -121,7 +121,8 @@ public class CompactionManager implement
                         return 0;
 
                     AbstractCompactionStrategy strategy = 
cfs.getCompactionStrategy();
-                    for (AbstractCompactionTask task : 
strategy.getBackgroundTasks(getDefaultGcBefore(cfs)))
+                    List<AbstractCompactionTask> tasks = 
strategy.getBackgroundTasks(getDefaultGcBefore(cfs));
+                    for (AbstractCompactionTask task : tasks)
                     {
                         if (!task.markSSTablesForCompaction())
                             continue;
@@ -135,6 +136,10 @@ public class CompactionManager implement
                             task.unmarkSSTables();
                         }
                     }
+
+                    // newly created sstables might have made other 
compactions eligible
+                    if (!tasks.isEmpty())
+                        submitBackground(cfs);
                 }
                 finally 
                 {

Modified: 
cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/compaction/CompactionTask.java
URL: 
http://svn.apache.org/viewvc/cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/compaction/CompactionTask.java?rev=1187456&r1=1187455&r2=1187456&view=diff
==============================================================================
--- 
cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/compaction/CompactionTask.java
 (original)
+++ 
cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/compaction/CompactionTask.java
 Fri Oct 21 16:36:41 2011
@@ -198,8 +198,6 @@ public class CompactionTask extends Abst
                key.cacheKey(entry.getKey(), entry.getValue());
         }
 
-        CompactionManager.instance.submitBackground(cfs);
-
         long dTime = System.currentTimeMillis() - startTime;
         long startsize = SSTable.getTotalBytes(toCompact);
         long endsize = SSTable.getTotalBytes(sstables);

Modified: 
cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/compaction/LeveledCompactionStrategy.java
URL: 
http://svn.apache.org/viewvc/cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/compaction/LeveledCompactionStrategy.java?rev=1187456&r1=1187455&r2=1187456&view=diff
==============================================================================
--- 
cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/compaction/LeveledCompactionStrategy.java
 (original)
+++ 
cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/db/compaction/LeveledCompactionStrategy.java
 Fri Oct 21 16:36:41 2011
@@ -78,16 +78,6 @@ public class LeveledCompactionStrategy e
         // override min/max for this strategy
         cfs.setMaximumCompactionThreshold(Integer.MAX_VALUE);
         cfs.setMinimumCompactionThreshold(1);
-
-        // TODO this is redundant wrt the kickoff in 
AbstractCompactionStrategy, once CASSANDRA-X is done
-        Runnable runnable = new Runnable()
-        {
-            public void run()
-            {
-                
CompactionManager.instance.submitBackground(LeveledCompactionStrategy.this.cfs);
-            }
-        };
-        StorageService.optionalTasks.scheduleAtFixedRate(runnable, 5 * 60, 5, 
TimeUnit.SECONDS);
     }
 
     public void shutdown()


Reply via email to