hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject svn commit: r1442404 - in /hadoop/common/branches/branch-1: CHANGES.txt src/mapred/org/apache/hadoop/mapred/JobLocalizer.java src/test/org/apache/hadoop/mapred/TestJobLocalizer.java
Date Mon, 04 Feb 2013 22:26:35 GMT
Author: tucu
Date: Mon Feb  4 22:26:34 2013
New Revision: 1442404

URL: http://svn.apache.org/viewvc?rev=1442404&view=rev
Log:
MAPREDUCE-4843. When using DefaultTaskController, JobLocalizer not thread safe. (kkambatl
via tucu)

Added:
    hadoop/common/branches/branch-1/src/test/org/apache/hadoop/mapred/TestJobLocalizer.java
Modified:
    hadoop/common/branches/branch-1/CHANGES.txt
    hadoop/common/branches/branch-1/src/mapred/org/apache/hadoop/mapred/JobLocalizer.java

Modified: hadoop/common/branches/branch-1/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1/CHANGES.txt?rev=1442404&r1=1442403&r2=1442404&view=diff
==============================================================================
--- hadoop/common/branches/branch-1/CHANGES.txt (original)
+++ hadoop/common/branches/branch-1/CHANGES.txt Mon Feb  4 22:26:34 2013
@@ -468,6 +468,9 @@ Release 1.2.0 - unreleased
     MAPREDUCE-4969. TestKeyValueTextInputFormat test fails with Open JDK 7.
     (Arpit Agarwal via suresh)
 
+    MAPREDUCE-4843. When using DefaultTaskController, JobLocalizer not thread 
+    safe. (kkambatl via tucu)
+
 Release 1.1.2 - Unreleased
 
   INCOMPATIBLE CHANGES

Modified: hadoop/common/branches/branch-1/src/mapred/org/apache/hadoop/mapred/JobLocalizer.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1/src/mapred/org/apache/hadoop/mapred/JobLocalizer.java?rev=1442404&r1=1442403&r2=1442404&view=diff
==============================================================================
--- hadoop/common/branches/branch-1/src/mapred/org/apache/hadoop/mapred/JobLocalizer.java
(original)
+++ hadoop/common/branches/branch-1/src/mapred/org/apache/hadoop/mapred/JobLocalizer.java
Mon Feb  4 22:26:34 2013
@@ -82,7 +82,7 @@ public class JobLocalizer {
   private final FileSystem lfs;
   private final List<Path> localDirs;
   private final LocalDirAllocator lDirAlloc;
-  private final JobConf ttConf;
+  protected final JobConf ttConf;
 
   private final String JOBDIR;
   private final String DISTDIR;
@@ -90,7 +90,7 @@ public class JobLocalizer {
   private final String JARDST;
   private final String JOBCONF;
   private final String JOBTOKEN;
-  private static final String JOB_LOCAL_CTXT = "mapred.job.local.dir";
+  protected static final String JOB_LOCAL_CTXT = "mapred.job.local.dir";
 
   public JobLocalizer(JobConf ttConf, String user, String jobid)
       throws IOException {
@@ -108,10 +108,10 @@ public class JobLocalizer {
       throw new IOException("Cannot initialize for null jobid");
     }
     this.jobid = jobid;
-    this.ttConf = ttConf;
-    lfs = FileSystem.getLocal(ttConf).getRaw();
+    this.ttConf = new JobConf(ttConf);
+    lfs = FileSystem.getLocal(this.ttConf).getRaw();
     this.localDirs = createPaths(user, localDirs);
-    ttConf.setStrings(JOB_LOCAL_CTXT, localDirs);
+    this.ttConf.setStrings(JOB_LOCAL_CTXT, localDirs);
     Collections.shuffle(this.localDirs);
     lDirAlloc = new LocalDirAllocator(JOB_LOCAL_CTXT);
     JOBDIR = TaskTracker.JOBCACHE + Path.SEPARATOR + jobid;

Added: hadoop/common/branches/branch-1/src/test/org/apache/hadoop/mapred/TestJobLocalizer.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1/src/test/org/apache/hadoop/mapred/TestJobLocalizer.java?rev=1442404&view=auto
==============================================================================
--- hadoop/common/branches/branch-1/src/test/org/apache/hadoop/mapred/TestJobLocalizer.java
(added)
+++ hadoop/common/branches/branch-1/src/test/org/apache/hadoop/mapred/TestJobLocalizer.java
Mon Feb  4 22:26:34 2013
@@ -0,0 +1,44 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.mapred;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+
+import org.apache.hadoop.conf.Configuration;
+import org.junit.Test;
+
+public class TestJobLocalizer {
+
+  @Test(timeout = 1000)
+  public void testConcurrentJobLocalizers() throws IOException {
+    final String LOCAL_DIR = "/tmp/mapred/local";
+    JobConf conf = new JobConf(new Configuration());
+    
+    JobLocalizer localizer1 = new JobLocalizer(conf, "user1", "jobid1",
+        LOCAL_DIR);
+    JobLocalizer localizer2 = new JobLocalizer(conf, "user2", "jobid2",
+        LOCAL_DIR);
+    assertTrue("Localizer 1 job local dirs should have user1",
+        localizer1.ttConf.get(JobLocalizer.JOB_LOCAL_CTXT).contains("user1"));
+    assertTrue("Localizer 2 job local dirs should have user2",
+        localizer2.ttConf.get(JobLocalizer.JOB_LOCAL_CTXT).contains("user2"));
+  }
+}



Mime
View raw message