Ver Fonte

merge MAPREDUCE-4698 from branch-1. Fix failing unit test - TestJobHistoryConfig. Optionally initialize the jobtracker on a JobTracker.startTracker. (Contributed by Gopal V)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-1.1@1393261 13f79535-47bb-0310-9956-ffa450edef68
Siddharth Seth há 12 anos atrás
pai
commit
557b3a3e3d

+ 3 - 0
CHANGES.txt

@@ -407,6 +407,9 @@ Release 1.1.0 - 2012.09.28
     getting, renewing, and cancelling the underlying token. Systems with
     weak crypto (kssl) configured will continue to use https. (omalley)
 
+    MAPREDUCE-4698. Fix failing unit test - TestJobHistoryConfig. Optionally
+    initialize the jobtracker on a JobTracker.startTracker. (Gopal V via sseth)
+
 Release 1.0.4 - Unreleased
 
   NEW FEATURES

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

@@ -296,8 +296,13 @@ public class JobTracker implements MRConstants, InterTrackerProtocol,
                                                  InterruptedException {
     return startTracker(conf, generateNewIdentifier());
   }
-  
+
   public static JobTracker startTracker(JobConf conf, String identifier) 
+  throws IOException, InterruptedException {
+  	return startTracker(conf, identifier, false);
+  }
+  
+  public static JobTracker startTracker(JobConf conf, String identifier, boolean initialize) 
   throws IOException, InterruptedException {
     DefaultMetricsSystem.initialize("JobTracker");
     JobTracker result = null;
@@ -325,6 +330,12 @@ public class JobTracker implements MRConstants, InterTrackerProtocol,
     if (result != null) {
       JobEndNotifier.startNotifier();
       MBeans.register("JobTracker", "JobTrackerInfo", result);
+      if(initialize == true) {
+        result.setSafeModeInternal(SafeModeAction.SAFEMODE_ENTER);
+        result.initializeFilesystem();
+        result.setSafeModeInternal(SafeModeAction.SAFEMODE_LEAVE);
+        result.initialize();
+      }
     }
     return result;
   }

+ 6 - 2
src/test/org/apache/hadoop/mapred/TestJobHistoryConfig.java

@@ -17,8 +17,10 @@
  */
 package org.apache.hadoop.mapred;
 
+import java.util.Date;
 import java.io.IOException;
 import java.io.PrintWriter;
+import java.text.SimpleDateFormat;
 
 import org.apache.hadoop.hdfs.MiniDFSCluster;
 import org.apache.hadoop.io.LongWritable;
@@ -113,7 +115,8 @@ public class TestJobHistoryConfig extends TestCase {
     conf.setQueueName("default");
     String TEST_ROOT_DIR = new Path(System.getProperty("test.build.data",
         "/tmp")).toString().replace(' ', '+');
-    JobTracker jt = JobTracker.startTracker(conf);
+    String uniqid = new SimpleDateFormat("yyyyMMddHHmm").format(new Date());
+    JobTracker jt = JobTracker.startTracker(conf, uniqid, true);
     assertTrue(jt != null);
     JobInProgress jip = new JobInProgress(new JobID("jt", 1),
         new JobConf(conf), jt);
@@ -132,8 +135,9 @@ public class TestJobHistoryConfig extends TestCase {
   private boolean canStartJobTracker(JobConf conf) throws InterruptedException,
       IOException {
     JobTracker jt = null;
+    String uniqid = new SimpleDateFormat("yyyyMMddHHmm").format(new Date());
     try {
-      jt = JobTracker.startTracker(conf);
+      jt = JobTracker.startTracker(conf, uniqid, true);
       Log.info("Started JobTracker");
     } catch (IOException e) {
       Log.info("Can not Start JobTracker", e.getLocalizedMessage());