knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pzamp...@apache.org
Subject knox git commit: KNOX-1352 - Service Discovery is not honoring the enabled attribute of HA Provider configuration
Date Mon, 11 Jun 2018 16:00:08 GMT
Repository: knox
Updated Branches:
  refs/heads/master 138a99bed -> db5080072


KNOX-1352 - Service Discovery is not honoring the enabled attribute of HA Provider configuration


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

Branch: refs/heads/master
Commit: db50800726efc6005f1eaea5547d3a9e8bdf514c
Parents: 138a99b
Author: Phil Zampino <pzampino@apache.org>
Authored: Mon Jun 11 11:30:10 2018 -0400
Committer: Phil Zampino <pzampino@apache.org>
Committed: Mon Jun 11 11:48:25 2018 -0400

----------------------------------------------------------------------
 .../simple/SimpleDescriptorHandler.java         |  2 +-
 .../simple/SimpleDescriptorHandlerTest.java     | 29 ++++++++++++++++++++
 2 files changed, 30 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/db508007/gateway-server/src/main/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorHandler.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorHandler.java
b/gateway-server/src/main/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorHandler.java
index 19521e3..f3bc172 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorHandler.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorHandler.java
@@ -502,7 +502,7 @@ public class SimpleDescriptorHandler {
                 }
 
                 // If the service is configured for ZooKeeper-based HA
-                if (zkConf != null && zkConf.getEnsemble() != null) {
+                if (zkConf != null && zkConf.getEnsemble() != null && isServiceHaEnabled)
{
                     String ensemble = zkConf.getEnsemble();
                     if (ensemble != null && !ensemble.isEmpty()) {
                         params.put("zookeeperEnsemble", ensemble);

http://git-wip-us.apache.org/repos/asf/knox/blob/db508007/gateway-server/src/test/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorHandlerTest.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorHandlerTest.java
b/gateway-server/src/test/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorHandlerTest.java
index ec78155..58a6c72 100644
--- a/gateway-server/src/test/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorHandlerTest.java
+++ b/gateway-server/src/test/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorHandlerTest.java
@@ -126,6 +126,7 @@ public class SimpleDescriptorHandlerTest {
             "            <param><name>WEBHDFS</name><value>enabled=true;retrySleep=40;maxRetryAttempts=5</value></param>\n"
+
             "            <param><name>WEBHBASE</name><value>enabled=auto;retrySleep=30;maxRetryAttempts=3;maxFailoverAttempts=2;failoverSleep=10</value></param>\n"
+
             "            <param><name>ATLAS</name><value>enabled=auto;retrySleep=30;maxRetryAttempts=3;maxFailoverAttempts=2;failoverSleep=10</value></param>\n"
+
+            "            <param><name>ATLAS-API</name><value>enabled=false</value></param>\n"
+
             "        </provider>\n" +
             "    </gateway>\n";
 
@@ -556,6 +557,8 @@ public class SimpleDescriptorHandlerTest {
         DISCOVERY_PROPERTIES.setProperty(clusterName + ".WEBHBASE.ensemble", WEBHBASE_HA_ENSEMBLE);
         DISCOVERY_PROPERTIES.setProperty(clusterName + ".ATLAS.haEnabled", ATLAS_HA_ENABLED);
         DISCOVERY_PROPERTIES.setProperty(clusterName + ".ATLAS.ensemble", ATLAS_HA_ENSEMBLE);
+        DISCOVERY_PROPERTIES.setProperty(clusterName + ".ATLAS-API.ensemble", ATLAS_HA_ENSEMBLE);
+        DISCOVERY_PROPERTIES.setProperty(clusterName + ".ATLAS-API.url", "http://atlasapihost:2222");
 
         try {
             DISCOVERY_PROPERTIES.store(new FileOutputStream(discoveryConfig), null);
@@ -568,6 +571,7 @@ public class SimpleDescriptorHandlerTest {
         serviceURLs.put("WEBHDFS", null);
         serviceURLs.put("RESOURCEMANAGER", null);
         serviceURLs.put("ATLAS", null);
+        serviceURLs.put("ATLAS-API", null);
         serviceURLs.put("HIVE", null);
 
         // Write the externalized provider config to a temp file
@@ -708,6 +712,31 @@ public class SimpleDescriptorHandlerTest {
                     assertNull(atlasServiceParams.get("zookeeperNamespace"));
                 }
 
+                // Validate the ATLAS service params
+                if ("ATLAS-API".equals(role)) {
+                    // Expecting non-HA-related service params
+                    NodeList paramNodes = (NodeList) xpath.compile("param").evaluate(serviceNode,
XPathConstants.NODESET);
+                    assertNotNull(paramNodes);
+                    Map<String, String> atlasApiServiceParams = new HashMap<>();
+                    for (int paramNodeIndex=0; paramNodeIndex < paramNodes.getLength();
paramNodeIndex++) {
+                        Node paramNode = paramNodes.item(paramNodeIndex);
+                        Node nameNode = (Node) xpath.compile("name/text()").evaluate(paramNode,
XPathConstants.NODE);
+                        assertNotNull(nameNode);
+                        Node valueNode = (Node) xpath.compile("value/text()").evaluate(paramNode,
XPathConstants.NODE);
+                        assertNotNull(valueNode);
+                        atlasApiServiceParams.put(nameNode.getNodeValue(), valueNode.getNodeValue());
+                    }
+                    // There should be no HA-related params because the enabled attribute
is false
+                    assertNull(atlasApiServiceParams.get("zookeeperEnsemble"));
+                    assertNull(atlasApiServiceParams.get("zookeeperNamespace"));
+
+                    // Instead, the URL should be declared for the service
+                    NodeList urlNodes = (NodeList) xpath.compile("url").evaluate(serviceNode,
XPathConstants.NODESET);
+                    assertNotNull(urlNodes);
+                    assertEquals(1, urlNodes.getLength());
+                    assertEquals(DISCOVERY_PROPERTIES.getProperty(clusterName + ".ATLAS-API.url"),
urlNodes.item(0).getTextContent());
+                }
+
                 // Validate the URLs
                 NodeList urlNodes = (NodeList) xpath.compile("url/text()").evaluate(serviceNode,
XPathConstants.NODESET);
                 for(int urlNodeIndex = 0 ; urlNodeIndex < urlNodes.getLength(); urlNodeIndex++)
{


Mime
View raw message