knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kris...@apache.org
Subject [knox] branch master updated: KNOX-2238 CM discovery - Add TLS support to Phoenix auto discovery (#267)
Date Thu, 20 Feb 2020 20:48:41 GMT
This is an automated email from the ASF dual-hosted git repository.

krisden pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/knox.git


The following commit(s) were added to refs/heads/master by this push:
     new 7d4e997  KNOX-2238 CM discovery - Add TLS support to Phoenix auto discovery (#267)
7d4e997 is described below

commit 7d4e997465eed2f01ad013618a36eba0bf5ae261
Author: Istvan Toth <stoty@apache.org>
AuthorDate: Thu Feb 20 21:48:35 2020 +0100

    KNOX-2238 CM discovery - Add TLS support to Phoenix auto discovery (#267)
---
 .../cm/model/phoenix/PhoenixServiceModelGenerator.java    | 15 ++++++++++++---
 .../discovery/cm/ClouderaManagerServiceDiscoveryTest.java | 12 ++++++++++++
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/gateway-discovery-cm/src/main/java/org/apache/knox/gateway/topology/discovery/cm/model/phoenix/PhoenixServiceModelGenerator.java
b/gateway-discovery-cm/src/main/java/org/apache/knox/gateway/topology/discovery/cm/model/phoenix/PhoenixServiceModelGenerator.java
index e6e157d..ea59a77 100644
--- a/gateway-discovery-cm/src/main/java/org/apache/knox/gateway/topology/discovery/cm/model/phoenix/PhoenixServiceModelGenerator.java
+++ b/gateway-discovery-cm/src/main/java/org/apache/knox/gateway/topology/discovery/cm/model/phoenix/PhoenixServiceModelGenerator.java
@@ -31,7 +31,8 @@ public class PhoenixServiceModelGenerator extends AbstractServiceModelGenerator
   public static final String SERVICE_TYPE = "PHOENIX";
   public static final String ROLE_TYPE    = "PHOENIX_QUERY_SERVER";
 
-  static final String QUERY_SERVER_PORT = "phoenix_query_server_port";
+  static final String SSL_ENABLED         = "ssl_enabled";
+  static final String QUERY_SERVER_PORT   = "phoenix_query_server_port";
 
   @Override
   public String getService() {
@@ -58,14 +59,22 @@ public class PhoenixServiceModelGenerator extends AbstractServiceModelGenerator
                                       ApiServiceConfig serviceConfig,
                                       ApiRole          role,
                                       ApiConfigList    roleConfig) {
+
     String hostname = role.getHostRef().getHostname();
-    // Phoenix Query Server does not support https
+    String sslEnabledRaw = getRoleConfigValue(roleConfig, SSL_ENABLED);
     String scheme = "http";
+
+    if (Boolean.parseBoolean(sslEnabledRaw)) {
+      scheme = "https";
+    }
+
     String port = getRoleConfigValue(roleConfig, QUERY_SERVER_PORT);
 
     ServiceModel model = createServiceModel(String.format(Locale.getDefault(), "%s://%s:%s",
scheme, hostname, port));
     model.addRoleProperty(getRoleType(), QUERY_SERVER_PORT, port);
-
+    if (sslEnabledRaw != null) {
+        model.addRoleProperty(getRoleType(), SSL_ENABLED, sslEnabledRaw);
+    }
     return model;
   }
 
diff --git a/gateway-discovery-cm/src/test/java/org/apache/knox/gateway/topology/discovery/cm/ClouderaManagerServiceDiscoveryTest.java
b/gateway-discovery-cm/src/test/java/org/apache/knox/gateway/topology/discovery/cm/ClouderaManagerServiceDiscoveryTest.java
index 2ae3b85..1f64a70 100644
--- a/gateway-discovery-cm/src/test/java/org/apache/knox/gateway/topology/discovery/cm/ClouderaManagerServiceDiscoveryTest.java
+++ b/gateway-discovery-cm/src/test/java/org/apache/knox/gateway/topology/discovery/cm/ClouderaManagerServiceDiscoveryTest.java
@@ -367,6 +367,18 @@ public class ClouderaManagerServiceDiscoveryTest {
   }
 
   @Test
+  public void testPhoenixDiscoverySSL() {
+    final String hostName    = "phoenix-host";
+    final String port        = "8765";
+    ServiceDiscovery.Cluster cluster = doTestPhoenixDiscovery(hostName, port, true);
+    assertNotNull(cluster);
+    List<String> phoenixURLs = cluster.getServiceURLs("AVATICA");
+    assertNotNull(phoenixURLs);
+    assertEquals(1, phoenixURLs.size());
+    assertEquals("https://" + hostName + ":" + port, phoenixURLs.get(0));
+  }
+
+  @Test
   public void testWebHCatDiscovery() {
     final String hostName = "webhcat-host";
     final String port     = "22222";


Mime
View raw message