cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r934673 - in /cassandra/trunk: src/java/org/apache/cassandra/db/Table.java src/java/org/apache/cassandra/io/util/FileUtils.java test/unit/org/apache/cassandra/CleanupHelper.java
Date Fri, 16 Apr 2010 02:27:08 GMT
Author: jbellis
Date: Fri Apr 16 02:27:08 2010
New Revision: 934673

URL: http://svn.apache.org/viewvc?rev=934673&view=rev
Log:
rename deleteDir -> deleteRecursive; use in CleanupHelper (automatically cleans up snapshots)
patch by jbellis; reviewed by gdusbabek for CASSANDRA-983

Modified:
    cassandra/trunk/src/java/org/apache/cassandra/db/Table.java
    cassandra/trunk/src/java/org/apache/cassandra/io/util/FileUtils.java
    cassandra/trunk/test/unit/org/apache/cassandra/CleanupHelper.java

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/Table.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/Table.java?rev=934673&r1=934672&r2=934673&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/Table.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/Table.java Fri Apr 16 02:27:08 2010
@@ -190,7 +190,7 @@ public class Table 
             {
                 if (logger.isDebugEnabled())
                     logger.debug("Removing snapshot directory " + snapshotPath);
-                FileUtils.deleteDir(snapshotDir);
+                FileUtils.deleteRecursive(snapshotDir);
             }
         }
     }
@@ -250,7 +250,7 @@ public class Table 
                 // remove the deprecated streaming directory.
                 File streamingDir = new File(keyspaceDir, "stream");
                 if (streamingDir.exists())
-                    FileUtils.deleteDir(streamingDir);
+                    FileUtils.deleteRecursive(streamingDir);
             }
             catch (IOException ex)
             {

Modified: cassandra/trunk/src/java/org/apache/cassandra/io/util/FileUtils.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/io/util/FileUtils.java?rev=934673&r1=934672&r2=934673&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/io/util/FileUtils.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/io/util/FileUtils.java Fri Apr 16 02:27:08
2010
@@ -21,9 +21,6 @@ package org.apache.cassandra.io.util;
 import java.io.*;
 import java.text.DecimalFormat;
 import java.util.*;
-import java.util.concurrent.ExecutorService;
-
-import org.apache.cassandra.concurrent.JMXEnabledThreadPoolExecutor;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -184,14 +181,14 @@ public class FileUtils
      * @param dir Directory to be deleted
      * @throws IOException if any part of the tree cannot be deleted
      */
-    public static void deleteDir(File dir) throws IOException
+    public static void deleteRecursive(File dir) throws IOException
     {
         if (dir.isDirectory())
         {
             String[] children = dir.list();
             for (int i = 0; i < children.length; i++)
             {
-                deleteDir(new File(dir, children[i]));
+                deleteRecursive(new File(dir, children[i]));
             }
         }
 

Modified: cassandra/trunk/test/unit/org/apache/cassandra/CleanupHelper.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/CleanupHelper.java?rev=934673&r1=934672&r2=934673&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/CleanupHelper.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/CleanupHelper.java Fri Apr 16 02:27:08
2010
@@ -54,11 +54,7 @@ public class CleanupHelper extends Schem
             {
                 throw new RuntimeException("No such directory: " + dir.getAbsolutePath());
             }
-            for (File f : dir.listFiles())
-            {
-                FileUtils.deleteWithConfirm(f);
-            }
-            FileUtils.deleteWithConfirm(dir);
+            FileUtils.deleteRecursive(dir);
         }
 
         // clean up data directory which are stored as data directory/table/data files
@@ -69,19 +65,7 @@ public class CleanupHelper extends Schem
             {
                 throw new RuntimeException("No such directory: " + dir.getAbsolutePath());
             }
-            for (File tableFile : dir.listFiles())
-            {
-                // table directory
-                if (tableFile.isDirectory())
-                {
-                    for (File dataFile : tableFile.listFiles())
-                    {
-                        FileUtils.deleteWithConfirm(dataFile);
-                    }
-                }
-                FileUtils.deleteWithConfirm(tableFile);
-            }
-            FileUtils.deleteWithConfirm(dir);
+            FileUtils.deleteRecursive(dir);
         }
     }
 



Mime
View raw message