hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bo...@apache.org
Subject svn commit: r1358312 - in /hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/src: main/java/org/apache/hadoop/fs/LocalDirAllocator.java test/java/org/apache/hadoop/fs/TestLocalDirAllocator.java
Date Fri, 06 Jul 2012 17:27:08 GMT
Author: bobby
Date: Fri Jul  6 17:27:07 2012
New Revision: 1358312

URL: http://svn.apache.org/viewvc?rev=1358312&view=rev
Log:
svn merge -c 1358305 FIXES: MAPREDUCE-4379. Node Manager throws java.lang.OutOfMemoryError:
Java heap space due to org.apache.hadoop.fs.LocalDirAllocator.contexts (Devaraj K via bobby)

Modified:
    hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/LocalDirAllocator.java
    hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalDirAllocator.java

Modified: hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/LocalDirAllocator.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/LocalDirAllocator.java?rev=1358312&r1=1358311&r2=1358312&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/LocalDirAllocator.java
(original)
+++ hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/LocalDirAllocator.java
Fri Jul  6 17:27:07 2012
@@ -207,6 +207,19 @@ public class LocalDirAllocator {
       return contexts.containsKey(contextCfgItemName);
     }
   }
+  
+  /**
+   * Removes the context from the context config items
+   * 
+   * @param contextCfgItemName
+   */
+  @Deprecated
+  @InterfaceAudience.LimitedPrivate({"MapReduce"})
+  public static void removeContext(String contextCfgItemName) {
+    synchronized (contexts) {
+      contexts.remove(contextCfgItemName);
+    }
+  }
     
   /** We search through all the configured dirs for the file's existence
    *  and return true when we find  

Modified: hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalDirAllocator.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalDirAllocator.java?rev=1358312&r1=1358311&r2=1358312&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalDirAllocator.java
(original)
+++ hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalDirAllocator.java
Fri Jul  6 17:27:07 2012
@@ -311,4 +311,43 @@ public class TestLocalDirAllocator {
       rmBufferDirs();
     }
   }
+
+  /**
+   * Test getLocalPathToRead() returns correct filename and "file" schema.
+   *
+   * @throws IOException
+   */
+  @Test
+  public void testGetLocalPathToRead() throws IOException {
+    if (isWindows)
+      return;
+    String dir = buildBufferDir(ROOT, 0);
+    try {
+      conf.set(CONTEXT, dir);
+      assertTrue(localFs.mkdirs(new Path(dir)));
+      File f1 = dirAllocator.createTmpFileForWrite(FILENAME, SMALL_FILE_SIZE,
+          conf);
+      Path p1 = dirAllocator.getLocalPathToRead(f1.getName(), conf);
+      assertEquals(f1.getName(), p1.getName());
+      assertEquals("file", p1.getFileSystem(conf).getUri().getScheme());
+    } finally {
+      Shell.execCommand(new String[] { "chmod", "u+w", BUFFER_DIR_ROOT });
+      rmBufferDirs();
+    }
+
+  }
+  
+  @Test
+  public void testRemoveContext() throws IOException {
+    String dir = buildBufferDir(ROOT, 0);
+    String contextCfgItemName = "application_1340842292563_0004.app.cache.dirs";
+    conf.set(contextCfgItemName, dir);
+    LocalDirAllocator localDirAllocator = new LocalDirAllocator(
+        contextCfgItemName);
+    localDirAllocator.getLocalPathForWrite("p1/x", SMALL_FILE_SIZE, conf);
+    assertTrue(LocalDirAllocator.isContextValid(contextCfgItemName));
+    LocalDirAllocator.removeContext(contextCfgItemName);
+    assertFalse(LocalDirAllocator.isContextValid(contextCfgItemName));
+  }
+
 }



Mime
View raw message