cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1005473 - in /cassandra/trunk: CHANGES.txt src/java/org/apache/cassandra/service/StorageService.java src/java/org/apache/cassandra/service/StorageServiceMBean.java
Date Thu, 07 Oct 2010 14:52:55 GMT
Author: jbellis
Date: Thu Oct  7 14:52:54 2010
New Revision: 1005473

URL: http://svn.apache.org/viewvc?rev=1005473&view=rev
Log:
add StorageService.getDrainProgress.
patch by Nick Bailey and jbellis for CASSANDRA-1588

Modified:
    cassandra/trunk/CHANGES.txt
    cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java
    cassandra/trunk/src/java/org/apache/cassandra/service/StorageServiceMBean.java

Modified: cassandra/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/trunk/CHANGES.txt?rev=1005473&r1=1005472&r2=1005473&view=diff
==============================================================================
--- cassandra/trunk/CHANGES.txt (original)
+++ cassandra/trunk/CHANGES.txt Thu Oct  7 14:52:54 2010
@@ -18,6 +18,7 @@ dev
  * allow keyspace creation with RF > N (CASSANDRA-1428)
  * improve cli error handling (CASSANDRA-1580)
  * add cache save/load ability (CASSANDRA-1417)
+ * add StorageService.getDrainProgress (CASSANDRA-1588)
 
 
 0.7-beta2

Modified: cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java?rev=1005473&r1=1005472&r2=1005473&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java Thu Oct  7 14:52:54
2010
@@ -181,6 +181,9 @@ public class StorageService implements I
     private String operationMode;
     private MigrationManager migrationManager = new MigrationManager();
 
+    /* Used for tracking drain progress */
+    private volatile int totalCFs, remainingCFs;
+
     public void finishBootstrapping()
     {
         isBootstrapMode = false;
@@ -1840,7 +1843,12 @@ public class StorageService implements I
     {
         return operationMode;
     }
-    
+
+    public String getDrainProgress()
+    {
+        return String.format("Drained %s/%s ColumnFamilies", remainingCFs, totalCFs);
+    }
+
     /** shuts node off to writes, empties memtables and the commit log. */
     public synchronized void drain() throws IOException, InterruptedException, ExecutionException
     {
@@ -1856,20 +1864,29 @@ public class StorageService implements I
         MessagingService.shutdown();
         setMode("Draining: emptying MessageService pools", false);
         MessagingService.waitFor();
-       
+
         setMode("Draining: clearing mutation stage", false);
         mutationStage.shutdown();
         mutationStage.awaitTermination(3600, TimeUnit.SECONDS);
 
         // lets flush.
         setMode("Draining: flushing column families", false);
+        List<ColumnFamilyStore> cfses = new ArrayList<ColumnFamilyStore>();
         for (String tableName : DatabaseDescriptor.getNonSystemTables())
-            for (Future f : Table.open(tableName).flush())
-                f.get();
+        {
+            Table table = Table.open(tableName);
+            cfses.addAll(table.getColumnFamilyStores());
+        }
+        totalCFs = remainingCFs = cfses.size();
+        for (ColumnFamilyStore cfs : cfses)
+        {
+            cfs.forceBlockingFlush();
+            remainingCFs--;
+        }
 
         ColumnFamilyStore.postFlushExecutor.shutdown();
         ColumnFamilyStore.postFlushExecutor.awaitTermination(60, TimeUnit.SECONDS);
-       
+
         // want to make sure that any segments deleted as a result of flushing are gone.
         DeletionService.waitFor();
 

Modified: cassandra/trunk/src/java/org/apache/cassandra/service/StorageServiceMBean.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/service/StorageServiceMBean.java?rev=1005473&r1=1005472&r2=1005473&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/service/StorageServiceMBean.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/service/StorageServiceMBean.java Thu Oct
 7 14:52:54 2010
@@ -225,6 +225,9 @@ public interface StorageServiceMBean
     /** get the operational mode (leaving, joining, normal, decommissioned, client) **/
     public String getOperationMode();
 
+    /** get the progress of a drain operation */
+    public String getDrainProgress();
+
     /** makes node unavailable for writes, flushes memtables and replays commitlog. */
     public void drain() throws IOException, InterruptedException, ExecutionException;
 



Mime
View raw message