hadoop-mapreduce-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sc...@apache.org
Subject svn commit: r1066929 - in /hadoop/mapreduce/trunk: CHANGES.txt src/java/org/apache/hadoop/mapred/JobInProgress.java src/java/org/apache/hadoop/mapred/JobTracker.java src/java/org/apache/hadoop/mapred/TaskInProgress.java
Date Thu, 03 Feb 2011 19:57:49 GMT
Author: schen
Date: Thu Feb  3 19:57:48 2011
New Revision: 1066929

URL: http://svn.apache.org/viewvc?rev=1066929&view=rev
Log:
MAPREDUCE-2026. Make JobTracker.getJobCounters() and
JobInProgress.getCounters() aquire locks in a shorter time period.
(Joydeep Sen Sarma via schen)

Modified:
    hadoop/mapreduce/trunk/CHANGES.txt
    hadoop/mapreduce/trunk/src/java/org/apache/hadoop/mapred/JobInProgress.java
    hadoop/mapreduce/trunk/src/java/org/apache/hadoop/mapred/JobTracker.java
    hadoop/mapreduce/trunk/src/java/org/apache/hadoop/mapred/TaskInProgress.java

Modified: hadoop/mapreduce/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/trunk/CHANGES.txt?rev=1066929&r1=1066928&r2=1066929&view=diff
==============================================================================
--- hadoop/mapreduce/trunk/CHANGES.txt (original)
+++ hadoop/mapreduce/trunk/CHANGES.txt Thu Feb  3 19:57:48 2011
@@ -28,6 +28,10 @@ Trunk (unreleased changes)
     (hairong)
 
   OPTIMIZATIONS
+    
+    MAPREDUCE-2026. Make JobTracker.getJobCounters() and
+    JobInProgress.getCounters() aquire locks in a shorter time period.
+    (Joydeep Sen Sarma via schen)
 
   BUG FIXES
 

Modified: hadoop/mapreduce/trunk/src/java/org/apache/hadoop/mapred/JobInProgress.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/trunk/src/java/org/apache/hadoop/mapred/JobInProgress.java?rev=1066929&r1=1066928&r2=1066929&view=diff
==============================================================================
--- hadoop/mapreduce/trunk/src/java/org/apache/hadoop/mapred/JobInProgress.java (original)
+++ hadoop/mapreduce/trunk/src/java/org/apache/hadoop/mapred/JobInProgress.java Thu Feb  3
19:57:48 2011
@@ -1253,9 +1253,14 @@ public class JobInProgress {
    *  Returns the total job counters, by adding together the job, 
    *  the map and the reduce counters.
    */
-  public synchronized Counters getCounters() {
+  public Counters getCounters() {
     Counters result = new Counters();
-    result.incrAllCounters(getJobCounters());
+    synchronized (this) {
+      result.incrAllCounters(getJobCounters());
+    }
+
+    // the counters of TIPs are not updated in place.
+    // hence read-only access is ok without any locks
     incrementTaskCounters(result, maps);
     return incrementTaskCounters(result, reduces);
   }

Modified: hadoop/mapreduce/trunk/src/java/org/apache/hadoop/mapred/JobTracker.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/trunk/src/java/org/apache/hadoop/mapred/JobTracker.java?rev=1066929&r1=1066928&r2=1066929&view=diff
==============================================================================
--- hadoop/mapreduce/trunk/src/java/org/apache/hadoop/mapred/JobTracker.java (original)
+++ hadoop/mapreduce/trunk/src/java/org/apache/hadoop/mapred/JobTracker.java Thu Feb  3 19:57:48
2011
@@ -3538,26 +3538,27 @@ public class JobTracker implements MRCon
       throws AccessControlException, IOException {
 
     JobID oldJobID = JobID.downgrade(jobid);
-
+    JobInProgress job;
     synchronized (this) {
-      JobInProgress job = jobs.get(oldJobID);
-      if (job != null) {
-	// check the job-access
-        aclsManager.checkAccess(job, UserGroupInformation.getCurrentUser(),
-            Operation.VIEW_JOB_COUNTERS);
-
-        if (!isJobInited(job)) {
-	  return EMPTY_COUNTERS;
-	}
-
-        Counters counters = job.getCounters();
-        if (counters != null) {
-          return new org.apache.hadoop.mapreduce.Counters(counters);
-        }
-        return null;
-      } 
+      job = jobs.get(oldJobID);
     }
 
+    if (job != null) {
+      // check the job-access
+      aclsManager.checkAccess(job, UserGroupInformation.getCurrentUser(),
+                              Operation.VIEW_JOB_COUNTERS);
+
+      if (!isJobInited(job)) {
+        return EMPTY_COUNTERS;
+      }
+
+      Counters counters = job.getCounters();
+      if (counters != null) {
+        return new org.apache.hadoop.mapreduce.Counters(counters);
+      }
+      return null;
+    } 
+
     Counters counters = completedJobStatusStore.readCounters(oldJobID);
     if (counters != null) {
       return new org.apache.hadoop.mapreduce.Counters(counters);

Modified: hadoop/mapreduce/trunk/src/java/org/apache/hadoop/mapred/TaskInProgress.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/trunk/src/java/org/apache/hadoop/mapred/TaskInProgress.java?rev=1066929&r1=1066928&r2=1066929&view=diff
==============================================================================
--- hadoop/mapreduce/trunk/src/java/org/apache/hadoop/mapred/TaskInProgress.java (original)
+++ hadoop/mapreduce/trunk/src/java/org/apache/hadoop/mapred/TaskInProgress.java Thu Feb 
3 19:57:48 2011
@@ -129,7 +129,7 @@ class TaskInProgress {
   //task to commit, <taskattemptid>  
   private TaskAttemptID taskToCommit;
   
-  private Counters counters = new Counters();
+  private volatile Counters counters = new Counters();
   
   private HashMap<TaskAttemptID, Long> dispatchTimeMap = 
     new HashMap<TaskAttemptID, Long>();



Mime
View raw message