Przeglądaj źródła

YARN-2859. ApplicationHistoryServer binds to default port 8188 in
MiniYARNCluster. Contributed by Vinod Kumar Vavilapalli

Xuan 9 lat temu
rodzic
commit
27414dac66

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

@@ -1897,6 +1897,9 @@ Release 2.6.2 - UNRELEASED
     YARN-3798. ZKRMStateStore shouldn't create new session without occurrance of 
     SESSIONEXPIED. (ozawa and Varun Saxena)
 
+    YARN-2859. ApplicationHistoryServer binds to default port 8188 in MiniYARNCluster.
+    (Vinod Kumar Vavilapalli via xgong)
+
 Release 2.6.1 - 2015-09-23
 
   INCOMPATIBLE CHANGES

+ 10 - 4
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/MiniYARNCluster.java

@@ -252,9 +252,9 @@ public class MiniYARNCluster extends CompositeService {
       resourceManagers[i] = createResourceManager();
       if (!useFixedPorts) {
         if (HAUtil.isHAEnabled(conf)) {
-          setHARMConfiguration(i, conf);
+          setHARMConfigurationWithEphemeralPorts(i, conf);
         } else {
-          setNonHARMConfiguration(conf);
+          setNonHARMConfigurationWithEphemeralPorts(conf);
         }
       }
       addService(new ResourceManagerWrapper(i));
@@ -274,7 +274,7 @@ public class MiniYARNCluster extends CompositeService {
         conf instanceof YarnConfiguration ? conf : new YarnConfiguration(conf));
   }
 
-  private void setNonHARMConfiguration(Configuration conf) {
+  private void setNonHARMConfigurationWithEphemeralPorts(Configuration conf) {
     String hostname = MiniYARNCluster.getHostname();
     conf.set(YarnConfiguration.RM_ADDRESS, hostname + ":0");
     conf.set(YarnConfiguration.RM_ADMIN_ADDRESS, hostname + ":0");
@@ -283,7 +283,7 @@ public class MiniYARNCluster extends CompositeService {
     WebAppUtils.setRMWebAppHostnameAndPort(conf, hostname, 0);
   }
 
-  private void setHARMConfiguration(final int index, Configuration conf) {
+  private void setHARMConfigurationWithEphemeralPorts(final int index, Configuration conf) {
     String hostname = MiniYARNCluster.getHostname();
     for (String confKey : YarnConfiguration.getServiceAddressConfKeys(conf)) {
       conf.set(HAUtil.addSuffix(confKey, rmIds[index]), hostname + ":0");
@@ -704,6 +704,12 @@ public class MiniYARNCluster extends CompositeService {
           MemoryTimelineStore.class, TimelineStore.class);
       conf.setClass(YarnConfiguration.TIMELINE_SERVICE_STATE_STORE_CLASS,
           MemoryTimelineStateStore.class, TimelineStateStore.class);
+      if (!useFixedPorts) {
+        String hostname = MiniYARNCluster.getHostname();
+        conf.set(YarnConfiguration.TIMELINE_SERVICE_ADDRESS, hostname + ":0");
+        conf.set(YarnConfiguration.TIMELINE_SERVICE_WEBAPP_ADDRESS, hostname
+            + ":0");
+      }
       appHistoryServer.init(conf);
       super.serviceInit(conf);
     }

+ 9 - 0
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/TestMiniYarnCluster.java

@@ -26,6 +26,7 @@ import org.junit.Assert;
 import org.junit.Test;
 
 public class TestMiniYarnCluster {
+
   @Test
   public void testTimelineServiceStartInMiniCluster() throws Exception {
     Configuration conf = new YarnConfiguration();
@@ -68,6 +69,14 @@ public class TestMiniYarnCluster {
       cluster = new MiniYARNCluster(TestMiniYarnCluster.class.getSimpleName(),
           numNodeManagers, numLocalDirs, numLogDirs, numLogDirs, enableAHS);
       cluster.init(conf);
+
+      // Verify that the timeline-service starts on ephemeral ports by default
+      String hostname = MiniYARNCluster.getHostname();
+      Assert.assertEquals(hostname + ":0",
+        conf.get(YarnConfiguration.TIMELINE_SERVICE_ADDRESS));
+      Assert.assertEquals(hostname + ":0",
+        conf.get(YarnConfiguration.TIMELINE_SERVICE_WEBAPP_ADDRESS));
+
       cluster.start();
 
       //Timeline service may sometime take a while to get started