浏览代码

HADOOP-1179. Merge -r 525499:525500 from trunk to 0.12 branch.

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/branches/branch-0.12@525774 13f79535-47bb-0310-9956-ffa450edef68
Thomas White 18 年之前
父节点
当前提交
dc4ca5b3aa
共有 2 个文件被更改,包括 31 次插入25 次删除
  1. 4 0
      CHANGES.txt
  2. 27 25
      src/java/org/apache/hadoop/mapred/TaskTracker.java

+ 4 - 0
CHANGES.txt

@@ -26,6 +26,10 @@ Release 0.12.3 (not yet released)
  7. HADOOP-1105. Fix reducers to make "progress" while iterating 
     through values.  (Devaraj Das & Owen O'Malley via tomwhite)
 
+ 8. HADOOP-1179. Make Task Tracker close index file as soon as the read 
+    is done when serving get-map-output requests.  
+    (Devaraj Das via tomwhite)
+
 
 Release 0.12.2 - 2007-23-17
 

+ 27 - 25
src/java/org/apache/hadoop/mapred/TaskTracker.java

@@ -1643,6 +1643,9 @@ public class TaskTracker
           long startOffset = indexIn.readLong();
           long partLength = indexIn.readLong();
 
+          indexIn.close();
+          indexIn = null;
+          
           //set the content-length header
           response.setContentLength((int) partLength);
 
@@ -1654,31 +1657,23 @@ public class TaskTracker
           mapOutputIn = fileSys.open(mapOutputFileName);
           //seek to the correct offset for the reduce
           mapOutputIn.seek(startOffset);
-          try {
-            int totalRead = 0;
-            int len = mapOutputIn.read(buffer, 0,
-                                 partLength < MAX_BYTES_TO_READ 
-                                 ? (int)partLength : MAX_BYTES_TO_READ);
-            while (len > 0) {
-              try {
-                outStream.write(buffer, 0, len);
-              } catch (IOException ie) {
-                isInputException = false;
-                throw ie;
-              }
-              totalRead += len;
-              if (totalRead == partLength) break;
-              len = mapOutputIn.read(buffer, 0, 
-                      (partLength - totalRead) < MAX_BYTES_TO_READ
-                       ? (int)(partLength - totalRead) : MAX_BYTES_TO_READ);
-            }
-          } finally {
-            if (indexIn != null) {
-              indexIn.close();
-            }
-            if (mapOutputIn != null) {
-              mapOutputIn.close();
+          
+          int totalRead = 0;
+          int len = mapOutputIn.read(buffer, 0,
+                               partLength < MAX_BYTES_TO_READ 
+                               ? (int)partLength : MAX_BYTES_TO_READ);
+          while (len > 0) {
+            try {
+              outStream.write(buffer, 0, len);
+            } catch (IOException ie) {
+              isInputException = false;
+              throw ie;
             }
+            totalRead += len;
+            if (totalRead == partLength) break;
+            len = mapOutputIn.read(buffer, 0, 
+                    (partLength - totalRead) < MAX_BYTES_TO_READ
+                     ? (int)(partLength - totalRead) : MAX_BYTES_TO_READ);
           }
         } catch (IOException ie) {
           TaskTracker tracker = 
@@ -1693,7 +1688,14 @@ public class TaskTracker
           }
           response.sendError(HttpServletResponse.SC_GONE, errorMsg);
           throw ie;
-        } 
+        } finally {
+          if (indexIn != null) {
+            indexIn.close();
+          }
+          if (mapOutputIn != null) {
+            mapOutputIn.close();
+          }
+        }
         outStream.close();
       }
     }