accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r1446314 - in /accumulo/trunk/server/src/main/java/org/apache/accumulo/server: gc/GarbageCollectWriteAheadLogs.java gc/SimpleGarbageCollector.java tabletserver/Tablet.java tabletserver/TabletServer.java
Date Thu, 14 Feb 2013 20:11:42 GMT
Author: ecn
Date: Thu Feb 14 20:11:42 2013
New Revision: 1446314

URL: http://svn.apache.org/r1446314
Log:
ACCUMULO-919 use the trash to cleanup root tablet files, recovery files, and WAL

Modified:
    accumulo/trunk/server/src/main/java/org/apache/accumulo/server/gc/GarbageCollectWriteAheadLogs.java
    accumulo/trunk/server/src/main/java/org/apache/accumulo/server/gc/SimpleGarbageCollector.java
    accumulo/trunk/server/src/main/java/org/apache/accumulo/server/tabletserver/Tablet.java
    accumulo/trunk/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletServer.java

Modified: accumulo/trunk/server/src/main/java/org/apache/accumulo/server/gc/GarbageCollectWriteAheadLogs.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/server/src/main/java/org/apache/accumulo/server/gc/GarbageCollectWriteAheadLogs.java?rev=1446314&r1=1446313&r2=1446314&view=diff
==============================================================================
--- accumulo/trunk/server/src/main/java/org/apache/accumulo/server/gc/GarbageCollectWriteAheadLogs.java
(original)
+++ accumulo/trunk/server/src/main/java/org/apache/accumulo/server/gc/GarbageCollectWriteAheadLogs.java
Thu Feb 14 20:11:42 2013
@@ -47,6 +47,7 @@ import org.apache.accumulo.trace.instrum
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.Trash;
 import org.apache.log4j.Logger;
 import org.apache.thrift.TException;
 import org.apache.zookeeper.KeeperException;
@@ -57,10 +58,14 @@ public class GarbageCollectWriteAheadLog
   
   private final Instance instance;
   private final FileSystem fs;
+
+  private Trash trash;
   
-  GarbageCollectWriteAheadLogs(Instance instance, FileSystem fs) {
+  GarbageCollectWriteAheadLogs(Instance instance, FileSystem fs, boolean noTrash) throws
IOException {
     this.instance = instance;
     this.fs = fs;
+    if (!noTrash)
+      this.trash = new Trash(fs, fs.getConf());
   }
 
   public void collect(GCStatus status) {
@@ -129,7 +134,9 @@ public class GarbageCollectWriteAheadLog
         for (String filename : entry.getValue()) {
           log.debug("Removing old-style WAL " + entry.getValue());
           try {
-            fs.delete(new Path(Constants.getWalDirectory(conf), filename), true);
+            Path path = new Path(Constants.getWalDirectory(conf), filename);
+            if (trash == null || !trash.moveToTrash(path))
+              fs.delete(path, true);
           } catch (IOException ex) {
             log.error("Unable to delete wal " + filename + ": " + ex);
           }

Modified: accumulo/trunk/server/src/main/java/org/apache/accumulo/server/gc/SimpleGarbageCollector.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/server/src/main/java/org/apache/accumulo/server/gc/SimpleGarbageCollector.java?rev=1446314&r1=1446313&r2=1446314&view=diff
==============================================================================
--- accumulo/trunk/server/src/main/java/org/apache/accumulo/server/gc/SimpleGarbageCollector.java
(original)
+++ accumulo/trunk/server/src/main/java/org/apache/accumulo/server/gc/SimpleGarbageCollector.java
Thu Feb 14 20:11:42 2013
@@ -296,8 +296,8 @@ public class SimpleGarbageCollector impl
       
       // Clean up any unused write-ahead logs
       Span waLogs = Trace.start("walogs");
-      GarbageCollectWriteAheadLogs walogCollector = new GarbageCollectWriteAheadLogs(instance,
fs);
       try {
+        GarbageCollectWriteAheadLogs walogCollector = new GarbageCollectWriteAheadLogs(instance,
fs, trash == null);
         log.info("Beginning garbage collection of write-ahead logs");
         walogCollector.collect(status);
       } catch (Exception e) {

Modified: accumulo/trunk/server/src/main/java/org/apache/accumulo/server/tabletserver/Tablet.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/server/src/main/java/org/apache/accumulo/server/tabletserver/Tablet.java?rev=1446314&r1=1446313&r2=1446314&view=diff
==============================================================================
--- accumulo/trunk/server/src/main/java/org/apache/accumulo/server/tabletserver/Tablet.java
(original)
+++ accumulo/trunk/server/src/main/java/org/apache/accumulo/server/tabletserver/Tablet.java
Thu Feb 14 20:11:42 2013
@@ -132,6 +132,7 @@ import org.apache.hadoop.conf.Configurat
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.Trash;
 import org.apache.hadoop.io.Text;
 import org.apache.log4j.Logger;
 import org.apache.zookeeper.KeeperException;
@@ -1037,8 +1038,11 @@ public class Tablet {
           
           // start deleting files, if we do not finish they will be cleaned
           // up later
+          Trash trash = new Trash(fs, fs.getConf());
           for (Path path : oldDatafiles) {
-            fs.delete(new Path(location + "/delete+" + compactName + "+" + path.getName()),
true);
+            Path deleteFile = new Path(location + "/delete+" + compactName + "+" + path.getName());
+            if (!trash.moveToTrash(deleteFile))
+              fs.delete(deleteFile, true);
           }
         }
         

Modified: accumulo/trunk/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletServer.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletServer.java?rev=1446314&r1=1446313&r2=1446314&view=diff
==============================================================================
--- accumulo/trunk/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletServer.java
(original)
+++ accumulo/trunk/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletServer.java
Thu Feb 14 20:11:42 2013
@@ -207,6 +207,7 @@ import org.apache.hadoop.fs.FSDataOutput
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.Trash;
 import org.apache.hadoop.hdfs.DistributedFileSystem;
 import org.apache.hadoop.io.SequenceFile;
 import org.apache.hadoop.io.SequenceFile.Reader;
@@ -2090,9 +2091,12 @@ public class TabletServer extends Abstra
               log.error("rename is unsuccessful");
           } else {
             log.info("Deleting walog " + filename);
-            if (!fs.delete(new Path(source), true))
+            Trash trash = new Trash(fs, fs.getConf());
+            Path sourcePath = new Path(source);
+            if (!trash.moveToTrash(sourcePath) && !fs.delete(sourcePath, true))
               log.warn("Failed to delete walog " + source);
-            if (fs.delete(new Path(Constants.getRecoveryDir(acuConf), filename), true))
+            Path recoveryPath = new Path(Constants.getRecoveryDir(acuConf), filename); 
+            if (trash.moveToTrash(recoveryPath) || fs.delete(recoveryPath, true))
               log.info("Deleted any recovery log " + filename);
             
           }



Mime
View raw message