Browse Source

AMBARI-18621. Service Summary screen does not show hostname in tooltip pop-up for all services. (jaimin)

Jaimin Jetly 8 years ago
parent
commit
083cd7fcb8

+ 10 - 0
ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentHostRequest.java

@@ -26,6 +26,7 @@ public class ServiceComponentHostRequest {
   private String serviceName;
   private String componentName;
   private String hostname;
+  private String publicHostname;
   private String state;
   private String desiredState; // CREATE/UPDATE
   private String desiredStackId; // UPDATE
@@ -178,6 +179,7 @@ public class ServiceComponentHostRequest {
       .append(", serviceName=").append(serviceName)
       .append(", componentName=").append(componentName)
       .append(", hostname=").append(hostname)
+      .append(", publicHostname=").append(publicHostname)
       .append(", desiredState=").append(desiredState)
       .append(", state=").append(state)
       .append(", desiredStackId=").append(desiredStackId)
@@ -201,4 +203,12 @@ public class ServiceComponentHostRequest {
   public String getMaintenanceState() {
     return maintenanceState;
   }
+
+  public String getPublicHostname() {
+    return publicHostname;
+  }
+
+  public void setPublicHostname(String publicHostname) {
+    this.publicHostname = publicHostname;
+  }
 }

+ 18 - 1
ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentHostResponse.java

@@ -30,6 +30,7 @@ public class ServiceComponentHostResponse {
   private String serviceName;
   private String componentName;
   private String displayName;
+  private String publicHostname;
   private String hostname;
   // type -> desired config
   private Map<String, HostConfig> actualConfigs;
@@ -44,7 +45,8 @@ public class ServiceComponentHostResponse {
 
 
   public ServiceComponentHostResponse(String clusterName, String serviceName,
-                                      String componentName, String displayName, String hostname,
+                                      String componentName, String displayName,
+                                      String hostname, String publicHostname,
                                       String liveState, String stackVersion,
                                       String desiredState, String desiredStackVersion,
                                       HostComponentAdminState adminState) {
@@ -53,6 +55,7 @@ public class ServiceComponentHostResponse {
     this.componentName = componentName;
     this.displayName = displayName;
     this.hostname = hostname;
+    this.publicHostname = publicHostname;
     this.liveState = liveState;
     this.stackVersion = stackVersion;
     this.desiredState = desiredState;
@@ -111,6 +114,20 @@ public class ServiceComponentHostResponse {
     this.hostname = hostname;
   }
 
+  /**
+   * @return the public hostname
+   */
+  public String getPublicHostname() {
+    return publicHostname;
+  }
+
+  /**
+   * @param publicHostname the public hostname to set
+   */
+  public void setPublicHostname(String publicHostname) {
+    this.publicHostname = publicHostname;
+  }
+
   /**
    * @return the liveState
    */

+ 9 - 0
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java

@@ -91,6 +91,8 @@ public class HostComponentResourceProvider extends AbstractControllerResourcePro
       = PropertyHelper.getPropertyId("HostRoles", "display_name");
   public static final String HOST_COMPONENT_HOST_NAME_PROPERTY_ID
       = PropertyHelper.getPropertyId("HostRoles", "host_name");
+  public static final String HOST_COMPONENT_PUBLIC_HOST_NAME_PROPERTY_ID
+      = PropertyHelper.getPropertyId("HostRoles", "public_host_name");
   public static final String HOST_COMPONENT_STATE_PROPERTY_ID
       = PropertyHelper.getPropertyId("HostRoles", "state");
   public static final String HOST_COMPONENT_DESIRED_STATE_PROPERTY_ID
@@ -229,6 +231,8 @@ public class HostComponentResourceProvider extends AbstractControllerResourcePro
               response.getDisplayName(), requestedIds);
       setResourceProperty(resource, HOST_COMPONENT_HOST_NAME_PROPERTY_ID,
               response.getHostname(), requestedIds);
+      setResourceProperty(resource, HOST_COMPONENT_PUBLIC_HOST_NAME_PROPERTY_ID,
+          response.getPublicHostname(), requestedIds);
       setResourceProperty(resource, HOST_COMPONENT_STATE_PROPERTY_ID,
               response.getLiveState(), requestedIds);
       setResourceProperty(resource, HOST_COMPONENT_DESIRED_STATE_PROPERTY_ID,
@@ -690,6 +694,11 @@ public class HostComponentResourceProvider extends AbstractControllerResourcePro
       serviceComponentHostRequest.setAdminState(
           properties.get(HOST_COMPONENT_DESIRED_ADMIN_STATE_PROPERTY_ID).toString());
     }
+    if (properties.get(HOST_COMPONENT_PUBLIC_HOST_NAME_PROPERTY_ID) != null) {
+      serviceComponentHostRequest.setPublicHostname(
+          properties.get(HOST_COMPONENT_PUBLIC_HOST_NAME_PROPERTY_ID).toString());
+    }
+
 
     Object o = properties.get(HOST_COMPONENT_MAINTENANCE_STATE_PROPERTY_ID);
     if (null != o) {

+ 6 - 0
ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentHost.java

@@ -59,6 +59,12 @@ public interface ServiceComponentHost {
    */
   String getHostName();
 
+  /**
+   * Get the public host name this object maps to
+   * @return Host's public hostname
+   */
+  String getPublicHostName();
+
   /**
    * Get the Host this object maps to
    * @return Host Object

+ 8 - 1
ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java

@@ -1091,6 +1091,11 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
     return host.getHostName();
   }
 
+  @Override
+  public String getPublicHostName() {
+    return host.getPublicHostName();
+  }
+
   @Override
   public Host getHost() {
     return host;
@@ -1364,6 +1369,7 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
         String serviceName = serviceComponent.getServiceName();
         String serviceComponentName = serviceComponent.getName();
         String hostName = getHostName();
+        String publicHostName = getPublicHostName();
         String state = getState().toString();
         String stackId = getStackVersion().getStackId();
         String desiredState = getDesiredState().toString();
@@ -1382,7 +1388,8 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
 
         ServiceComponentHostResponse r = new ServiceComponentHostResponse(
             clusterName, serviceName,
-            serviceComponentName, displayName, hostName, state,
+            serviceComponentName, displayName, hostName,
+            publicHostName, state,
             stackId, desiredState,
             desiredStackId, componentAdminState);
 

+ 1 - 0
ambari-server/src/main/resources/properties.json

@@ -74,6 +74,7 @@
         "HostRoles/role_id",
         "HostRoles/cluster_name",
         "HostRoles/host_name",
+        "HostRoles/public_host_name",
         "HostRoles/component_name",
         "HostRoles/display_name",
         "HostRoles/state",

+ 4 - 2
ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProviderTest.java

@@ -225,6 +225,7 @@ public class ClientConfigResourceProviderTest {
     String componentName = "PIG";
     String displayName = "Pig Client";
     String hostName = "Host100";
+    String publicHostname = "Host100";
     String desiredState = "INSTALLED";
 
     String stackName = "S1";
@@ -249,7 +250,7 @@ public class ClientConfigResourceProviderTest {
     HashMap<String, ServiceOsSpecific> serviceOsSpecificHashMap = new HashMap<String, ServiceOsSpecific>();
     serviceOsSpecificHashMap.put("key",serviceOsSpecific);
 
-    ServiceComponentHostResponse shr1 = new ServiceComponentHostResponse(clusterName, serviceName, componentName, displayName, hostName, desiredState, "", null, null, null);
+    ServiceComponentHostResponse shr1 = new ServiceComponentHostResponse(clusterName, serviceName, componentName, displayName, hostName, publicHostname,desiredState, "", null, null, null);
 
     Set<ServiceComponentHostResponse> responses = new LinkedHashSet<ServiceComponentHostResponse>();
     responses.add(shr1);
@@ -425,6 +426,7 @@ public class ClientConfigResourceProviderTest {
     String componentName = "PIG";
     String displayName = "Pig Client";
     String hostName = "Host100";
+    String publicHostName = "Host100";
     String desiredState = "INSTALLED";
 
     String stackName = "S1";
@@ -450,7 +452,7 @@ public class ClientConfigResourceProviderTest {
     HashMap<String, ServiceOsSpecific> serviceOsSpecificHashMap = new HashMap<String, ServiceOsSpecific>();
     serviceOsSpecificHashMap.put("key",serviceOsSpecific);
 
-    ServiceComponentHostResponse shr1 = new ServiceComponentHostResponse(clusterName, serviceName, componentName, displayName, hostName, desiredState, "", null, null, null);
+    ServiceComponentHostResponse shr1 = new ServiceComponentHostResponse(clusterName, serviceName, componentName, displayName, hostName, publicHostName, desiredState, "", null, null, null);
 
     Set<ServiceComponentHostResponse> responses = new LinkedHashSet<ServiceComponentHostResponse>();
     responses.add(shr1);

+ 5 - 5
ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HostComponentResourceProviderTest.java

@@ -184,14 +184,14 @@ public class HostComponentResourceProviderTest {
     StackId stackId = new StackId("HDP-0.1");
     StackId stackId2 = new StackId("HDP-0.2");
     allResponse.add(new ServiceComponentHostResponse(
-        "Cluster100", "Service100", "Component100", "Component 100", "Host100", State.INSTALLED.toString(), stackId.getStackId(), State.STARTED.toString(),
+        "Cluster100", "Service100", "Component100", "Component 100", "Host100", "Host100", State.INSTALLED.toString(), stackId.getStackId(), State.STARTED.toString(),
         stackId2.getStackId(), null));
     allResponse.add(new ServiceComponentHostResponse(
-        "Cluster100", "Service100", "Component101", "Component 101", "Host100", State.INSTALLED.toString(), stackId.getStackId(), State.STARTED.toString(),
+        "Cluster100", "Service100", "Component101", "Component 101", "Host100", "Host100", State.INSTALLED.toString(), stackId.getStackId(), State.STARTED.toString(),
         stackId2.getStackId(), null));
 
     allResponse.add(new ServiceComponentHostResponse(
-        "Cluster100", "Service100", "Component102", "Component 102", "Host100", State.INSTALLED.toString(), stackId.getStackId(), State.STARTED.toString(),
+        "Cluster100", "Service100", "Component102", "Component 102", "Host100","Host100", State.INSTALLED.toString(), stackId.getStackId(), State.STARTED.toString(),
         stackId2.getStackId(), null));
     Map<String, String> expectedNameValues = new HashMap<String, String>();
     expectedNameValues.put(
@@ -337,7 +337,7 @@ public class HostComponentResourceProviderTest {
 
     Set<ServiceComponentHostResponse> nameResponse = new HashSet<ServiceComponentHostResponse>();
     nameResponse.add(new ServiceComponentHostResponse(
-        "Cluster102", "Service100", "Component100", "Component 100", "Host100", "INSTALLED", "", "", "", null));
+        "Cluster102", "Service100", "Component100", "Component 100", "Host100", "Host100","INSTALLED", "", "", "", null));
 
     // set expectations
     expect(managementController.getClusters()).andReturn(clusters).anyTimes();
@@ -538,7 +538,7 @@ public class HostComponentResourceProviderTest {
 
     Set<ServiceComponentHostResponse> nameResponse = new HashSet<ServiceComponentHostResponse>();
     nameResponse.add(new ServiceComponentHostResponse(
-        "Cluster102", "Service100", "Component100", "Component 100", "Host100", "INSTALLED", "", "", "", null));
+        "Cluster102", "Service100", "Component100", "Component 100", "Host100", "Host100","INSTALLED", "", "", "", null));
 
     // set expectations
     expect(managementController.getClusters()).andReturn(clusters).anyTimes();

+ 13 - 13
ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HostResourceProviderTest.java

@@ -300,11 +300,11 @@ public class HostResourceProviderTest extends EasyMockSupport {
     clusterSet.add(cluster);
 
     ServiceComponentHostResponse shr1 = new ServiceComponentHostResponse("Cluster100", "Service100", "Component100", "Component 100",
-        "Host100", "STARTED", "", null, null, null);
+        "Host100", "Host100", "STARTED", "", null, null, null);
     ServiceComponentHostResponse shr2 = new ServiceComponentHostResponse("Cluster100", "Service100", "Component102", "Component 102",
-        "Host100", "STARTED", "", null, null, null);
+        "Host100", "Host100", "STARTED", "", null, null, null);
     ServiceComponentHostResponse shr3 = new ServiceComponentHostResponse("Cluster100", "Service100", "Component103", "Component 103",
-        "Host100", "STARTED", "", null, null, null);
+        "Host100", "Host100", "STARTED", "", null, null, null);
 
     Set<ServiceComponentHostResponse> responses = new HashSet<ServiceComponentHostResponse>();
     responses.add(shr1);
@@ -401,11 +401,11 @@ public class HostResourceProviderTest extends EasyMockSupport {
     clusterSet.add(cluster);
 
     ServiceComponentHostResponse shr1 = new ServiceComponentHostResponse("Cluster100", "Service100", "Component100", "Component 100",
-        "Host100", "STARTED", "", null, null, null);
+        "Host100", "Host100", "STARTED", "", null, null, null);
     ServiceComponentHostResponse shr2 = new ServiceComponentHostResponse("Cluster100", "Service100", "Component102", "Component 102",
-        "Host100", "STARTED", "", null, null, null);
+        "Host100", "Host100", "STARTED", "", null, null, null);
     ServiceComponentHostResponse shr3 = new ServiceComponentHostResponse("Cluster100", "Service100", "Component103", "Component 103",
-        "Host100", "STARTED", "", null, null, null);
+        "Host100", "Host100", "STARTED", "", null, null, null);
 
     Set<ServiceComponentHostResponse> responses = new HashSet<ServiceComponentHostResponse>();
     responses.add(shr1);
@@ -497,11 +497,11 @@ public class HostResourceProviderTest extends EasyMockSupport {
     clusterSet.add(cluster);
 
     ServiceComponentHostResponse shr1 = new ServiceComponentHostResponse("Cluster100", "Service100", "Component100", "Component 100",
-        "Host100", "STARTED", "", null, null, null);
+        "Host100", "Host100", "STARTED", "", null, null, null);
     ServiceComponentHostResponse shr2 = new ServiceComponentHostResponse("Cluster100", "Service100", "Component102", "Component 102",
-        "Host100", "INSTALLED", "", null, null, null);
+        "Host100", "Host100", "INSTALLED", "", null, null, null);
     ServiceComponentHostResponse shr3 = new ServiceComponentHostResponse("Cluster100", "Service100", "Component103", "Component 103",
-        "Host100", "STARTED", "", null, null, null);
+        "Host100", "Host100", "STARTED", "", null, null, null);
 
     Set<ServiceComponentHostResponse> responses = new HashSet<ServiceComponentHostResponse>();
     responses.add(shr1);
@@ -697,7 +697,7 @@ public class HostResourceProviderTest extends EasyMockSupport {
     clusterSet.add(cluster);
 
     ServiceComponentHostResponse shr1 = new ServiceComponentHostResponse("Cluster100", "Service100", "Component100", "Component 100",
-        "Host100", "STARTED", "", null, null, null);
+        "Host100", "Host100", "STARTED", "", null, null, null);
 
     Set<ServiceComponentHostResponse> responses = new HashSet<ServiceComponentHostResponse>();
     responses.add(shr1);
@@ -784,11 +784,11 @@ public class HostResourceProviderTest extends EasyMockSupport {
     clusterSet.add(cluster);
 
     ServiceComponentHostResponse shr1 = new ServiceComponentHostResponse("Cluster100", "Service100", "Component100", "Component 100",
-        "Host100", "STARTED", "", null, null, null);
+        "Host100", "Host100", "STARTED", "", null, null, null);
     ServiceComponentHostResponse shr2 = new ServiceComponentHostResponse("Cluster100", "Service100", "Component102", "Component 102",
-        "Host100", "INSTALLED", "", null, null, null);
+        "Host100", "Host100", "INSTALLED", "", null, null, null);
     ServiceComponentHostResponse shr3 = new ServiceComponentHostResponse("Cluster100", "Service100", "Component103", "Component 103",
-        "Host100", "STARTED", "", null, null, null);
+        "Host100", "Host100", "STARTED", "", null, null, null);
 
     Set<ServiceComponentHostResponse> responses = new HashSet<ServiceComponentHostResponse>();
     responses.add(shr1);

+ 2 - 1
ambari-web/app/controllers/global/update_controller.js

@@ -466,6 +466,7 @@ App.UpdateController = Em.Controller.extend({
         'ServiceComponentInfo/service_name,' +
         'host_components/HostRoles/display_name,' +
         'host_components/HostRoles/host_name,' +
+        'host_components/HostRoles/public_host_name,' +
         'host_components/HostRoles/state,' +
         'host_components/HostRoles/maintenance_state,' +
         'host_components/HostRoles/stale_configs,' +
@@ -533,7 +534,7 @@ App.UpdateController = Em.Controller.extend({
   },
   updateComponentConfig: function (callback) {
     var testUrl = '/data/services/host_component_stale_configs.json';
-    var componentConfigUrl = this.getUrl(testUrl, '/components?host_components/HostRoles/stale_configs=true&fields=host_components/HostRoles/display_name,host_components/HostRoles/service_name,host_components/HostRoles/state,host_components/HostRoles/maintenance_state,host_components/HostRoles/host_name,host_components/HostRoles/stale_configs,host_components/HostRoles/desired_admin_state&minimal_response=true');
+    var componentConfigUrl = this.getUrl(testUrl, '/components?host_components/HostRoles/stale_configs=true&fields=host_components/HostRoles/display_name,host_components/HostRoles/service_name,host_components/HostRoles/state,host_components/HostRoles/maintenance_state,host_components/HostRoles/host_name,host_components/HostRoles/public_host_name,host_components/HostRoles/stale_configs,host_components/HostRoles/desired_admin_state&minimal_response=true');
     App.HttpClient.get(componentConfigUrl, App.componentConfigMapper, {
       complete: callback
     });

+ 1 - 0
ambari-web/app/mappers/component_config_mapper.js

@@ -26,6 +26,7 @@ App.componentConfigMapper = App.QuickDataMapper.create({
     component_name: 'HostRoles.component_name',
     display_name: 'HostRoles.display_name',
     host_name: 'HostRoles.host_name',
+    public_host_name: 'HostRoles.public_host_name',
     $ha_status: '',
     $display_name_advanced: '',
     stale_configs: 'HostRoles.stale_configs',

+ 2 - 0
ambari-web/app/mappers/hosts_mapper.js

@@ -65,6 +65,7 @@ App.hostsMapper = App.QuickDataMapper.create({
     work_status: 'HostRoles.state',
     stale_configs: 'HostRoles.stale_configs',
     host_name: 'host_name',
+    public_host_name: 'public_host_name',
     admin_state: 'HostRoles.desired_admin_state'
   },
   stackVersionConfig: {
@@ -131,6 +132,7 @@ App.hostsMapper = App.QuickDataMapper.create({
           component.id = id;
           component.host_id = item.Hosts.host_name;
           component.host_name = item.Hosts.host_name;
+          component.public_host_name = item.Hosts.public_host_name;
           components.push(component);
           componentsIdMap[id] = component;
           if (!newHostComponentsMap[serviceName]) {

+ 1 - 0
ambari-web/app/mappers/service_metrics_mapper.js

@@ -159,6 +159,7 @@ App.serviceMetricsMapper = App.QuickDataMapper.create({
     component_name: 'HostRoles.component_name',
     host_id: 'HostRoles.host_name',
     host_name: 'HostRoles.host_name',
+    public_host_name: 'HostRoles.public_host_name',
     stale_configs: 'HostRoles.stale_configs',
     ha_status: 'HostRoles.ha_state',
     display_name_advanced: 'display_name_advanced',

+ 1 - 0
ambari-web/app/models/host_component.js

@@ -29,6 +29,7 @@ App.HostComponent = DS.Model.extend({
   host: DS.belongsTo('App.Host'),
   componentLogs: DS.belongsTo('App.HostComponentLog'),
   hostName: DS.attr('string'),
+  publicHostName: DS.attr('string'),
   service: DS.belongsTo('App.Service'),
   adminState: DS.attr('string'),
 

+ 1 - 1
ambari-web/app/templates/main/service/info/summary/master_components.hbs

@@ -19,7 +19,7 @@
 {{#each comp in view.mastersComp}}
   <tr {{bindAttr class="comp.isSubComponent:component-small :component comp.componentName"}}>
     <td {{bindAttr class=":summary-label comp.summaryLabelClassName"}}>
-      <a href="#" {{action showDetails comp.host}} title="{{unbound comp.host.publicHostName}}" rel="UsageTooltip">
+      <a href="#" {{action showDetails comp.host}} title="{{unbound comp.publicHostName}}" rel="UsageTooltip">
         {{#if comp.displayNameAdvanced}}
           {{comp.displayNameAdvanced}}
         {{else}}