Parcourir la source

YARN-3108. ApplicationHistoryServer doesn't process -D arguments (Chang Li via jeagles)

Jonathan Eagles il y a 10 ans
Parent
commit
30a8778c63

+ 3 - 0
hadoop-yarn-project/CHANGES.txt

@@ -222,6 +222,9 @@ Release 2.7.0 - UNRELEASED
     scheduler web UI and queue initialize/refresh logging. 
     (Eric Payne via wangda)
 
+    YARN-3108. ApplicationHistoryServer doesn't process -D arguments (Chang Li
+    via jeagles)
+
   OPTIMIZATIONS
 
   BUG FIXES

+ 2 - 0
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryServer.java

@@ -33,6 +33,7 @@ import org.apache.hadoop.security.SecurityUtil;
 import org.apache.hadoop.service.CompositeService;
 import org.apache.hadoop.service.Service;
 import org.apache.hadoop.util.ExitUtil;
+import org.apache.hadoop.util.GenericOptionsParser;
 import org.apache.hadoop.util.ReflectionUtils;
 import org.apache.hadoop.util.ShutdownHookManager;
 import org.apache.hadoop.util.StringUtils;
@@ -153,6 +154,7 @@ public class ApplicationHistoryServer extends CompositeService {
         new CompositeServiceShutdownHook(appHistoryServer),
         SHUTDOWN_HOOK_PRIORITY);
       YarnConfiguration conf = new YarnConfiguration();
+      new GenericOptionsParser(conf, args);
       appHistoryServer.init(conf);
       appHistoryServer.start();
     } catch (Throwable t) {

+ 26 - 0
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestApplicationHistoryServer.java

@@ -106,6 +106,32 @@ public class TestApplicationHistoryServer {
     }
   }
 
+ //test launch method with -D arguments
+ @Test(timeout = 60000)
+ public void testLaunchWithArguments() throws Exception {
+   ExitUtil.disableSystemExit();
+   ApplicationHistoryServer historyServer = null;
+   try {
+     // Not able to modify the config of this test case,
+     // but others have been customized to avoid conflicts
+     String[] args = new String[2];
+     args[0]="-D" + YarnConfiguration.TIMELINE_SERVICE_LEVELDB_TTL_INTERVAL_MS + "=4000";
+     args[1]="-D" + YarnConfiguration.TIMELINE_SERVICE_TTL_MS + "=200";
+     historyServer =
+         ApplicationHistoryServer.launchAppHistoryServer(args);
+     Configuration conf = historyServer.getConfig();
+     assertEquals("4000", conf.get(YarnConfiguration.TIMELINE_SERVICE_LEVELDB_TTL_INTERVAL_MS));
+     assertEquals("200", conf.get(YarnConfiguration.TIMELINE_SERVICE_TTL_MS));
+   } catch (ExitUtil.ExitException e) {
+     assertEquals(0, e.status);
+     ExitUtil.resetFirstExitException();
+     fail();
+   } finally {
+     if (historyServer != null) {
+       historyServer.stop();
+     }
+   }
+ }
   @Test(timeout = 240000)
   public void testFilterOverrides() throws Exception {