Author: jbellis Date: Mon Dec 6 22:32:09 2010 New Revision: 1042824 URL: http://svn.apache.org/viewvc?rev=1042824&view=rev Log: add support for per-CF compaction patch by Jon Hermes; reviewed by jbellis for CASSANDRA-1812
Modified: cassandra/branches/cassandra-0.6/CHANGES.txt cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/db/ColumnFamilyStore.java cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/service/StorageService.java cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/service/StorageServiceMBean.java cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/tools/NodeCmd.java cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/tools/NodeProbe.java Modified: cassandra/branches/cassandra-0.6/CHANGES.txt URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.6/CHANGES.txt?rev=1042824&r1=1042823&r2=1042824&view=diff ============================================================================== --- cassandra/branches/cassandra-0.6/CHANGES.txt (original) +++ cassandra/branches/cassandra-0.6/CHANGES.txt Mon Dec 6 22:32:09 2010 @@ -12,6 +12,7 @@ with live subcolumn (CASSANDRA-1591) * clean up log messages for gossip token notifications (CASSANDRA-1518) * fix range queries against wrapped range (CASSANDRA-1781) + * add support for per-CF compaction (CASSANDRA-1812) * reduce fat client timeout (CASSANDRA-1730) Modified: cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/db/ColumnFamilyStore.java URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/db/ColumnFamilyStore.java?rev=1042824&r1=1042823&r2=1042824&view=diff ============================================================================== --- cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/db/ColumnFamilyStore.java (original) +++ cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/db/ColumnFamilyStore.java Mon Dec 6 22:32:09 2010 @@ -701,7 +701,7 @@ public class ColumnFamilyStore implement return maxFile; } - void forceCleanup() + public void forceCleanup() { CompactionManager.instance.submitCleanup(ColumnFamilyStore.this); } Modified: cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/service/StorageService.java URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/service/StorageService.java?rev=1042824&r1=1042823&r2=1042824&view=diff ============================================================================== --- cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/service/StorageService.java (original) +++ cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/service/StorageService.java Mon Dec 6 22:32:09 2010 @@ -554,7 +554,7 @@ public class StorageService implements I * Handle node move to normal state. That is, node is entering token ring and participating * in reads. * - * @param endPoint node + * @param endpoint node * @param pieces STATE_NORMAL,token[,other_state,token] */ private void handleStateNormal(InetAddress endpoint, String[] pieces) @@ -1034,11 +1034,12 @@ public class StorageService implements I table.forceCleanup(); } } - - public void forceTableCleanup(String tableName) throws IOException + public void forceTableCleanup(String tableName, String... columnFamilies) throws IOException { - Table table = getValidTable(tableName); - table.forceCleanup(); + for (ColumnFamilyStore cfStore : getValidColumnFamilies(tableName, columnFamilies)) + { + cfStore.forceCleanup(); + } } public void forceTableCompaction() throws IOException @@ -1046,11 +1047,12 @@ public class StorageService implements I for (Table table : Table.all()) table.forceCompaction(); } - - public void forceTableCompaction(String tableName) throws IOException + public void forceTableCompaction(String ks, String... columnFamilies) throws IOException { - Table table = getValidTable(tableName); - table.forceCompaction(); + for (ColumnFamilyStore cfStore : getValidColumnFamilies(ks, columnFamilies)) + { + cfStore.forceMajorCompaction(); + } } /** Modified: cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/service/StorageServiceMBean.java URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/service/StorageServiceMBean.java?rev=1042824&r1=1042823&r2=1042824&view=diff ============================================================================== --- cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/service/StorageServiceMBean.java (original) +++ cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/service/StorageServiceMBean.java Mon Dec 6 22:32:09 2010 @@ -96,9 +96,9 @@ public interface StorageServiceMBean public void forceTableCompaction() throws IOException; /** - * Forces major compaction of a single keyspace + * Forces major compaction on a single cf of a single keyspace */ - public void forceTableCompaction(String tableName) throws IOException; + public void forceTableCompaction(String ks, String... columnFamilies) throws IOException; /** * Trigger a cleanup of keys on all tables. @@ -108,7 +108,7 @@ public interface StorageServiceMBean /** * Trigger a cleanup of keys on a single keyspace */ - public void forceTableCleanup(String tableName) throws IOException; + public void forceTableCleanup(String tableName, String... columnFamilies) throws IOException; /** * Takes the snapshot for a given table. Modified: cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/tools/NodeCmd.java URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/tools/NodeCmd.java?rev=1042824&r1=1042823&r2=1042824&view=diff ============================================================================== --- cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/tools/NodeCmd.java (original) +++ cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/tools/NodeCmd.java Mon Dec 6 22:32:09 2010 @@ -69,19 +69,33 @@ public class NodeCmd { private static void printUsage() { HelpFormatter hf = new HelpFormatter(); - String header = String.format( - "%nAvailable commands: ring, info, cleanup, compact, cfstats, snapshot [snapshotname], clearsnapshot, " + - "tpstats, flush, drain, repair, decommission, move, loadbalance, removetoken, " + - "setcachecapacity <keyspace> <cfname> <keycachecapacity> <rowcachecapacity>, " + - "getcompactionthreshold, setcompactionthreshold [minthreshold] ([maxthreshold])" + - "streams [host], cfhistograms <keyspace> <column_family>"); + String header = String.format("%nAvailable commands:%n" + + "ring%n" + + "info%n" + + "cfstats%n" + + "snapshot [snapshotname]%n" + + "info%n" + + "cfstats%n" + + "tpstats%n" + + "flush%n" + + "drain%n" + + "decommission%n" + + "move <new token>%n" + + "loadbalance%n" + + "removetoken <token>%n" + + "repair|cleanup|compact [keyspace] [columfamilies]%n" + + "setcachecapacity <keyspace> <cfname> <keycachecapacity> <rowcachecapacity>%n" + + "getcompactionthreshold%n" + + "setcompactionthreshold [minthreshold] ([maxthreshold])%n" + + "streams [host]%n" + + "cfhistograms <keyspace> <column_family>%n"); String usage = String.format("java %s --host <arg> <command>%n", NodeCmd.class.getName()); hf.printHelp(usage, "", options, header); } - + /** * Write a textual representation of the Cassandra ring. - * + * * @param outs the stream to write to */ public void printRing(PrintStream outs) @@ -148,11 +162,11 @@ public class NodeCmd { asciiRingArt = "| |"; } outs.println(asciiRingArt); - + counter++; } } - + public void printThreadPoolStats(PrintStream outs) { outs.print(String.format("%-25s", "Pool Name")); @@ -160,9 +174,9 @@ public class NodeCmd { outs.print(String.format("%10s", "Pending")); outs.print(String.format("%15s", "Completed")); outs.println(); - + Iterator<Map.Entry<String, IExecutorMBean>> threads = probe.getThreadPoolMBeanProxies(); - + for (; threads.hasNext();) { Map.Entry<String, IExecutorMBean> thread = threads.next(); @@ -178,7 +192,7 @@ public class NodeCmd { /** * Write node information. - * + * * @param outs the stream to write to */ public void printInfo(PrintStream outs) @@ -186,7 +200,7 @@ public class NodeCmd { outs.println(probe.getToken()); outs.println(String.format("%-17s: %s", "Load", probe.getLoadString())); outs.println(String.format("%-17s: %s", "Generation No", probe.getCurrentGenerationNumber())); - + // Uptime long secondsUp = probe.getUptime() / 1000; outs.println(String.format("%-17s: %d", "Uptime (seconds)", secondsUp)); @@ -251,7 +265,7 @@ public class NodeCmd { } } } - + public void printColumnFamilyStats(PrintStream outs) { Map <String, List <ColumnFamilyStoreMBean>> cfstoreMap = new HashMap <String, List <ColumnFamilyStoreMBean>>(); @@ -454,12 +468,32 @@ public class NodeCmd { else probe.forceTableCleanup(); } - else if (cmdName.equals("compact")) + else if (cmdName.equals("compact") || cmdName.equals("cleanup")) { - if (arguments.length > 1) - probe.forceTableCompaction(arguments[1]); + if (arguments.length == 1) + { + if (cmdName.equals("compact")) + probe.forceTableCompaction(); + else + probe.forceTableCleanup(); + } else - probe.forceTableCompaction(); + { + String[] columnFamilies = new String[cmd.getArgs().length - 2]; + for (int i = 0; i < columnFamilies.length; i++) + { + columnFamilies[i] = cmd.getArgs()[i + 2]; + } + + if (cmdName.equals("compact")) + { + probe.forceTableCompaction(arguments[1],columnFamilies); + } + else + { + probe.forceTableCleanup(arguments[1],columnFamilies); + } + } } else if (cmdName.equals("cfstats")) { Modified: cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/tools/NodeProbe.java URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/tools/NodeProbe.java?rev=1042824&r1=1042823&r2=1042824&view=diff ============================================================================== --- cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/tools/NodeProbe.java (original) +++ cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/tools/NodeProbe.java Mon Dec 6 22:32:09 2010 @@ -132,20 +132,18 @@ public class NodeProbe { ssProxy.forceTableCleanup(); } - - public void forceTableCleanup(String tableName) throws IOException + public void forceTableCleanup(String ks, String... columnFamilies) throws IOException { - ssProxy.forceTableCleanup(tableName); + ssProxy.forceTableCleanup(ks, columnFamilies); } public void forceTableCompaction() throws IOException { ssProxy.forceTableCompaction(); } - - public void forceTableCompaction(String tableName) throws IOException + public void forceTableCompaction(String ks, String... columnFamilies) throws IOException { - ssProxy.forceTableCompaction(tableName); + ssProxy.forceTableCompaction(ks, columnFamilies); } public void forceTableFlush(String tableName, String... columnFamilies) throws IOException