cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1044109 - in /cassandra/branches/cassandra-0.6: CHANGES.txt src/java/org/apache/cassandra/db/Table.java
Date Thu, 09 Dec 2010 19:48:55 GMT
Author: jbellis
Date: Thu Dec  9 19:48:55 2010
New Revision: 1044109

URL: http://svn.apache.org/viewvc?rev=1044109&view=rev
Log:
cleanup smallest CFs first to increase free temp space for larger ones
patch by Jon Hermes and jbellis for CASSANDRA-1811

Modified:
    cassandra/branches/cassandra-0.6/CHANGES.txt
    cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/db/Table.java

Modified: cassandra/branches/cassandra-0.6/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.6/CHANGES.txt?rev=1044109&r1=1044108&r2=1044109&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.6/CHANGES.txt (original)
+++ cassandra/branches/cassandra-0.6/CHANGES.txt Thu Dec  9 19:48:55 2010
@@ -14,6 +14,8 @@
  * fix range queries against wrapped range (CASSANDRA-1781)
  * add support for per-CF compaction (CASSANDRA-1812)
  * reduce fat client timeout (CASSANDRA-1730)
+ * cleanup smallest CFs first to increase free temp space for larger ones
+   (CASSANDRA-1811)
 
 
 0.6.8

Modified: cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/db/Table.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/db/Table.java?rev=1044109&r1=1044108&r2=1044109&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/db/Table.java (original)
+++ cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/db/Table.java Thu Dec 
9 19:48:55 2010
@@ -226,15 +226,28 @@ public class Table 
     public void forceCleanup()
     {
         if (name.equals(SYSTEM_TABLE))
-            throw new RuntimeException("Cleanup of the system table is neither necessary
nor wise");
+            throw new UnsupportedOperationException("Cleanup of the system table is neither
necessary nor wise");
 
-        Set<String> columnFamilies = tableMetadata.getColumnFamilies();
-        for ( String columnFamily : columnFamilies )
+        // Sort the column families in order of SSTable size, so cleanup of smaller CFs
+        // can free up space for larger ones
+        List<ColumnFamilyStore> sortedColumnFamilies = new ArrayList<ColumnFamilyStore>(columnFamilyStores.values());
+        Collections.sort(sortedColumnFamilies, new Comparator<ColumnFamilyStore>()
         {
-            ColumnFamilyStore cfStore = columnFamilyStores.get( columnFamily );
-            if ( cfStore != null )
-                cfStore.forceCleanup();
-        }   
+            // Compare first on size and, if equal, sort by name (arbitrary & deterministic).
+            public int compare(ColumnFamilyStore cf1, ColumnFamilyStore cf2)
+            {
+                long diff = (cf1.getTotalDiskSpaceUsed() - cf2.getTotalDiskSpaceUsed());
+                if (diff > 0)
+                    return 1;
+                if (diff < 0)
+                    return -1;
+                return cf1.columnFamily_.compareTo(cf2.columnFamily_);
+            }
+        });
+
+        // Cleanup in sorted order to free up space for the larger ones
+        for (ColumnFamilyStore cfs : sortedColumnFamilies)
+            cfs.forceCleanup();
     }
     
     



Mime
View raw message