You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by jb...@apache.org on 2009/12/29 18:33:24 UTC

svn commit: r894451 - in /incubator/cassandra/trunk: src/java/org/apache/cassandra/db/ src/java/org/apache/cassandra/io/ src/java/org/apache/cassandra/io/util/ test/unit/org/apache/cassandra/db/ test/unit/org/apache/cassandra/tools/

Author: jbellis
Date: Tue Dec 29 17:33:24 2009
New Revision: 894451

URL: http://svn.apache.org/viewvc?rev=894451&view=rev
Log:
move deleteAsync into DeletionService.  patch by jbellis

Added:
    incubator/cassandra/trunk/src/java/org/apache/cassandra/io/DeletionService.java   (with props)
Modified:
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/CommitLog.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/io/util/FileUtils.java
    incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyTest.java
    incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/ReadMessageTest.java
    incubator/cassandra/trunk/test/unit/org/apache/cassandra/tools/SSTableExportTest.java

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/CommitLog.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/CommitLog.java?rev=894451&r1=894450&r2=894451&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/CommitLog.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/CommitLog.java Tue Dec 29 17:33:24 2009
@@ -21,7 +21,7 @@
 import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.io.util.BufferedRandomAccessFile;
 import org.apache.cassandra.io.util.DataOutputBuffer;
-import org.apache.cassandra.io.util.FileUtils;
+import org.apache.cassandra.io.DeletionService;
 import org.apache.cassandra.utils.FBUtilities;
 import org.apache.cassandra.concurrent.StageManager;
 
@@ -570,7 +570,7 @@
             if (header.isSafeToDelete())
             {
                 logger_.info("Deleting obsolete commit log:" + oldFile);
-                FileUtils.deleteAsync(oldFile);
+                DeletionService.deleteAsync(oldFile);
                 clHeaders_.remove(oldFile);
             }
             else

Added: incubator/cassandra/trunk/src/java/org/apache/cassandra/io/DeletionService.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/io/DeletionService.java?rev=894451&view=auto
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/io/DeletionService.java (added)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/io/DeletionService.java Tue Dec 29 17:33:24 2009
@@ -0,0 +1,32 @@
+package org.apache.cassandra.io;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.concurrent.ExecutorService;
+
+import org.apache.cassandra.concurrent.JMXEnabledThreadPoolExecutor;
+import org.apache.cassandra.io.util.FileUtils;
+
+public class DeletionService
+{
+    public static final ExecutorService executor = new JMXEnabledThreadPoolExecutor("FILEUTILS-DELETE-POOL");
+
+    public static void deleteAsync(final String file) throws IOException
+    {
+        Runnable deleter = new Runnable()
+        {
+            public void run()
+            {
+                try
+                {
+                    FileUtils.deleteWithConfirm(new File(file));
+                }
+                catch (IOException e)
+                {
+                    throw new RuntimeException(e);
+                }
+            }
+        };
+        executor.submit(deleter);
+    }
+}

Propchange: incubator/cassandra/trunk/src/java/org/apache/cassandra/io/DeletionService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/io/util/FileUtils.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/io/util/FileUtils.java?rev=894451&r1=894450&r2=894451&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/io/util/FileUtils.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/io/util/FileUtils.java Tue Dec 29 17:33:24 2009
@@ -37,43 +37,17 @@
     private static final double gb_ = 1024*1024*1024d;
     private static final double tb_ = 1024*1024*1024*1024d;
 
-    private static ExecutorService deleter_ = new JMXEnabledThreadPoolExecutor("FILEUTILS-DELETE-POOL");
-
-    public static void shutdown()
-    {
-    	deleter_.shutdownNow();
-    }
-
     public static void deleteWithConfirm(File file) throws IOException
     {
         assert file.exists() : "attempted to delete non-existing file " + file.getName();
+        if (logger_.isDebugEnabled())
+            logger_.debug("Deleting " + file.getName());
         if (!file.delete())
         {
             throw new IOException("Failed to delete " + file.getAbsolutePath());
         }
     }
 
-    public static class Deleter implements Runnable
-    {
-    	File file_ = null;
-
-    	public Deleter(File f)
-        {
-    		file_ = f;
-        }
-
-        public void run()
-        {
-        	if(file_ == null)
-        		return;
-        	logger_.debug("Deleting " + file_.getName());
-        	if (!file_.delete())
-        	{
-            	logger_.error("Unable to delete file " + file_.getAbsolutePath());
-        	}
-        }
-    }
-
     public static class FileComparator implements Comparator<File>
     {
         public int compare(File f, File f2)
@@ -113,13 +87,6 @@
         return f.delete();
     }
 
-    public static void deleteAsync(String file) throws IOException
-    {
-        File f = new File(file);
-    	Runnable deleter = new Deleter(f);
-        deleter_.submit(deleter);
-    }
-
     public static boolean delete(List<String> files) throws IOException
     {
         boolean bVal = true;

Modified: incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyTest.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyTest.java?rev=894451&r1=894450&r2=894451&view=diff
==============================================================================
--- incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyTest.java (original)
+++ incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyTest.java Tue Dec 29 17:33:24 2009
@@ -26,7 +26,7 @@
 
 import org.junit.Test;
 
-import DataOutputBuffer;
+import org.apache.cassandra.io.util.DataOutputBuffer;
 import org.apache.cassandra.db.filter.QueryPath;
 import static org.apache.cassandra.Util.column;
 

Modified: incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/ReadMessageTest.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/ReadMessageTest.java?rev=894451&r1=894450&r2=894451&view=diff
==============================================================================
--- incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/ReadMessageTest.java (original)
+++ incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/ReadMessageTest.java Tue Dec 29 17:33:24 2009
@@ -30,6 +30,7 @@
 import org.junit.Test;
 
 import org.apache.cassandra.db.filter.QueryPath;
+import org.apache.cassandra.io.util.DataOutputBuffer;
 
 public class ReadMessageTest
 {

Modified: incubator/cassandra/trunk/test/unit/org/apache/cassandra/tools/SSTableExportTest.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/unit/org/apache/cassandra/tools/SSTableExportTest.java?rev=894451&r1=894450&r2=894451&view=diff
==============================================================================
--- incubator/cassandra/trunk/test/unit/org/apache/cassandra/tools/SSTableExportTest.java (original)
+++ incubator/cassandra/trunk/test/unit/org/apache/cassandra/tools/SSTableExportTest.java Tue Dec 29 17:33:24 2009
@@ -31,6 +31,7 @@
 import org.apache.cassandra.io.SSTableAccessor;
 import org.apache.cassandra.io.SSTableReader;
 import org.apache.cassandra.io.SSTableWriter;
+import org.apache.cassandra.io.util.DataOutputBuffer;
 import static org.apache.cassandra.Util.createTemporarySSTable;
 import static org.apache.cassandra.utils.FBUtilities.hexToBytes;
 import static org.junit.Assert.assertTrue;