Browse Source

Fix bug HADOOP-16.

  Don't invoke TaskInProgress.hasTaskWithCacheHit() 
unnecessarily from within JobInProgress.

  Also, cache filesystem hints inside JobInProgress.



git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@377801 13f79535-47bb-0310-9956-ffa450edef68
Michael John Cafarella 19 years ago
parent
commit
5f7ab15543

+ 2 - 0
src/java/org/apache/hadoop/mapred/JobInProgress.java

@@ -275,10 +275,12 @@ class JobInProgress {
             if (maps[i].hasTaskWithCacheHit(taskTracker, tts)) {
             if (maps[i].hasTaskWithCacheHit(taskTracker, tts)) {
                 if (cacheTarget < 0) {
                 if (cacheTarget < 0) {
                     cacheTarget = i;
                     cacheTarget = i;
+                    break;
                 }
                 }
             } else if (maps[i].hasTask()) {
             } else if (maps[i].hasTask()) {
                 if (stdTarget < 0) {
                 if (stdTarget < 0) {
                     stdTarget = i;
                     stdTarget = i;
+                    break;
                 }
                 }
             }
             }
             totalProgress += maps[i].getProgress();
             totalProgress += maps[i].getProgress();

+ 11 - 6
src/java/org/apache/hadoop/mapred/TaskInProgress.java

@@ -49,6 +49,7 @@ class TaskInProgress {
     // Defines the TIP
     // Defines the TIP
     String jobFile = null;
     String jobFile = null;
     FileSplit split = null;
     FileSplit split = null;
+    String hints[][] = null;
     TaskInProgress predecessors[] = null;
     TaskInProgress predecessors[] = null;
     int partition;
     int partition;
     JobTracker jobtracker;
     JobTracker jobtracker;
@@ -360,12 +361,16 @@ class TaskInProgress {
         } else {
         } else {
             try {
             try {
                 if (isMapTask()) {
                 if (isMapTask()) {
-                    FileSystem fs = FileSystem.get(conf);
-                    String hints[][] = fs.getFileCacheHints(split.getFile(), split.getStart(), split.getLength());
-                    for (int i = 0; i < hints.length; i++) {
-                        for (int j = 0; j < hints[i].length; j++) {
-                            if (hints[i][j].equals(tts.getHost())) {
-                                return true;
+                    if (hints == null) {
+                        FileSystem fs = FileSystem.get(conf);
+                        hints = fs.getFileCacheHints(split.getFile(), split.getStart(), split.getLength());
+                    }
+                    if (hints != null) {
+                        for (int i = 0; i < hints.length; i++) {
+                            for (int j = 0; j < hints[i].length; j++) {
+                                if (hints[i][j].equals(tts.getHost())) {
+                                    return true;
+                                }
                             }
                             }
                         }
                         }
                     }
                     }