You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by jl...@apache.org on 2017/07/23 23:34:07 UTC

[34/50] [abbrv] ambari git commit: AMBARI-21524: ResourceManager HA status not reported when using VIPs (jluniya)

AMBARI-21524: ResourceManager HA status not reported when using VIPs (jluniya)


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

Branch: refs/heads/branch-feature-AMBARI-14714
Commit: b55e4578e529f247ba878803742540320ae9d6e4
Parents: 0a42f53
Author: Jayush Luniya <jl...@hortonworks.com>
Authored: Wed Jul 19 12:23:49 2017 -0700
Committer: Jayush Luniya <jl...@hortonworks.com>
Committed: Wed Jul 19 12:23:49 2017 -0700

----------------------------------------------------------------------
 .../internal/AbstractProviderModule.java        |  1 +
 .../internal/HttpPropertyProvider.java          | 27 ++++++++++++++++++--
 .../internal/HttpPropertyProviderTest.java      | 11 ++++++++
 3 files changed, 37 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/b55e4578/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 f3211bf..0242d7c 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
@@ -817,6 +817,7 @@ public abstract class AbstractProviderModule implements ProviderModule,
             managementController.getClusters(),
             PropertyHelper.getPropertyId("HostRoles", "cluster_name"),
             PropertyHelper.getPropertyId("HostRoles", "host_name"),
+            PropertyHelper.getPropertyId("HostRoles", "public_host_name"),
             PropertyHelper.getPropertyId("HostRoles", "component_name"),
             HTTP_PROPERTY_REQUESTS));
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/b55e4578/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HttpPropertyProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HttpPropertyProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HttpPropertyProvider.java
index 6a04b60..c556b06 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HttpPropertyProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HttpPropertyProvider.java
@@ -48,6 +48,7 @@ public class HttpPropertyProvider extends BaseProvider implements PropertyProvid
   private final StreamProvider streamProvider;
   private final String clusterNamePropertyId;
   private final String hostNamePropertyId;
+  private final String publicHostNamePropertyId;
   private final String componentNamePropertyId;
   private final Clusters clusters;
   private final Map<String, List<HttpPropertyRequest>> httpPropertyRequests;
@@ -60,6 +61,7 @@ public class HttpPropertyProvider extends BaseProvider implements PropertyProvid
       Clusters clusters,
       String clusterNamePropertyId,
       String hostNamePropertyId,
