Browse Source

MAPREDUCE-4278. Cannot run two local jobs in parallel from the same gateway. Contributed by Sandy Ryza.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-1@1430371 13f79535-47bb-0310-9956-ffa450edef68
Thomas White 12 years ago
parent
commit
128c502d3c
2 changed files with 11 additions and 3 deletions
  1. 3 0
      CHANGES.txt
  2. 8 3
      src/mapred/org/apache/hadoop/mapred/LocalJobRunner.java

+ 3 - 0
CHANGES.txt

@@ -407,6 +407,9 @@ Release 1.2.0 - unreleased
     HDFS-4351.  In BlockPlacementPolicyDefault.chooseTarget(..), numOfReplicas
     needs to be updated when avoiding stale nodes.  (Andrew Wang via szetszwo)
 
+    MAPREDUCE-4278. Cannot run two local jobs in parallel from the same
+    gateway. (Sandy Ryza via tomwhite)
+
 Release 1.1.2 - Unreleased
 
   INCOMPATIBLE CHANGES

+ 8 - 3
src/mapred/org/apache/hadoop/mapred/LocalJobRunner.java

@@ -427,8 +427,12 @@ class LocalJobRunner implements JobSubmissionProtocol {
   // JobSubmissionProtocol methods
 
   private static int jobid = 0;
+  // used for making sure that local jobs run in different jvms don't
+  // collide on staging or job directories
+  private int randid;
+
   public synchronized JobID getNewJobId() {
-    return new JobID("local", ++jobid);
+    return new JobID("local" + randid, ++jobid);
   }
 
   public JobStatus submitJob(JobID jobid, String jobSubmitDir, 
@@ -541,10 +545,11 @@ class LocalJobRunner implements JobSubmissionProtocol {
         "/tmp/hadoop/mapred/staging"));
     UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
     String user;
+    randid = rand.nextInt(Integer.MAX_VALUE);
     if (ugi != null) {
-      user = ugi.getShortUserName() + rand.nextInt();
+      user = ugi.getShortUserName() + randid;
     } else {
-      user = "dummy" + rand.nextInt();
+      user = "dummy" + randid;
     }
     return fs.makeQualified(new Path(stagingRootDir, user+"/.staging")).toString();
   }