Repository: ambari Updated Branches: refs/heads/branch-2.5 e348f6521 -> 356349697
AMBARI-20305. All HBase Masters listed as in standby if Hbase ssl is enabled (dsen via smohanty) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/35634969 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/35634969 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/35634969 Branch: refs/heads/branch-2.5 Commit: 356349697c10cb76c43bdfdc55bd0c58e8147465 Parents: e348f65 Author: Sumit Mohanty <[email protected]> Authored: Fri Mar 3 19:11:05 2017 -0800 Committer: Sumit Mohanty <[email protected]> Committed: Fri Mar 3 19:13:54 2017 -0800 ---------------------------------------------------------------------- .../internal/AbstractProviderModule.java | 21 +++++++------ .../internal/JMXHostProviderTest.java | 33 ++++++++++++++++++++ 2 files changed, 45 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/35634969/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 a37b873..3eae675 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 @@ -175,11 +175,11 @@ public abstract class AbstractProviderModule implements ProviderModule, jmxDesiredProperties.put("RESOURCEMANAGER", initPropMap); initPropMap = new HashMap<String, String[]>(); - initPropMap.put("HBASE_MASTER", new String[]{"hbase.http.policy"}); + initPropMap.put("HBASE_MASTER", new String[]{"hbase.ssl.enabled"}); jmxDesiredProperties.put("HBASE_MASTER", initPropMap); initPropMap = new HashMap<String, String[]>(); - initPropMap.put("HBASE_REGIONSERVER", new String[]{"hbase.http.policy"}); + initPropMap.put("HBASE_REGIONSERVER", new String[]{"hbase.ssl.enabled"}); jmxDesiredProperties.put("HBASE_REGIONSERVER", initPropMap); initPropMap = new HashMap<String, String[]>(); @@ -1130,7 +1130,14 @@ public abstract class AbstractProviderModule implements ProviderModule, clusterName, newSiteConfigVersion, config, jmxDesiredProperties.get(componentName)); - jmxProtocolString = getJMXProtocolString(protocolMap.get(componentName)); + boolean isHttpsEnabled; + String propetyVal = protocolMap.get(componentName); + if (service.equals(Service.Type.HBASE)) { + isHttpsEnabled = Boolean.valueOf(propetyVal); + } else { + isHttpsEnabled = PROPERTY_HDFS_HTTP_POLICY_VALUE_HTTPS_ONLY.equals(propetyVal); + } + jmxProtocolString = getJMXProtocolStringFromBool(isHttpsEnabled); } } else { jmxProtocolString = "http"; @@ -1158,12 +1165,8 @@ public abstract class AbstractProviderModule implements ProviderModule, return jmxProtocolString; } - private String getJMXProtocolString(String value) { - if (PROPERTY_HDFS_HTTP_POLICY_VALUE_HTTPS_ONLY.equals(value)) { - return "https"; - } else { - return "http"; - } + private String getJMXProtocolStringFromBool(boolean isHttpsEnabled) { + return isHttpsEnabled ? "https" : "http"; } @Override http://git-wip-us.apache.org/repos/asf/ambari/blob/35634969/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 270d50a..4a57092 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 @@ -228,10 +228,12 @@ public class JMXHostProviderTest { String serviceName = "HDFS"; String serviceName2 = "YARN"; String serviceName3 = "MAPREDUCE2"; + String serviceName4 = "HBASE"; createService(clusterName, serviceName, null); createService(clusterName, serviceName2, null); createService(clusterName, serviceName3, null); + createService(clusterName, serviceName4, null); String componentName1 = "NAMENODE"; String componentName2 = "DATANODE"; @@ -240,6 +242,8 @@ public class JMXHostProviderTest { String componentName5 = "JOURNALNODE"; String componentName6 = "HISTORYSERVER"; String componentName7 = "NODEMANAGER"; + String componentName8 = "HBASE_MASTER"; + String componentName9 = "HBASE_REGIONSERVER"; createServiceComponent(clusterName, serviceName, componentName1, State.INIT); @@ -255,6 +259,10 @@ public class JMXHostProviderTest { State.INIT); createServiceComponent(clusterName, serviceName2, componentName7, State.INIT); + createServiceComponent(clusterName, serviceName4, componentName8, + State.INIT); + createServiceComponent(clusterName, serviceName4, componentName9, + State.INIT); String host1 = "h1"; clusters.addHost(host1); @@ -291,6 +299,10 @@ public class JMXHostProviderTest { host2, null); createServiceComponentHost(clusterName, serviceName2, componentName7, host2, null); + createServiceComponentHost(clusterName, serviceName4, componentName8, + host1, null); + createServiceComponentHost(clusterName, serviceName4, componentName9, + host2, null); // Create configs Map<String, String> configs = new HashMap<String, String>(); @@ -312,6 +324,9 @@ public class JMXHostProviderTest { mapreduceConfigs.put(MAPREDUCE_HTTPS_PORT, "19889"); mapreduceConfigs.put(MAPREDUCE_HTTPS_POLICY, "HTTPS_ONLY"); + Map<String, String> hbaseConfigs = new HashMap<String, String>(); + hbaseConfigs.put("hbase.ssl.enabled", "true"); + ConfigurationRequest cr1 = new ConfigurationRequest(clusterName, "hdfs-site", "versionN", configs, null); @@ -332,6 +347,11 @@ public class JMXHostProviderTest { crReq.setDesiredConfig(Collections.singletonList(cr3)); controller.updateClusters(Collections.singleton(crReq), null); + ConfigurationRequest cr4 = new ConfigurationRequest(clusterName, + "hbase-site", "versionN", hbaseConfigs, null); + crReq.setDesiredConfig(Collections.singletonList(cr4)); + controller.updateClusters(Collections.singleton(crReq), null); + Assert.assertEquals("versionN", cluster.getDesiredConfigByType("yarn-site") .getTag()); Assert.assertEquals("localhost:${ambari.dfs.datanode.http.port}", cluster.getDesiredConfigByType @@ -566,6 +586,19 @@ public class JMXHostProviderTest { } @Test + public void testJMXHbaseMasterHttps() throws + NoSuchParentResourceException, + ResourceAlreadyExistsException, UnsupportedPropertyException, + SystemException, AmbariException, NoSuchResourceException { + createConfigs(); + JMXHostProviderModule providerModule = new JMXHostProviderModule(controller); + providerModule.registerResourceProvider(Resource.Type.Cluster); + providerModule.registerResourceProvider(Resource.Type.Configuration); + Assert.assertEquals("https", providerModule.getJMXProtocol("c1", "HBASE_MASTER")); + Assert.assertEquals("https", providerModule.getJMXProtocol("c1", "HBASE_REGIONSERVER")); + } + + @Test public void testJMXPortMapUpdate() throws NoSuchParentResourceException, ResourceAlreadyExistsException, UnsupportedPropertyException,
