ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject git commit: AMBARI-5342 Ambari YARN UI - Quick Link - JMX breaks if RM port is changed (dsen)
Date Fri, 04 Apr 2014 16:38:57 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 7df81fabf -> 34476f2d4


AMBARI-5342 Ambari YARN UI - Quick Link - JMX breaks if RM port is changed (dsen)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/34476f2d
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/34476f2d
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/34476f2d

Branch: refs/heads/trunk
Commit: 34476f2d44ad72752eb89de4ef1511f756eeda29
Parents: 7df81fa
Author: Dmitry Sen <dsen@hortonworks.com>
Authored: Fri Apr 4 19:38:46 2014 +0300
Committer: Dmitry Sen <dsen@hortonworks.com>
Committed: Fri Apr 4 19:38:46 2014 +0300

----------------------------------------------------------------------
 .../internal/AbstractProviderModule.java        |  4 +-
 .../internal/JMXHostProviderTest.java           | 52 +++++++++++++++++++-
 2 files changed, 53 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/34476f2d/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractProviderModule.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractProviderModule.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractProviderModule.java
index 4d358ec..ced22b1 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractProviderModule.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractProviderModule.java
@@ -225,7 +225,9 @@ public abstract class AbstractProviderModule implements ProviderModule,
Resource
         // Since concurrent thread access is expected we err on the side of
         // performance with a ConcurrentHashMap and maybe get default/existing
         // ports for a few calls.
-        if (!currVersion.equals(oldVersion)) {
+        if (!currVersion.equals(oldVersion) ||
+          !clusterJmxPorts.containsKey(componentName)) {
+
           serviceConfigVersions.put(service, currVersion);
           
           Map<String, String> portMap = getDesiredConfigMap(clusterName,

http://git-wip-us.apache.org/repos/asf/ambari/blob/34476f2d/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/JMXHostProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/JMXHostProviderTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/JMXHostProviderTest.java
index ec82e55..412b066 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/JMXHostProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/JMXHostProviderTest.java
@@ -61,6 +61,7 @@ public class JMXHostProviderTest {
   private static final String NAMENODE_PORT_V1 = "dfs.http.address";
   private static final String NAMENODE_PORT_V2 = "dfs.namenode.http-address";
   private static final String DATANODE_PORT = "dfs.datanode.http.address";
+  private static final String RESOURCEMANAGER_PORT = "yarn.resourcemanager.webapp.address";
 
   @Before
   public void setup() throws Exception {
@@ -191,14 +192,17 @@ public class JMXHostProviderTest {
 
   private void createConfigs() throws AmbariException {
     String clusterName = "c1";
-    ClusterRequest r = new ClusterRequest(null, clusterName, "HDP-0.1", null);
+    ClusterRequest r = new ClusterRequest(null, clusterName, "HDP-2.0.6", null);
     controller.createCluster(r);
-    clusters.getCluster(clusterName).setDesiredStackVersion(new StackId("HDP-0.1"));
+    clusters.getCluster(clusterName).setDesiredStackVersion(new StackId("HDP-2.0.6"));
     String serviceName = "HDFS";
+    String serviceName2 = "YARN";
     createService(clusterName, serviceName, null);
+    createService(clusterName, serviceName2, null);
     String componentName1 = "NAMENODE";
     String componentName2 = "DATANODE";
     String componentName3 = "HDFS_CLIENT";
+    String componentName4 = "RESOURCEMANAGER";
 
     createServiceComponent(clusterName, serviceName, componentName1,
       State.INIT);
@@ -206,6 +210,8 @@ public class JMXHostProviderTest {
       State.INIT);
     createServiceComponent(clusterName, serviceName, componentName3,
       State.INIT);
+    createServiceComponent(clusterName, serviceName2, componentName4,
+      State.INIT);
 
     String host1 = "h1";
     clusters.addHost(host1);
@@ -228,6 +234,8 @@ public class JMXHostProviderTest {
       host1, null);
     createServiceComponentHost(clusterName, serviceName, componentName3,
       host2, null);
+    createServiceComponentHost(clusterName, serviceName2, componentName4,
+      host2, null);
 
     // Create configs
     Map<String, String> configs = new HashMap<String, String>();
@@ -235,6 +243,9 @@ public class JMXHostProviderTest {
     configs.put(DATANODE_PORT, "localhost:70075");
     configs.put("ambari.dfs.datanode.http.port", "70070");
 
+    Map<String, String> yarnConfigs = new HashMap<String, String>();
+    yarnConfigs.put(RESOURCEMANAGER_PORT, "8088");
+
     ConfigurationRequest cr1 = new ConfigurationRequest(clusterName,
       "hdfs-site", "versionN", configs);
 
@@ -244,6 +255,14 @@ public class JMXHostProviderTest {
     Cluster cluster = clusters.getCluster(clusterName);
     Assert.assertEquals("versionN", cluster.getDesiredConfigByType("hdfs-site")
       .getVersionTag());
+
+    ConfigurationRequest cr2 = new ConfigurationRequest(clusterName,
+      "yarn-site", "versionN", yarnConfigs);
+    crReq.setDesiredConfig(cr2);
+    controller.updateClusters(Collections.singleton(crReq), null);
+
+    Assert.assertEquals("versionN", cluster.getDesiredConfigByType("yarn-site")
+      .getVersionTag());
     Assert.assertEquals("localhost:${ambari.dfs.datanode.http.port}", cluster.getDesiredConfigByType
       ("hdfs-site").getProperties().get(NAMENODE_PORT_V1));
   }
@@ -309,6 +328,35 @@ public class JMXHostProviderTest {
     Assert.assertEquals(null, providerModule.getPort("c1", "HBASE_MASTER"));
   }
 
+  @Test
+  public void testJMXPortMapUpdate() throws
+    NoSuchParentResourceException,
+    ResourceAlreadyExistsException, UnsupportedPropertyException,
+    SystemException, AmbariException, NoSuchResourceException {
+
+    createConfigs();
+
+    JMXHostProviderModule providerModule = new JMXHostProviderModule();
+    providerModule.registerResourceProvider(Resource.Type.Cluster);
+    providerModule.registerResourceProvider(Resource.Type.Configuration);
+    // Non default port addresses
+    Assert.assertEquals("8088", providerModule.getPort("c1", "RESOURCEMANAGER"));
+
+    Map<String, String> yarnConfigs = new HashMap<String, String>();
+    yarnConfigs.put(RESOURCEMANAGER_PORT, "localhost:50030");
+    ConfigurationRequest cr2 = new ConfigurationRequest("c1",
+      "yarn-site", "versionN+1", yarnConfigs);
+
+    ClusterRequest crReq = new ClusterRequest(null, "c1", null, null);
+    crReq.setDesiredConfig(cr2);
+    controller.updateClusters(Collections.singleton(crReq), null);
+    Assert.assertEquals("50030", providerModule.getPort("c1", "RESOURCEMANAGER"));
+
+    //Unrelated ports
+    Assert.assertEquals("70070", providerModule.getPort("c1", "NAMENODE"));
+    Assert.assertEquals(null, providerModule.getPort("c1", "JOBTRACKER"));
+  }
+
   private static class JMXHostProviderModule extends
     AbstractProviderModule {
 


Mime
View raw message