فهرست منبع

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 12 سال پیش
والد
کامیت
557b3a3e3d
3فایلهای تغییر یافته به همراه21 افزوده شده و 3 حذف شده
  1. 3 0
      CHANGES.txt
  2. 12 1
      src/mapred/org/apache/hadoop/mapred/JobTracker.java
  3. 6 2
      src/test/org/apache/hadoop/mapred/TestJobHistoryConfig.java

+ 3 - 0
CHANGES.txt

@@ -407,6 +407,9 @@ Release 1.1.0 - 2012.09.28
     getting, renewing, and cancelling the underlying token. Systems with
     getting, renewing, and cancelling the underlying token. Systems with
     weak crypto (kssl) configured will continue to use https. (omalley)
     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
 Release 1.0.4 - Unreleased
 
 
   NEW FEATURES
   NEW FEATURES

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

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

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

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