浏览代码

commit d132bb2588a66359a0b09554ac5a7a3b2e4aad45
Author: Arun C Murthy <acmurthy@apache.org>
Date: Fri Jul 2 16:34:35 2010 -0700

MAPREDUCE-1538. Add a limit on the number of artifacts in the DistributedCache to ensure we cleanup aggressively. Contributed by Dick King.

+++ b/YAHOO-CHANGES.txt
+ MAPREDUCE-1538. Add a limit on the number of artifacts in the
+ DistributedCache to ensure we cleanup aggressively. (Dick King via
+ acmurthy)
+


git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.20-security-patches@1077566 13f79535-47bb-0310-9956-ffa450edef68

Owen O'Malley 14 年之前
父节点
当前提交
5584a455df

+ 2 - 13
src/mapred/org/apache/hadoop/filecache/TrackerDistributedCacheManager.java

@@ -276,21 +276,10 @@ public class TrackerDistributedCacheManager {
     // do the deletion, after releasing the global lock
     for (CacheStatus lcacheStatus : deleteList) {
       synchronized (lcacheStatus) {
-        FileSystem localFS = FileSystem.getLocal(conf);
-
-        Path potentialDeletee = lcacheStatus.localizedLoadPath;
-
-        localFS.delete(potentialDeletee, true);
+        FileSystem.getLocal(conf).delete(lcacheStatus.localizedLoadPath, true);
 
         // Update the maps baseDirSize and baseDirNumberSubDir
-        LOG.info("Deleted path " + potentialDeletee);
-
-        try {
-          localFS.delete(lcacheStatus.getLocalizedUniqueDir(), true);
-        } catch (IOException e) {
-          LOG.warn("Could not delete distributed cache empty directory "
-                   + lcacheStatus.getLocalizedUniqueDir());
-        }
+        LOG.info("Deleted path " + lcacheStatus.localizedLoadPath);
 
         deleteCacheInfoUpdate(lcacheStatus);
       }

+ 2 - 2
src/test/org/apache/hadoop/filecache/TestTrackerDistributedCacheManager.java

@@ -66,6 +66,7 @@ public class TestTrackerDistributedCacheManager extends TestCase {
   private static final int TEST_FILE_SIZE = 4 * 1024; // 4K
   private static final int LOCAL_CACHE_LIMIT = 5 * 1024; //5K
   private static final int LOCAL_CACHE_SUBDIR_LIMIT = 2;
+  private static final int LOCAL_CACHE_SUBDIR = 2;
   protected Configuration conf;
   protected Path firstCacheFile;
   protected Path secondCacheFile;
@@ -491,7 +492,7 @@ public class TestTrackerDistributedCacheManager extends TestCase {
     conf2.set("user.name", userName);
 
     // We first test the size limit
-    Path firstLocalCache = manager.getLocalCache(firstCacheFile.toUri(), conf2, 
+    Path localCache = manager.getLocalCache(firstCacheFile.toUri(), conf2, 
         TaskTracker.getPrivateDistributedCacheDir(userName),
         fs.getFileStatus(firstCacheFile), false,
         now, new Path(TEST_ROOT_DIR), false, false);
@@ -535,7 +536,6 @@ public class TestTrackerDistributedCacheManager extends TestCase {
            + "because they collectively exceeded the size limit.",
        localfs.listStatus(cachesBase).length > 1);
     
-    
     // Now we test the number of sub directories limit
     // Create the temporary cache files to be used in the tests.
     Path thirdCacheFile = new Path(TEST_ROOT_DIR, "thirdcachefile");