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-1231 - Atlas HA URL Manager must handle ZooKeeeper namespaces that begin with leading slash
Date Fri, 30 Mar 2018 13:10:42 GMT
Repository: knox
Updated Branches:
  refs/heads/master a587795d4 -> c7f28551f


KNOX-1231 - Atlas HA URL Manager must handle ZooKeeeper namespaces that begin with leading
slash


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

Branch: refs/heads/master
Commit: c7f28551f9489d7327792ec97f032ac932016af9
Parents: a587795
Author: Phil Zampino <pzampino@apache.org>
Authored: Thu Mar 29 15:18:07 2018 -0400
Committer: Phil Zampino <pzampino@apache.org>
Committed: Thu Mar 29 15:18:07 2018 -0400

----------------------------------------------------------------------
 .../provider/impl/AtlasZookeeperURLManager.java |  6 ++--
 .../impl/AtlasZookeeperURLManagerTest.java      | 34 +++++++++++++-------
 2 files changed, 27 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/c7f28551/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/impl/AtlasZookeeperURLManager.java
----------------------------------------------------------------------
diff --git a/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/impl/AtlasZookeeperURLManager.java
b/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/impl/AtlasZookeeperURLManager.java
index 0f28c37..9eaf2b8 100644
--- a/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/impl/AtlasZookeeperURLManager.java
+++ b/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/provider/impl/AtlasZookeeperURLManager.java
@@ -52,6 +52,9 @@ public class AtlasZookeeperURLManager extends DefaultURLManager {
     public void setConfig(HaServiceConfig config) {
         zooKeeperEnsemble = config.getZookeeperEnsemble();
         zooKeeperNamespace = config.getZookeeperNamespace();
+        if (!zooKeeperNamespace.startsWith("/")) {
+            zooKeeperNamespace = "/" + zooKeeperNamespace;
+        }
         setURLs(lookupURLs());
     }
 
@@ -63,10 +66,9 @@ public class AtlasZookeeperURLManager extends DefaultURLManager {
                                                  .retryPolicy(new ExponentialBackoffRetry(1000,
3))
                                                  .build();
         try {
-
             zooKeeperClient.start();
 
-            byte[] bytes = zooKeeperClient.getData().forPath("/" + zooKeeperNamespace + APACHE_ATLAS_ACTIVE_SERVER_INFO);
+            byte[] bytes = zooKeeperClient.getData().forPath(zooKeeperNamespace + APACHE_ATLAS_ACTIVE_SERVER_INFO);
 
             String activeURL = new String(bytes, Charset.forName("UTF-8"));
 

http://git-wip-us.apache.org/repos/asf/knox/blob/c7f28551/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/provider/impl/AtlasZookeeperURLManagerTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/provider/impl/AtlasZookeeperURLManagerTest.java
b/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/provider/impl/AtlasZookeeperURLManagerTest.java
index 56f4061..e0b805c 100644
--- a/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/provider/impl/AtlasZookeeperURLManagerTest.java
+++ b/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/provider/impl/AtlasZookeeperURLManagerTest.java
@@ -93,26 +93,38 @@ public class AtlasZookeeperURLManagerTest {
 
     @Test
     public void testAtlasURLManagerLoadingForAtlasApiService() {
-        HaServiceConfig config = new DefaultHaServiceConfig("ATLAS-API");
-        config.setEnabled(true);
-        config.setZookeeperEnsemble(cluster.getConnectString());
-        config.setZookeeperNamespace("apache_atlas");
-        URLManager manager = URLManagerLoader.loadURLManager(config);
-        Assert.assertNotNull(manager);
-        Assert.assertTrue(manager instanceof AtlasZookeeperURLManager);
+        doTestAtlasZooKeeperURLManager("ATLAS-API", true, cluster.getConnectString(), "apache_atlas");
     }
 
     @Test
     public void testAtlasURLManagerLoadingForAtlasUIService() {
-        HaServiceConfig config = new DefaultHaServiceConfig("ATLAS");
-        config.setEnabled(true);
-        config.setZookeeperEnsemble(cluster.getConnectString());
-        config.setZookeeperNamespace("apache_atlas");
+        doTestAtlasZooKeeperURLManager("ATLAS", true, cluster.getConnectString(), "apache_atlas");
+    }
+
+    @Test
+    public void testAtlasURLManagerWithLeadingSlashNamespace() {
+        doTestAtlasZooKeeperURLManager("ATLAS", true, cluster.getConnectString(), "/apache_atlas");
+    }
+
+    @Test
+    public void testAtlasAPIURLManagerWithLeadingSlashNamespace() {
+        doTestAtlasZooKeeperURLManager("ATLAS-API", true, cluster.getConnectString(), "/apache_atlas");
+    }
+
+    private void doTestAtlasZooKeeperURLManager(final String  serviceName,
+                                                final boolean enabled,
+                                                final String  ensemble,
+                                                final String  namespace) {
+        HaServiceConfig config = new DefaultHaServiceConfig(serviceName);
+        config.setEnabled(enabled);
+        config.setZookeeperEnsemble(ensemble);
+        config.setZookeeperNamespace(namespace);
         URLManager manager = URLManagerLoader.loadURLManager(config);
         Assert.assertNotNull(manager);
         Assert.assertTrue(manager instanceof AtlasZookeeperURLManager);
     }
 
+
     void setAtlasActiveHostURLInZookeeper(String activeURL) throws Exception {
 
         CuratorFramework zooKeeperClient =


Mime
View raw message