+      String publicHostNamePropertyId,
       String componentNamePropertyId,
       Map<String, List<HttpPropertyRequest>> httpPropertyRequests) {
 
@@ -67,6 +69,7 @@ public class HttpPropertyProvider extends BaseProvider implements PropertyProvid
     this.streamProvider = stream;
     this.clusterNamePropertyId = clusterNamePropertyId;
     this.hostNamePropertyId = hostNamePropertyId;
+    this.publicHostNamePropertyId = publicHostNamePropertyId;
     this.componentNamePropertyId = componentNamePropertyId;
     this.clusters = clusters;
     this.httpPropertyRequests = httpPropertyRequests;
@@ -103,6 +106,7 @@ public class HttpPropertyProvider extends BaseProvider implements PropertyProvid
     for (Resource resource : resources) {
       String clusterName = (String) resource.getPropertyValue(clusterNamePropertyId);
       String hostName = (String) resource.getPropertyValue(hostNamePropertyId);
+      String publicHostName = (String) resource.getPropertyValue(publicHostNamePropertyId);
       String componentName = (String) resource.getPropertyValue(componentNamePropertyId);
 
       if (clusterName != null && hostName != null && componentName != null &&
@@ -114,7 +118,7 @@ public class HttpPropertyProvider extends BaseProvider implements PropertyProvid
           List<HttpPropertyRequest> httpPropertyRequestList = httpPropertyRequests.get(componentName);
 
           for (HttpPropertyRequest httpPropertyRequest : httpPropertyRequestList) {
-            populateResource(httpPropertyRequest, resource, cluster, hostName);
+            populateResource(httpPropertyRequest, resource, cluster, hostName, publicHostName);
           }
         } catch (AmbariException e) {
           String msg = String.format("Could not load cluster with name %s.", clusterName);
@@ -128,7 +132,7 @@ public class HttpPropertyProvider extends BaseProvider implements PropertyProvid
 
   // populate the given resource from the given HTTP property request.
   private void populateResource(HttpPropertyRequest httpPropertyRequest, Resource resource,
-                                Cluster cluster, String hostName) throws SystemException {
+                                Cluster cluster, String hostName, String publicHostName) throws SystemException {
 
     String url = httpPropertyRequest.getUrl(cluster, hostName);
 
@@ -146,6 +150,25 @@ public class HttpPropertyProvider extends BaseProvider implements PropertyProvid
       }
     } catch (Exception e) {
       LOG.debug(String.format("Error reading HTTP response from %s", url), e);
+      if(publicHostName != null && !publicHostName.equalsIgnoreCase(hostName)) {
+        String publicUrl = httpPropertyRequest.getUrl(cluster, publicHostName);
+        LOG.debug(String.format("Retry using public host name url %s", publicUrl));
+        try {
+          InputStream inputStream = streamProvider.readFrom(publicUrl);
+
+          try {
+            httpPropertyRequest.populateResource(resource, inputStream);
+          } finally {
+            try {
+              inputStream.close();
+            } catch (IOException ioe) {
+              LOG.error(String.format("Error closing HTTP response stream %s", url), ioe);
+            }
+          }
+        } catch (Exception ex) {
+          LOG.debug(String.format("Error reading HTTP response from public host name url %s", url), ex);
+        }
+      }
     }
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/b55e4578/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HttpPropertyProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HttpPropertyProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HttpPropertyProviderTest.java
index 2eb02d1..7c8a6b1 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HttpPropertyProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HttpPropertyProviderTest.java
@@ -44,6 +44,7 @@ import org.junit.Test;
 public class HttpPropertyProviderTest {
   private static final String PROPERTY_ID_CLUSTER_NAME = PropertyHelper.getPropertyId("HostRoles", "cluster_name");
   private static final String PROPERTY_ID_HOST_NAME = PropertyHelper.getPropertyId("HostRoles", "host_name");
+  private static final String PROPERTY_ID_PUBLIC_HOST_NAME = PropertyHelper.getPropertyId("HostRoles", "public_host_name");
   private static final String PROPERTY_ID_COMPONENT_NAME = PropertyHelper.getPropertyId("HostRoles", "component_name");
 
   private static final String PROPERTY_ID_STALE_CONFIGS = PropertyHelper.getPropertyId(
@@ -85,12 +86,14 @@ public class HttpPropertyProviderTest {
             streamProvider, clusters,
             PROPERTY_ID_CLUSTER_NAME,
             PROPERTY_ID_HOST_NAME,
+            PROPERTY_ID_PUBLIC_HOST_NAME,
             PROPERTY_ID_COMPONENT_NAME,
             HTTP_PROPERTY_REQUESTS);
 
     Resource resource = new ResourceImpl(Resource.Type.HostComponent);
 
     resource.setProperty(PROPERTY_ID_HOST_NAME, "ec2-54-234-33-50.compute-1.amazonaws.com");
+    resource.setProperty(PROPERTY_ID_PUBLIC_HOST_NAME, "ec2-54-234-33-50.compute-1.amazonaws.com");
     resource.setProperty(PROPERTY_ID_CLUSTER_NAME, "testCluster");
     resource.setProperty(PROPERTY_ID_COMPONENT_NAME, "RESOURCEMANAGER");
 
@@ -134,12 +137,14 @@ public class HttpPropertyProviderTest {
         streamProvider, clusters,
         PROPERTY_ID_CLUSTER_NAME,
         PROPERTY_ID_HOST_NAME,
+        PROPERTY_ID_PUBLIC_HOST_NAME,
         PROPERTY_ID_COMPONENT_NAME,
         HTTP_PROPERTY_REQUESTS);
 
     Resource resource = new ResourceImpl(Resource.Type.HostComponent);
 
     resource.setProperty(PROPERTY_ID_HOST_NAME, "lc6402.ambari.apache.org");
+    resource.setProperty(PROPERTY_ID_PUBLIC_HOST_NAME, "lc6402.ambari.apache.org");
     resource.setProperty(PROPERTY_ID_CLUSTER_NAME, "testCluster");
     resource.setProperty(PROPERTY_ID_COMPONENT_NAME, "RESOURCEMANAGER");
 
@@ -174,6 +179,7 @@ public class HttpPropertyProviderTest {
         streamProvider, clusters,
         PROPERTY_ID_CLUSTER_NAME,
         PROPERTY_ID_HOST_NAME,
+        PROPERTY_ID_PUBLIC_HOST_NAME,
         PROPERTY_ID_COMPONENT_NAME,
         HTTP_PROPERTY_REQUESTS);
 
@@ -181,6 +187,7 @@ public class HttpPropertyProviderTest {
 
     resource.setProperty(PROPERTY_ID_CLUSTER_NAME, "testCluster");
     resource.setProperty(PROPERTY_ID_HOST_NAME, "ec2-54-234-33-50.compute-1.amazonaws.com");
+    resource.setProperty(PROPERTY_ID_PUBLIC_HOST_NAME, "ec2-54-234-33-50.compute-1.amazonaws.com");
     resource.setProperty(PROPERTY_ID_COMPONENT_NAME, "ATLAS_SERVER");
 
     Request request = PropertyHelper.getReadRequest(Collections.<String>emptySet());
@@ -214,6 +221,7 @@ public class HttpPropertyProviderTest {
         streamProvider, clusters,
         PROPERTY_ID_CLUSTER_NAME,
         PROPERTY_ID_HOST_NAME,
+        PROPERTY_ID_PUBLIC_HOST_NAME,
         PROPERTY_ID_COMPONENT_NAME,
         HTTP_PROPERTY_REQUESTS);
 
@@ -221,6 +229,7 @@ public class HttpPropertyProviderTest {
 
     resource.setProperty(PROPERTY_ID_CLUSTER_NAME, "testCluster");
     resource.setProperty(PROPERTY_ID_HOST_NAME, "ec2-54-234-33-50.compute-1.amazonaws.com");
+    resource.setProperty(PROPERTY_ID_PUBLIC_HOST_NAME, "ec2-54-234-33-50.compute-1.amazonaws.com");
     resource.setProperty(PROPERTY_ID_COMPONENT_NAME, "ATLAS_SERVER");
 
     Request request = PropertyHelper.getReadRequest(Collections.<String>emptySet());
@@ -249,12 +258,14 @@ public class HttpPropertyProviderTest {
        streamProvider, clusters,
        PROPERTY_ID_CLUSTER_NAME,
        PROPERTY_ID_HOST_NAME,
+       PROPERTY_ID_PUBLIC_HOST_NAME,
        PROPERTY_ID_COMPONENT_NAME,
        HTTP_PROPERTY_REQUESTS);
 
     Resource resource = new ResourceImpl(Resource.Type.HostComponent);
 
     resource.setProperty(PROPERTY_ID_HOST_NAME, "ec2-54-234-33-50.compute-1.amazonaws.com");
+    resource.setProperty(PROPERTY_ID_PUBLIC_HOST_NAME, "ec2-54-234-33-50.compute-1.amazonaws.com");
     resource.setProperty(PROPERTY_ID_CLUSTER_NAME, "testCluster");
     resource.setProperty(PROPERTY_ID_COMPONENT_NAME, componentName);