浏览代码

HADOOP-2001. Make the job priority updates and job kills synchronized on the JobTracker. Deadlock was seen in the JobTracker because of the lack of this synchronization. Contributed by Arun C Murthy

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@583424 13f79535-47bb-0310-9956-ffa450edef68
Devaraj Das 18 年之前
父节点
当前提交
a7c75b4cf1
共有 3 个文件被更改,包括 26 次插入5 次删除
  1. 4 0
      CHANGES.txt
  2. 18 1
      src/java/org/apache/hadoop/mapred/JobTracker.java
  3. 4 4
      src/webapps/job/jobdetails.jsp

+ 4 - 0
CHANGES.txt

@@ -259,6 +259,10 @@ Trunk (unreleased changes)
     otherwise may lead to lost tasktrackers if the NameNode is unresponsive.
     (Devaraj Das via acmurthy)
 
+    HADOOP-2001.  Make the job priority updates and job kills synchronized on
+    the JobTracker. Deadlock was seen in the JobTracker because of the lack of
+    this synchronization.  (Arun C Murthy via ddas)
+
   IMPROVEMENTS
 
     HADOOP-1908. Restructure data node code so that block sending and 

+ 18 - 1
src/java/org/apache/hadoop/mapred/JobTracker.java

@@ -1545,7 +1545,7 @@ public class JobTracker implements MRConstants, InterTrackerProtocol, JobSubmiss
   /**
    * Sort jobs by priority and then by start time.
    */
-  public void resortPriority() {
+  private synchronized void resortPriority() {
     Comparator<JobInProgress> comp = new Comparator<JobInProgress>() {
       public int compare(JobInProgress o1, JobInProgress o2) {
         int res = o1.getPriority().compareTo(o2.getPriority());
@@ -1761,6 +1761,23 @@ public class JobTracker implements MRConstants, InterTrackerProtocol, JobSubmiss
     return jobs.get(jobid);
   }
 
+  /**
+   * Change the run-time priority of the given job.
+   * @param jobId job id
+   * @param priority new {@link JobPriority} for the job
+   */
+  synchronized void setJobPriority(String jobId, JobPriority priority) {
+    JobInProgress job = jobs.get(jobId);
+    if (job != null) {
+      job.setPriority(priority);
+      
+      // Re-sort jobs to reflect this change
+      resortPriority();
+    } else {
+      LOG.warn("Trying to change the priority of an unknown job: " + jobId);
+    }
+  }
+  
   ////////////////////////////////////////////////////
   // Methods to track all the TaskTrackers
   ////////////////////////////////////////////////////

+ 4 - 4
src/webapps/job/jobdetails.jsp

@@ -105,8 +105,8 @@
     
     String action = request.getParameter("action");
     if("changeprio".equalsIgnoreCase(action)) {
-	  job.setPriority(JobPriority.valueOf(request.getParameter("prio")));
-	  tracker.resortPriority();
+      tracker.setJobPriority(jobId, 
+                             JobPriority.valueOf(request.getParameter("prio")));
     }
     
     if(JspHelper.conf.getBoolean(PRIVATE_ACTIONS_KEY, false)) {
@@ -115,8 +115,8 @@
   	      printConfirm(out, jobId);
     	    return;
 	    }
-  	  else if(action != null && action.equalsIgnoreCase("kill")) {
-				job.kill();
+  	    else if(action != null && action.equalsIgnoreCase("kill")) {
+	      tracker.killJob(jobId);
 	    }
     }
 %>