Author: jlowe Date: Thu Oct 10 15:43:05 2013 New Revision: 1531029 URL: http://svn.apache.org/r1531029 Log: svn merge -c 1511464 FIXES: MAPREDUCE-5425. Junit in TestJobHistoryServer failing in jdk 7. Contributed by Robert Parker
Modified: hadoop/common/branches/branch-0.23/hadoop-mapreduce-project/CHANGES.txt hadoop/common/branches/branch-0.23/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/JobHistoryServer.java hadoop/common/branches/branch-0.23/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/TestJobHistoryServer.java Modified: hadoop/common/branches/branch-0.23/hadoop-mapreduce-project/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.23/hadoop-mapreduce-project/CHANGES.txt?rev=1531029&r1=1531028&r2=1531029&view=diff ============================================================================== --- hadoop/common/branches/branch-0.23/hadoop-mapreduce-project/CHANGES.txt (original) +++ hadoop/common/branches/branch-0.23/hadoop-mapreduce-project/CHANGES.txt Thu Oct 10 15:43:05 2013 @@ -57,6 +57,9 @@ Release 0.23.10 - UNRELEASED MAPREDUCE-4571. TestHsWebServicesJobs fails on jdk7. (tgraves via tucu) + MAPREDUCE-5425. Junit in TestJobHistoryServer failing in jdk 7 (Robert + Parker via jlowe) + Release 0.23.9 - 2013-07-08 INCOMPATIBLE CHANGES Modified: hadoop/common/branches/branch-0.23/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/JobHistoryServer.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.23/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/JobHistoryServer.java?rev=1531029&r1=1531028&r2=1531029&view=diff ============================================================================== --- hadoop/common/branches/branch-0.23/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/JobHistoryServer.java (original) +++ hadoop/common/branches/branch-0.23/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/JobHistoryServer.java Thu Oct 10 15:43:05 2013 @@ -30,6 +30,7 @@ import org.apache.hadoop.mapreduce.v2.jo import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem; import org.apache.hadoop.metrics2.source.JvmMetrics; import org.apache.hadoop.security.SecurityUtil; +import org.apache.hadoop.util.ExitUtil; import org.apache.hadoop.util.ShutdownHookManager; import org.apache.hadoop.util.StringUtils; import org.apache.hadoop.yarn.YarnException; @@ -133,11 +134,13 @@ public class JobHistoryServer extends Co return this.clientService; } - public static void main(String[] args) { - Thread.setDefaultUncaughtExceptionHandler(new YarnUncaughtExceptionHandler()); + static JobHistoryServer launchJobHistoryServer(String[] args) { + Thread. + setDefaultUncaughtExceptionHandler(new YarnUncaughtExceptionHandler()); StringUtils.startupShutdownMessage(JobHistoryServer.class, args, LOG); + JobHistoryServer jobHistoryServer = null; try { - JobHistoryServer jobHistoryServer = new JobHistoryServer(); + jobHistoryServer = new JobHistoryServer(); ShutdownHookManager.get().addShutdownHook( new CompositeServiceShutdownHook(jobHistoryServer), SHUTDOWN_HOOK_PRIORITY); @@ -146,7 +149,12 @@ public class JobHistoryServer extends Co jobHistoryServer.start(); } catch (Throwable t) { LOG.fatal("Error starting JobHistoryServer", t); - System.exit(-1); + ExitUtil.terminate(-1, "Error starting JobHistoryServer"); } + return jobHistoryServer; + } + + public static void main(String[] args) { + launchJobHistoryServer(args); } } Modified: hadoop/common/branches/branch-0.23/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/TestJobHistoryServer.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.23/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/TestJobHistoryServer.java?rev=1531029&r1=1531028&r2=1531029&view=diff ============================================================================== --- hadoop/common/branches/branch-0.23/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/TestJobHistoryServer.java (original) +++ hadoop/common/branches/branch-0.23/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/TestJobHistoryServer.java Thu Oct 10 15:43:05 2013 @@ -79,14 +79,11 @@ public class TestJobHistoryServer { private static RecordFactory recordFactory = RecordFactoryProvider .getRecordFactory(null); - - JobHistoryServer historyServer=null; + // simple test init/start/stop JobHistoryServer. Status should change. - @Test (timeout= 50000 ) public void testStartStopServer() throws Exception { - historyServer = new JobHistoryServer(); Configuration config = new Configuration(); historyServer.init(config); @@ -99,7 +96,6 @@ public class TestJobHistoryServer { assertNotNull(historyServer.getClientService()); HistoryClientService historyService = historyServer.getClientService(); assertNotNull(historyService.getClientHandler().getConnectAddress()); - } /* @@ -126,7 +122,6 @@ public class TestJobHistoryServer { } //Test reports of JobHistoryServer. History server should get log files from MRApp and read them - @Test (timeout= 50000 ) public void testReports() throws Exception { Configuration config = new Configuration(); @@ -160,7 +155,6 @@ public class TestJobHistoryServer { assertEquals(1, jobs.size()); assertEquals("job_0_0000",jobs.keySet().iterator().next().toString()); - Task task = job.getTasks().values().iterator().next(); TaskAttempt attempt = task.getAttempts().values().iterator().next(); @@ -274,14 +268,14 @@ public class TestJobHistoryServer { historyServer.stop(); } - // test main method + + // test launch method @Test (timeout =60000) - public void testMainMethod() throws Exception { + public void testLaunch() throws Exception { ExitUtil.disableSystemExit(); try { - JobHistoryServer.main(new String[0]); - + historyServer = JobHistoryServer.launchJobHistoryServer(new String[0]); } catch (ExitUtil.ExitException e) { assertEquals(0,e.status); ExitUtil.resetFirstExitException();