Sfoglia il codice sorgente

Merge -r 754846:754847 from trunk onto 0.20 branch. Fixes HADOOP-5490.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/branches/branch-0.20@754850 13f79535-47bb-0310-9956-ffa450edef68
Devaraj Das 16 anni fa
parent
commit
9baa390f65

+ 3 - 0
CHANGES.txt

@@ -722,6 +722,9 @@ Release 0.20.0 - Unreleased
     HADOOP-5278. Fixes a problem to do with logging the finish time of a task 
     during recovery (after a JobTracker restart). (Amar Kamat via ddas)
 
+    HADOOP-5490. Fixes a synchronization problem in the EagerTaskInitializationListener
+    class. (Jothi Padmanabhan via ddas)
+
 Release 0.19.2 - Unreleased
 
   BUG FIXES

+ 3 - 10
src/mapred/org/apache/hadoop/mapred/EagerTaskInitializationListener.java

@@ -51,14 +51,11 @@ class EagerTaskInitializationListener extends JobInProgressListener {
       while (true) {
         try {
           synchronized (jobInitQueue) {
-            while (jobInitQueue.isEmpty() && !exitFlag) {
+            while (jobInitQueue.isEmpty()) {
               jobInitQueue.wait();
             }
-            if (exitFlag) {
-              break;
-            }
+            job = jobInitQueue.remove(0);
           }
-          job = jobInitQueue.remove(0);
           threadPool.execute(new InitJob(job));
         } catch (InterruptedException t) {
           LOG.info("JobInitManagerThread interrupted.");
@@ -97,7 +94,6 @@ class EagerTaskInitializationListener extends JobInProgressListener {
   private List<JobInProgress> jobInitQueue = new ArrayList<JobInProgress>();
   private ExecutorService threadPool;
   private int numThreads;
-  private boolean exitFlag = false;
   
   public EagerTaskInitializationListener(Configuration conf) {
     numThreads = conf.getInt("mapred.jobinit.threads", DEFAULT_NUM_THREADS);
@@ -113,10 +109,7 @@ class EagerTaskInitializationListener extends JobInProgressListener {
   public void terminate() throws IOException {
     if (jobInitManagerThread != null && jobInitManagerThread.isAlive()) {
       LOG.info("Stopping Job Init Manager thread");
-      synchronized (jobInitQueue) {
-        exitFlag = true;
-        jobInitQueue.notify();
-      }
+      jobInitManagerThread.interrupt();
       try {
         jobInitManagerThread.join();
       } catch (InterruptedException ex) {