cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r828796 - in /incubator/cassandra/branches/cassandra-0.4: CHANGES.txt src/java/org/apache/cassandra/service/StorageService.java src/java/org/apache/cassandra/service/StorageServiceMBean.java src/java/org/apache/cassandra/tools/NodeProbe.java
Date Thu, 22 Oct 2009 17:45:41 GMT
Author: jbellis
Date: Thu Oct 22 17:45:41 2009
New Revision: 828796

URL: http://svn.apache.org/viewvc?rev=828796&view=rev
Log:
replace flush_binary with flush, affecting both binary and standard memtables.  patch by gdusbabek;
reviewd by jbellis for CASSANDRA-505

Modified:
    incubator/cassandra/branches/cassandra-0.4/CHANGES.txt
    incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/service/StorageService.java
    incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/service/StorageServiceMBean.java
    incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/tools/NodeProbe.java

Modified: incubator/cassandra/branches/cassandra-0.4/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/cassandra/branches/cassandra-0.4/CHANGES.txt?rev=828796&r1=828795&r2=828796&view=diff
==============================================================================
--- incubator/cassandra/branches/cassandra-0.4/CHANGES.txt (original)
+++ incubator/cassandra/branches/cassandra-0.4/CHANGES.txt Thu Oct 22 17:45:41 2009
@@ -4,6 +4,8 @@
  * Fix using non-utf8-aware comparison as a sanity check.
    (CASSANDRA-493)
  * Improve default garbage collector options (CASSANDRA-504)
+ * Add "nodeprobe flush" (CASSANDRA-505)
+
 
 0.4.1
  * Fix FlushPeriod columnfamily configuration regression

Modified: incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/service/StorageService.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/service/StorageService.java?rev=828796&r1=828795&r2=828796&view=diff
==============================================================================
--- incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/service/StorageService.java
(original)
+++ incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/service/StorageService.java
Thu Oct 22 17:45:41 2009
@@ -770,7 +770,13 @@
             logger_.debug("Cleared out all snapshot directories");
     }
 
-    public void forceTableFlushBinary(String tableName) throws IOException
+    /**
+     * Flush all memtables for a table and column families.
+     * @param tableName
+     * @param columnFamilies
+     * @throws IOException
+     */
+    public void forceTableFlush(String tableName, String... columnFamilies) throws IOException
     {
         if (DatabaseDescriptor.getTable(tableName) == null)
         {
@@ -778,16 +784,33 @@
         }
 
         Table table = Table.open(tableName);
-        Set<String> columnFamilies = table.getColumnFamilies();
+        Set<String> positiveColumnFamilies = table.getColumnFamilies();
+
+        // no columnFamilies means flush'em all.
+        if (columnFamilies == null || columnFamilies.length == 0)
+        {
+            columnFamilies = positiveColumnFamilies.toArray(new String[positiveColumnFamilies.size()]);
+        }
+
         for (String columnFamily : columnFamilies)
         {
-            ColumnFamilyStore cfStore = table.getColumnFamilyStore(columnFamily);
-            logger_.debug("Forcing flush on keyspace " + tableName + " on CF " + columnFamily);
-            cfStore.forceFlushBinary();
+
+            if (positiveColumnFamilies.contains(columnFamily))
+            {
+                ColumnFamilyStore cfStore = table.getColumnFamilyStore(columnFamily);
+                logger_.debug("Forcing binary flush on keyspace " + tableName + ", CF " +
columnFamily);
+                cfStore.forceFlushBinary();
+                logger_.debug("Forcing flush on keyspace " + tableName + ", CF " + columnFamily);
+                cfStore.forceFlush();
+            }
+            else
+            {
+                // this means there was a cf passed in that is not recognized in the keyspace.
report it and continue.
+                logger_.warn(String.format("Invalid column family specified: %s. Proceeding
with others.", columnFamily));
+            }
         }
     }
 
-
     /* End of MBean interface methods */
     
     /**

Modified: incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/service/StorageServiceMBean.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/service/StorageServiceMBean.java?rev=828796&r1=828795&r2=828796&view=diff
==============================================================================
--- incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/service/StorageServiceMBean.java
(original)
+++ incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/service/StorageServiceMBean.java
Thu Oct 22 17:45:41 2009
@@ -86,11 +86,13 @@
     public void clearSnapshot() throws IOException;
 
     /**
-     * Flush all binary memtables for a table
+     * Flush all memtables for the given column families, or all columnfamilies for the given
table
+     * if none are explicitly listed.
      * @param tableName
+     * @param columnFamilies
      * @throws IOException
      */
-    public void forceTableFlushBinary(String tableName) throws IOException;
+    public void forceTableFlush(String tableName, String... columnFamilies) throws IOException;
 
     /** set the logging level at runtime */
     public void setLog4jLevel(String classQualifier, String level);

Modified: incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/tools/NodeProbe.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/tools/NodeProbe.java?rev=828796&r1=828795&r2=828796&view=diff
==============================================================================
--- incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/tools/NodeProbe.java
(original)
+++ incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/tools/NodeProbe.java
Thu Oct 22 17:45:41 2009
@@ -260,11 +260,11 @@
     }
 
     /**
-     * Trigger a binary flush on CFs of a table.
+     * Trigger a flush of the given CFs
      */
-    public void forceTableFlushBinary(String tableName) throws IOException
+    public void forceTableFlush(String tableName, String... columnFamilies) throws IOException
     {
-        ssProxy.forceTableFlushBinary(tableName);
+        ssProxy.forceTableFlush(tableName, columnFamilies);
     }
 
 
@@ -529,7 +529,7 @@
     {
         HelpFormatter hf = new HelpFormatter();
         String header = String.format(
-                "%nAvailable commands: ring, cluster, info, cleanup, compact, cfstats, snapshot
[name], clearsnapshot, bootstrap, tpstats, flush_binary");
+                "%nAvailable commands: ring, cluster, info, cleanup, compact, cfstats, snapshot
[name], clearsnapshot, bootstrap, tpstats, flush");
         String usage = String.format("java %s -host <arg> <command>%n", NodeProbe.class.getName());
         hf.printHelp(usage, "", options, header);
     }
@@ -621,7 +621,7 @@
         {
             probe.printThreadPoolStats(System.out);
         }
-        else if (cmdName.equals("flush_binary"))
+        else if (cmdName.equals("flush"))
         {
             if (probe.getArgs().length < 2)
             {
@@ -629,7 +629,13 @@
                 NodeProbe.printUsage();
                 System.exit(1);
             }
-            probe.forceTableFlushBinary(probe.getArgs()[1]);
+
+            String[] columnFamilies = new String[probe.getArgs().length - 2];
+            for (int i = 0; i < columnFamilies.length; i++)
+            {
+                columnFamilies[i] = probe.getArgs()[i + 2];
+            }   
+            probe.forceTableFlush(probe.getArgs()[1], columnFamilies);
         }
         else
         {



Mime
View raw message