Make cleaner cache persistent across runs
authorMichael Vrable <vrable@cs.hmc.edu>
Mon, 19 Sep 2011 06:09:44 +0000 (23:09 -0700)
committerMichael Vrable <vrable@cs.hmc.edu>
Mon, 19 Sep 2011 06:09:44 +0000 (23:09 -0700)
cleaner/cleaner

index 93feef4..60c91f5 100755 (executable)
@@ -96,6 +96,9 @@ class S3Backend(Backend):
         self.path = path
         self.cachedir = cachedir
         self.cache = {}
+        for f in os.listdir(cachedir):
+            self.cache[f] = True
+        print "Initial cache contents:", list(self.cache.keys())
         self.connect()
         self.stats_get = [0, 0]
         self.stats_put = [0, 0]
@@ -466,7 +469,7 @@ class InodeMap:
             print "%s: %s %s" % (s, u, float(u[1]) / u[0])
             if u[1] == 0:
                 print "Would delete..."
-                #backend.delete(s)
+                backend.delete(s)
                 deletions[0] += 1
                 deletions[1] += u[0]
 
@@ -586,7 +589,7 @@ def run_cleaner(backend, inode_map, log, repack_inodes=False):
 
 if __name__ == '__main__':
     start_time = time.time()
-    backend = S3Backend("mvrable-bluesky-west", cachedir="/export/cache")
+    backend = S3Backend("mvrable-bluesky-west", cachedir="/tmp/bluesky-cache")
     #backend = FileBackend(".")
     chkpt = load_checkpoint_record(backend)
     print backend.list()