You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by dm...@apache.org on 2016/01/11 14:21:38 UTC
[1/4] ambari git commit: AMBARI-14593. Ambari not showing
active/standby status for Resource manager when custom ports are used
(dlysnichenko)
Repository: ambari
Updated Branches:
refs/heads/branch-2.2 0f4c75d9d -> ce4b480ba
refs/heads/trunk c76a47af8 -> ae780b618
AMBARI-14593. Ambari not showing active/standby status for Resource manager when custom ports are used (dlysnichenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/213e5843
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/213e5843
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/213e5843
Branch: refs/heads/branch-2.2
Commit: 213e58439e82957cb20fbfe481f754a2f19128c9
Parents: 0f4c75d
Author: Lisnichenko Dmitro <dl...@hortonworks.com>
Authored: Mon Jan 11 15:17:52 2016 +0200
Committer: Lisnichenko Dmitro <dl...@hortonworks.com>
Committed: Mon Jan 11 15:17:52 2016 +0200
----------------------------------------------------------------------
.../internal/HttpProxyPropertyProvider.java | 58 ++++++++++++++++++--
.../internal/HttpPropertyProviderTest.java | 56 ++++++++++++++++++-
2 files changed, 107 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/213e5843/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HttpProxyPropertyProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HttpProxyPropertyProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HttpProxyPropertyProvider.java
index 302a54b..e92536c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HttpProxyPropertyProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HttpProxyPropertyProvider.java
@@ -65,8 +65,18 @@ public class HttpProxyPropertyProvider extends BaseProvider implements PropertyP
private static final String PROPERTY_YARN_HTTP_POLICY_VALUE_HTTPS_ONLY = "HTTPS_ONLY";
private static final String PROPERTY_HADOOP_SSL_ENABLED_VALUE_TRUE = "true";
+
+ private static final String PROPERTY_RESOURCEMANAGER_WEBAPP_ADDRESS = "yarn.resourcemanager.webapp.address";
+ private static final String PROPERTY_RESOURCEMANAGER_WEBAPP_HTTPS_ADDRESS = "yarn.resourcemanager.webapp.https.address";
+ // resource manager HA properties
+
+ private static final String PROPERTY_RESOURCEMANAGER_HA_RM_IDS = "yarn.resourcemanager.ha.rm-ids";
+ private static final String PROPERTY_RESOURCEMANAGER_HOSTNAME_TEMPLATE = "yarn.resourcemanager.hostname.%s";
+ private static final String PROPERTY_RESOURCEMANAGER_WEBAPP_ADDRESS_TEMPLATE = "yarn.resourcemanager.webapp.address.%s";
+ private static final String PROPERTY_RESOURCEMANAGER_WEBAPP_HTTPS_ADDRESS_TEMPLATE = "yarn.resourcemanager.webapp.https.address.%s";
+
static {
- URL_TEMPLATES.put(COMPONENT_RESOURCEMANAGER, "http://%s:8088/ws/v1/cluster/info");
+ URL_TEMPLATES.put(COMPONENT_RESOURCEMANAGER, "http://%s:%s/ws/v1/cluster/info");
MAPPINGS.put(COMPONENT_RESOURCEMANAGER, PropertyHelper.getPropertyId("HostRoles", "ha_state"));
@@ -125,7 +135,7 @@ public class HttpProxyPropertyProvider extends BaseProvider implements PropertyP
MAPPINGS.containsKey(componentName.toString()) &&
URL_TEMPLATES.containsKey(componentName.toString())) {
- String template = getTemplate(componentName.toString(), clusterName.toString());
+ String template = getTemplate(componentName.toString(), clusterName.toString(), hostName.toString());
String propertyId = MAPPINGS.get(componentName.toString());
String url = String.format(template, hostName);
@@ -136,7 +146,7 @@ public class HttpProxyPropertyProvider extends BaseProvider implements PropertyP
return resources;
}
- private String getTemplate(String componentName, String clusterName) throws SystemException {
+ private String getTemplate(String componentName, String clusterName, String hostName) throws SystemException {
String template = URL_TEMPLATES.get(componentName);
if (componentName.equals(COMPONENT_RESOURCEMANAGER)) {
@@ -146,10 +156,41 @@ public class HttpProxyPropertyProvider extends BaseProvider implements PropertyP
Map<String, String> coreConfigProperties = cluster.getDesiredConfigByType(CONFIG_CORE_SITE).getProperties();
String yarnHttpPolicy = yarnConfigProperties.get(PROPERTY_YARN_HTTP_POLICY);
String hadoopSslEnabled = coreConfigProperties.get(PROPERTY_HADOOP_SSL_ENABLED);
- if ((yarnHttpPolicy != null && yarnHttpPolicy.equals(PROPERTY_YARN_HTTP_POLICY_VALUE_HTTPS_ONLY)) ||
- hadoopSslEnabled != null && hadoopSslEnabled.equals(PROPERTY_HADOOP_SSL_ENABLED_VALUE_TRUE)) {
+ boolean useHttps = (yarnHttpPolicy != null && yarnHttpPolicy.equals(PROPERTY_YARN_HTTP_POLICY_VALUE_HTTPS_ONLY)) ||
+ hadoopSslEnabled != null && hadoopSslEnabled.equals(PROPERTY_HADOOP_SSL_ENABLED_VALUE_TRUE);
+ if (useHttps) {
template = template.replace("http", "https");
}
+ // determine correct port, we don't want to use hardcoded one
+ String port;
+ if(!yarnConfigProperties.containsKey(PROPERTY_RESOURCEMANAGER_HA_RM_IDS)) {
+ //non ha mode
+ if(useHttps) {
+ port = getPortFromProperty(yarnConfigProperties, PROPERTY_RESOURCEMANAGER_WEBAPP_HTTPS_ADDRESS, "8090");
+ } else {
+ port = getPortFromProperty(yarnConfigProperties, PROPERTY_RESOURCEMANAGER_WEBAPP_ADDRESS, "8088");
+ }
+ } else {
+ // ha mode
+ String rmId = null;
+ for(String id : yarnConfigProperties.get(PROPERTY_RESOURCEMANAGER_HA_RM_IDS).split(",")) {
+ String hostNameProperty = String.format(PROPERTY_RESOURCEMANAGER_HOSTNAME_TEMPLATE, id);
+ String hostNameById = yarnConfigProperties.get(hostNameProperty);
+ if(hostNameById.equals(hostName)){
+ rmId = id;
+ break;
+ }
+ }
+ if(useHttps) {
+ String httpsAddressPoperty = String.format(PROPERTY_RESOURCEMANAGER_WEBAPP_HTTPS_ADDRESS_TEMPLATE, rmId);
+ port = getPortFromProperty(yarnConfigProperties, httpsAddressPoperty, "8090");
+ } else {
+ String httpAddressPoperty = String.format(PROPERTY_RESOURCEMANAGER_WEBAPP_ADDRESS_TEMPLATE, rmId);
+ port = getPortFromProperty(yarnConfigProperties, httpAddressPoperty, "8088");
+ }
+
+ }
+ template = String.format(template, "%s", port);
} catch (AmbariException e) {
LOG.debug(String.format("Could not load cluster with name %s. %s", clusterName, e.getMessage()));
throw new SystemException(String.format("Could not load cluster with name %s.", clusterName),e);
@@ -158,6 +199,13 @@ public class HttpProxyPropertyProvider extends BaseProvider implements PropertyP
return template;
}
+ private String getPortFromProperty(Map<String, String> propertyMap, String property, String defaultValue) {
+ if(propertyMap.containsKey(property))
+ return propertyMap.get(property).split(":")[1];
+ else
+ return defaultValue;
+ }
+
private Object getPropertyValueToSet(Map<String, Object> propertyValueFromJson, Object componentName) throws SystemException {
Object result = propertyValueFromJson;
//TODO need refactoring for universalization
http://git-wip-us.apache.org/repos/asf/ambari/blob/213e5843/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 154d125..b622728 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
@@ -91,7 +91,8 @@ public class HttpPropertyProviderTest {
Map<String, String> map = new HashMap<String, String>();
map.put("yarn.http.policy", "HTTPS_ONLY");
-
+ map.put("yarn.resourcemanager.webapp.https.address", "ec2-54-234-33-50.compute-1.amazonaws.com:8999");
+ map.put("yarn.resourcemanager.webapp.address", "ec2-54-234-33-50.compute-1.amazonaws.com:8088");
expect(injector.getInstance(Clusters.class)).andReturn(clusters);
expect(clusters.getCluster("testCluster")).andReturn(cluster);
@@ -119,11 +120,62 @@ public class HttpPropertyProviderTest {
propProvider.populateResources(Collections.singleton(resource), request, null);
Assert.assertTrue(resource.getPropertiesMap().get("HostRoles").get("ha_state").equals("ACTIVE"));
- Assert.assertTrue(streamProvider.getLastSpec().equals("https://ec2-54-234-33-50.compute-1.amazonaws.com:8088" +
+ Assert.assertTrue(streamProvider.getLastSpec().equals("https://ec2-54-234-33-50.compute-1.amazonaws.com:8999" +
"/ws/v1/cluster/info"));
}
@Test
+ public void testReadResourceManagerHA() throws Exception {
+
+ TestStreamProvider streamProvider = new TestStreamProvider(false);
+ Clusters clusters = createNiceMock(Clusters.class);
+ Cluster cluster = createNiceMock(Cluster.class);
+ Injector injector = createNiceMock(Injector.class);
+ Config config1 = createNiceMock(Config.class);
+ Config config2 = createNiceMock(Config.class);
+
+ Map<String, String> map = new HashMap<String, String>();
+ map.put("yarn.http.policy", "HTTPS_ONLY");
+ map.put("yarn.resourcemanager.ha.rm-ids", "rm1,rm2");
+ map.put("yarn.resourcemanager.hostname.rm1", "lc6402.ambari.apache.org");
+ map.put("yarn.resourcemanager.hostname.rm2", "lc6403.ambari.apache.org");
+ map.put("yarn.resourcemanager.webapp.address.rm1", "lc6402.ambari.apache.org:8099");
+ map.put("yarn.resourcemanager.webapp.address.rm2", "lc6403.ambari.apache.org:8099");
+ map.put("yarn.resourcemanager.webapp.https.address.rm1", "lc6402.ambari.apache.org:8066");
+ map.put("yarn.resourcemanager.webapp.https.address.rm2", "lc6403.ambari.apache.org:8066");
+
+ expect(injector.getInstance(Clusters.class)).andReturn(clusters);
+ expect(clusters.getCluster("testCluster")).andReturn(cluster);
+ expect(cluster.getDesiredConfigByType("yarn-site")).andReturn(config1).anyTimes();
+ expect(cluster.getDesiredConfigByType("core-site")).andReturn(config2).anyTimes();
+ expect(config1.getProperties()).andReturn(map).anyTimes();
+ expect(config2.getProperties()).andReturn(new HashMap<String, String>()).anyTimes();
+
+ replay(injector, clusters, cluster, config1, config2);
+
+ HttpProxyPropertyProvider propProvider = new HttpProxyPropertyProvider(
+ streamProvider, configuration, injector,
+ PROPERTY_ID_CLUSTER_NAME,
+ PROPERTY_ID_HOST_NAME,
+ PROPERTY_ID_COMPONENT_NAME);
+
+ Resource resource = new ResourceImpl(Resource.Type.HostComponent);
+
+ resource.setProperty(PROPERTY_ID_HOST_NAME, "lc6402.ambari.apache.org");
+ resource.setProperty(PROPERTY_ID_CLUSTER_NAME, "testCluster");
+ resource.setProperty(PROPERTY_ID_COMPONENT_NAME, "RESOURCEMANAGER");
+
+ Request request = PropertyHelper.getReadRequest(Collections.<String>emptySet());
+
+ propProvider.populateResources(Collections.singleton(resource), request, null);
+
+ Assert.assertTrue(resource.getPropertiesMap().get("HostRoles").get("ha_state").equals("ACTIVE"));
+ Assert.assertTrue(streamProvider.getLastSpec().equals("https://lc6402.ambari.apache.org:8066" +
+ "/ws/v1/cluster/info"));
+ }
+
+
+ @Test
public void testReadGangliaServer() throws Exception {
Resource resource = doPopulate("GANGLIA_SERVER",
Collections.<String> emptySet(), new TestStreamProvider(false));
[4/4] ambari git commit: AMBARI-14593. Ambari not showing
active/standby status for Resource manager when custom ports are used
(dgrinenko via dlysnichenko)
Posted by dm...@apache.org.
AMBARI-14593. Ambari not showing active/standby status for Resource manager when custom ports are used (dgrinenko via dlysnichenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/ce4b480b
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/ce4b480b
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/ce4b480b
Branch: refs/heads/branch-2.2
Commit: ce4b480baabd7418724092d2a92d67ab300291bb
Parents: 213e584
Author: Lisnichenko Dmitro <dl...@hortonworks.com>
Authored: Mon Jan 11 15:20:14 2016 +0200
Committer: Lisnichenko Dmitro <dl...@hortonworks.com>
Committed: Mon Jan 11 15:21:09 2016 +0200
----------------------------------------------------------------------
.../ambari/server/controller/internal/HostResourceProvider.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/ce4b480b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostResourceProvider.java
index bc47ee7..7ce956f 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostResourceProvider.java
@@ -830,7 +830,7 @@ public class HostResourceProvider extends AbstractControllerResourceProvider {
// Assume the user also wants to delete it entirely, including all clusters.
clusters.deleteHost(hostRequest.getHostname());
- for (LogicalRequest logicalRequest: topologyManager.getRequests(Collections.EMPTY_LIST)) {
+ for (LogicalRequest logicalRequest: topologyManager.getRequests(Collections.<Long>emptyList())) {
logicalRequest.removeHostRequestByHostName(hostRequest.getHostname());
}
[2/4] ambari git commit: AMBARI-14593. Ambari not showing
active/standby status for Resource manager when custom ports are used
(dlysnichenko)
Posted by dm...@apache.org.
AMBARI-14593. Ambari not showing active/standby status for Resource manager when custom ports are used (dlysnichenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/35073a28
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/35073a28
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/35073a28
Branch: refs/heads/trunk
Commit: 35073a28173e89004fb0a4347d4150b5c169122e
Parents: c76a47a
Author: Lisnichenko Dmitro <dl...@hortonworks.com>
Authored: Mon Jan 11 15:17:52 2016 +0200
Committer: Lisnichenko Dmitro <dl...@hortonworks.com>
Committed: Mon Jan 11 15:19:10 2016 +0200
----------------------------------------------------------------------
.../internal/HttpProxyPropertyProvider.java | 58 ++++++++++++++++++--
.../internal/HttpPropertyProviderTest.java | 56 ++++++++++++++++++-
2 files changed, 107 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/35073a28/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HttpProxyPropertyProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HttpProxyPropertyProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HttpProxyPropertyProvider.java
index 302a54b..e92536c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HttpProxyPropertyProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HttpProxyPropertyProvider.java
@@ -65,8 +65,18 @@ public class HttpProxyPropertyProvider extends BaseProvider implements PropertyP
private static final String PROPERTY_YARN_HTTP_POLICY_VALUE_HTTPS_ONLY = "HTTPS_ONLY";
private static final String PROPERTY_HADOOP_SSL_ENABLED_VALUE_TRUE = "true";
+
+ private static final String PROPERTY_RESOURCEMANAGER_WEBAPP_ADDRESS = "yarn.resourcemanager.webapp.address";
+ private static final String PROPERTY_RESOURCEMANAGER_WEBAPP_HTTPS_ADDRESS = "yarn.resourcemanager.webapp.https.address";
+ // resource manager HA properties
+
+ private static final String PROPERTY_RESOURCEMANAGER_HA_RM_IDS = "yarn.resourcemanager.ha.rm-ids";
+ private static final String PROPERTY_RESOURCEMANAGER_HOSTNAME_TEMPLATE = "yarn.resourcemanager.hostname.%s";
+ private static final String PROPERTY_RESOURCEMANAGER_WEBAPP_ADDRESS_TEMPLATE = "yarn.resourcemanager.webapp.address.%s";
+ private static final String PROPERTY_RESOURCEMANAGER_WEBAPP_HTTPS_ADDRESS_TEMPLATE = "yarn.resourcemanager.webapp.https.address.%s";
+
static {
- URL_TEMPLATES.put(COMPONENT_RESOURCEMANAGER, "http://%s:8088/ws/v1/cluster/info");
+ URL_TEMPLATES.put(COMPONENT_RESOURCEMANAGER, "http://%s:%s/ws/v1/cluster/info");
MAPPINGS.put(COMPONENT_RESOURCEMANAGER, PropertyHelper.getPropertyId("HostRoles", "ha_state"));
@@ -125,7 +135,7 @@ public class HttpProxyPropertyProvider extends BaseProvider implements PropertyP
MAPPINGS.containsKey(componentName.toString()) &&
URL_TEMPLATES.containsKey(componentName.toString())) {
- String template = getTemplate(componentName.toString(), clusterName.toString());
+ String template = getTemplate(componentName.toString(), clusterName.toString(), hostName.toString());
String propertyId = MAPPINGS.get(componentName.toString());
String url = String.format(template, hostName);
@@ -136,7 +146,7 @@ public class HttpProxyPropertyProvider extends BaseProvider implements PropertyP
return resources;
}
- private String getTemplate(String componentName, String clusterName) throws SystemException {
+ private String getTemplate(String componentName, String clusterName, String hostName) throws SystemException {
String template = URL_TEMPLATES.get(componentName);
if (componentName.equals(COMPONENT_RESOURCEMANAGER)) {
@@ -146,10 +156,41 @@ public class HttpProxyPropertyProvider extends BaseProvider implements PropertyP
Map<String, String> coreConfigProperties = cluster.getDesiredConfigByType(CONFIG_CORE_SITE).getProperties();
String yarnHttpPolicy = yarnConfigProperties.get(PROPERTY_YARN_HTTP_POLICY);
String hadoopSslEnabled = coreConfigProperties.get(PROPERTY_HADOOP_SSL_ENABLED);
- if ((yarnHttpPolicy != null && yarnHttpPolicy.equals(PROPERTY_YARN_HTTP_POLICY_VALUE_HTTPS_ONLY)) ||
- hadoopSslEnabled != null && hadoopSslEnabled.equals(PROPERTY_HADOOP_SSL_ENABLED_VALUE_TRUE)) {
+ boolean useHttps = (yarnHttpPolicy != null && yarnHttpPolicy.equals(PROPERTY_YARN_HTTP_POLICY_VALUE_HTTPS_ONLY)) ||
+ hadoopSslEnabled != null && hadoopSslEnabled.equals(PROPERTY_HADOOP_SSL_ENABLED_VALUE_TRUE);
+ if (useHttps) {
template = template.replace("http", "https");
}
+ // determine correct port, we don't want to use hardcoded one
+ String port;
+ if(!yarnConfigProperties.containsKey(PROPERTY_RESOURCEMANAGER_HA_RM_IDS)) {
+ //non ha mode
+ if(useHttps) {
+ port = getPortFromProperty(yarnConfigProperties, PROPERTY_RESOURCEMANAGER_WEBAPP_HTTPS_ADDRESS, "8090");
+ } else {
+ port = getPortFromProperty(yarnConfigProperties, PROPERTY_RESOURCEMANAGER_WEBAPP_ADDRESS, "8088");
+ }
+ } else {
+ // ha mode
+ String rmId = null;
+ for(String id : yarnConfigProperties.get(PROPERTY_RESOURCEMANAGER_HA_RM_IDS).split(",")) {
+ String hostNameProperty = String.format(PROPERTY_RESOURCEMANAGER_HOSTNAME_TEMPLATE, id);
+ String hostNameById = yarnConfigProperties.get(hostNameProperty);
+ if(hostNameById.equals(hostName)){
+ rmId = id;
+ break;
+ }
+ }
+ if(useHttps) {
+ String httpsAddressPoperty = String.format(PROPERTY_RESOURCEMANAGER_WEBAPP_HTTPS_ADDRESS_TEMPLATE, rmId);
+ port = getPortFromProperty(yarnConfigProperties, httpsAddressPoperty, "8090");
+ } else {
+ String httpAddressPoperty = String.format(PROPERTY_RESOURCEMANAGER_WEBAPP_ADDRESS_TEMPLATE, rmId);
+ port = getPortFromProperty(yarnConfigProperties, httpAddressPoperty, "8088");
+ }
+
+ }
+ template = String.format(template, "%s", port);
} catch (AmbariException e) {
LOG.debug(String.format("Could not load cluster with name %s. %s", clusterName, e.getMessage()));
throw new SystemException(String.format("Could not load cluster with name %s.", clusterName),e);
@@ -158,6 +199,13 @@ public class HttpProxyPropertyProvider extends BaseProvider implements PropertyP
return template;
}
+ private String getPortFromProperty(Map<String, String> propertyMap, String property, String defaultValue) {
+ if(propertyMap.containsKey(property))
+ return propertyMap.get(property).split(":")[1];
+ else
+ return defaultValue;
+ }
+
private Object getPropertyValueToSet(Map<String, Object> propertyValueFromJson, Object componentName) throws SystemException {
Object result = propertyValueFromJson;
//TODO need refactoring for universalization
http://git-wip-us.apache.org/repos/asf/ambari/blob/35073a28/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 154d125..b622728 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
@@ -91,7 +91,8 @@ public class HttpPropertyProviderTest {
Map<String, String> map = new HashMap<String, String>();
map.put("yarn.http.policy", "HTTPS_ONLY");
-
+ map.put("yarn.resourcemanager.webapp.https.address", "ec2-54-234-33-50.compute-1.amazonaws.com:8999");
+ map.put("yarn.resourcemanager.webapp.address", "ec2-54-234-33-50.compute-1.amazonaws.com:8088");
expect(injector.getInstance(Clusters.class)).andReturn(clusters);
expect(clusters.getCluster("testCluster")).andReturn(cluster);
@@ -119,11 +120,62 @@ public class HttpPropertyProviderTest {
propProvider.populateResources(Collections.singleton(resource), request, null);
Assert.assertTrue(resource.getPropertiesMap().get("HostRoles").get("ha_state").equals("ACTIVE"));
- Assert.assertTrue(streamProvider.getLastSpec().equals("https://ec2-54-234-33-50.compute-1.amazonaws.com:8088" +
+ Assert.assertTrue(streamProvider.getLastSpec().equals("https://ec2-54-234-33-50.compute-1.amazonaws.com:8999" +
"/ws/v1/cluster/info"));
}
@Test
+ public void testReadResourceManagerHA() throws Exception {
+
+ TestStreamProvider streamProvider = new TestStreamProvider(false);
+ Clusters clusters = createNiceMock(Clusters.class);
+ Cluster cluster = createNiceMock(Cluster.class);
+ Injector injector = createNiceMock(Injector.class);
+ Config config1 = createNiceMock(Config.class);
+ Config config2 = createNiceMock(Config.class);
+
+ Map<String, String> map = new HashMap<String, String>();
+ map.put("yarn.http.policy", "HTTPS_ONLY");
+ map.put("yarn.resourcemanager.ha.rm-ids", "rm1,rm2");
+ map.put("yarn.resourcemanager.hostname.rm1", "lc6402.ambari.apache.org");
+ map.put("yarn.resourcemanager.hostname.rm2", "lc6403.ambari.apache.org");
+ map.put("yarn.resourcemanager.webapp.address.rm1", "lc6402.ambari.apache.org:8099");
+ map.put("yarn.resourcemanager.webapp.address.rm2", "lc6403.ambari.apache.org:8099");
+ map.put("yarn.resourcemanager.webapp.https.address.rm1", "lc6402.ambari.apache.org:8066");
+ map.put("yarn.resourcemanager.webapp.https.address.rm2", "lc6403.ambari.apache.org:8066");
+
+ expect(injector.getInstance(Clusters.class)).andReturn(clusters);
+ expect(clusters.getCluster("testCluster")).andReturn(cluster);
+ expect(cluster.getDesiredConfigByType("yarn-site")).andReturn(config1).anyTimes();
+ expect(cluster.getDesiredConfigByType("core-site")).andReturn(config2).anyTimes();
+ expect(config1.getProperties()).andReturn(map).anyTimes();
+ expect(config2.getProperties()).andReturn(new HashMap<String, String>()).anyTimes();
+
+ replay(injector, clusters, cluster, config1, config2);
+
+ HttpProxyPropertyProvider propProvider = new HttpProxyPropertyProvider(
+ streamProvider, configuration, injector,
+ PROPERTY_ID_CLUSTER_NAME,
+ PROPERTY_ID_HOST_NAME,
+ PROPERTY_ID_COMPONENT_NAME);
+
+ Resource resource = new ResourceImpl(Resource.Type.HostComponent);
+
+ resource.setProperty(PROPERTY_ID_HOST_NAME, "lc6402.ambari.apache.org");
+ resource.setProperty(PROPERTY_ID_CLUSTER_NAME, "testCluster");
+ resource.setProperty(PROPERTY_ID_COMPONENT_NAME, "RESOURCEMANAGER");
+
+ Request request = PropertyHelper.getReadRequest(Collections.<String>emptySet());
+
+ propProvider.populateResources(Collections.singleton(resource), request, null);
+
+ Assert.assertTrue(resource.getPropertiesMap().get("HostRoles").get("ha_state").equals("ACTIVE"));
+ Assert.assertTrue(streamProvider.getLastSpec().equals("https://lc6402.ambari.apache.org:8066" +
+ "/ws/v1/cluster/info"));
+ }
+
+
+ @Test
public void testReadGangliaServer() throws Exception {
Resource resource = doPopulate("GANGLIA_SERVER",
Collections.<String> emptySet(), new TestStreamProvider(false));
[3/4] ambari git commit: AMBARI-14593. Ambari not showing
active/standby status for Resource manager when custom ports are used
(dgrinenko via dlysnichenko)
Posted by dm...@apache.org.
AMBARI-14593. Ambari not showing active/standby status for Resource manager when custom ports are used (dgrinenko via dlysnichenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/ae780b61
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/ae780b61
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/ae780b61
Branch: refs/heads/trunk
Commit: ae780b6181fbec5fc6d955f873484bdc65883d78
Parents: 35073a2
Author: Lisnichenko Dmitro <dl...@hortonworks.com>
Authored: Mon Jan 11 15:20:14 2016 +0200
Committer: Lisnichenko Dmitro <dl...@hortonworks.com>
Committed: Mon Jan 11 15:20:14 2016 +0200
----------------------------------------------------------------------
.../ambari/server/controller/internal/HostResourceProvider.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/ae780b61/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostResourceProvider.java
index 9bc4ab3..da73f15 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostResourceProvider.java
@@ -876,7 +876,7 @@ public class HostResourceProvider extends AbstractControllerResourceProvider {
// Assume the user also wants to delete it entirely, including all clusters.
clusters.deleteHost(hostRequest.getHostname());
- for (LogicalRequest logicalRequest: topologyManager.getRequests(Collections.EMPTY_LIST)) {
+ for (LogicalRequest logicalRequest: topologyManager.getRequests(Collections.<Long>emptyList())) {
logicalRequest.removeHostRequestByHostName(hostRequest.getHostname());
}