accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r1430474 - in /accumulo/trunk/server/src: main/java/org/apache/accumulo/server/gc/SimpleGarbageCollector.java test/java/org/apache/accumulo/server/gc/TestConfirmDeletes.java
Date Tue, 08 Jan 2013 20:02:06 GMT
Author: ecn
Date: Tue Jan  8 20:02:05 2013
New Revision: 1430474

URL: http://svn.apache.org/viewvc?rev=1430474&view=rev
Log:
ACCUMULO-919 provide an option to just skip using the trash to delete files

Modified:
    accumulo/trunk/server/src/main/java/org/apache/accumulo/server/gc/SimpleGarbageCollector.java
    accumulo/trunk/server/src/test/java/org/apache/accumulo/server/gc/TestConfirmDeletes.java

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=1430474&r1=1430473&r2=1430474&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
Tue Jan  8 20:02:05 2013
@@ -110,6 +110,8 @@ public class SimpleGarbageCollector impl
     boolean offline = false;
     @Parameter(names={"-a", "--address"}, description="specify our local address")
     String address = null;
+    @Parameter(names={"--no-trash"}, description="do not use the Trash, even if it is configured")
+    boolean noTrash = false;
   }
 
   // how much of the JVM's available memory should it use gathering candidates
@@ -122,7 +124,7 @@ public class SimpleGarbageCollector impl
   private long gcStartDelay;
   private boolean checkForBulkProcessingFiles;
   private FileSystem fs;
-  private Trash trash;
+  private Trash trash = null;
   private boolean safemode = false, offline = false, verbose = false;
   private String address = "localhost";
   private ZooLock lock;
@@ -155,7 +157,7 @@ public class SimpleGarbageCollector impl
     if (opts.address != null)
       gc.useAddress(address);
     
-    gc.init(fs, instance, SecurityConstants.getSystemCredentials());
+    gc.init(fs, instance, SecurityConstants.getSystemCredentials(), opts.noTrash);
     Accumulo.enableTracing(address, "gc");
     gc.run();
   }
@@ -178,9 +180,8 @@ public class SimpleGarbageCollector impl
     this.address = address;
   }
 
-  public void init(FileSystem fs, Instance instance, AuthInfo credentials) throws IOException
{
+  public void init(FileSystem fs, Instance instance, AuthInfo credentials, boolean noTrash)
throws IOException {
     this.fs = TraceFileSystem.wrap(fs);
-    this.trash = new Trash(fs, fs.getConf());
     this.credentials = credentials;
     this.instance = instance;
     
@@ -194,8 +195,11 @@ public class SimpleGarbageCollector impl
     log.info("verbose: " + verbose);
     log.info("memory threshold: " + CANDIDATE_MEMORY_PERCENTAGE + " of " + Runtime.getRuntime().maxMemory()
+ " bytes");
     log.info("delete threads: " + numDeleteThreads);
-    log.info("Starting trash emptier");
-    new Daemon(new LoggingRunnable(log, trash.getEmptier()), "Trash Emptier").start();
+    if (!noTrash) {
+      this.trash = new Trash(fs, fs.getConf());
+      log.info("Starting trash emptier");
+      new Daemon(new LoggingRunnable(log, trash.getEmptier()), "Trash Emptier").start();
+    }
   }
   
   private void run() {
@@ -597,7 +601,7 @@ public class SimpleGarbageCollector impl
             
             Path p = new Path(ServerConstants.getTablesDir() + delete);
             
-            if (trash.moveToTrash(p) || fs.delete(p, true)) {
+            if ((trash != null && trash.moveToTrash(p)) || fs.delete(p, true)) {
               // delete succeeded, still want to delete
               removeFlag = true;
               synchronized (SimpleGarbageCollector.this) {

Modified: accumulo/trunk/server/src/test/java/org/apache/accumulo/server/gc/TestConfirmDeletes.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/server/src/test/java/org/apache/accumulo/server/gc/TestConfirmDeletes.java?rev=1430474&r1=1430473&r2=1430474&view=diff
==============================================================================
--- accumulo/trunk/server/src/test/java/org/apache/accumulo/server/gc/TestConfirmDeletes.java
(original)
+++ accumulo/trunk/server/src/test/java/org/apache/accumulo/server/gc/TestConfirmDeletes.java
Tue Jan  8 20:02:05 2013
@@ -99,7 +99,7 @@ public class TestConfirmDeletes {
     load(instance, metadata, deletes);
 
     SimpleGarbageCollector gc = new SimpleGarbageCollector();
-    gc.init(fs, instance, auth);
+    gc.init(fs, instance, auth, false);
     SortedSet<String> candidates = gc.getCandidates();
     Assert.assertEquals(expectedInitial, candidates.size());
     gc.confirmDeletes(candidates);



Mime
View raw message