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-1248 - AtlasZookeeperURLManager handle missing namespace property from Atlas config with appropriate default value
Date Tue, 17 Apr 2018 17:42:35 GMT
Repository: knox
Updated Branches:
  refs/heads/master 20d018ced -> 5db4c8c13


KNOX-1248 - AtlasZookeeperURLManager handle missing namespace property from Atlas config with
appropriate default value


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

Branch: refs/heads/master
Commit: 5db4c8c13c54f63ee396f13deedabacea1bc6ad7
Parents: 20d018c
Author: Phil Zampino <pzampino@apache.org>
Authored: Tue Apr 17 13:25:46 2018 -0400
Committer: Phil Zampino <pzampino@apache.org>
Committed: Tue Apr 17 13:25:46 2018 -0400

----------------------------------------------------------------------
 .../ha/provider/impl/AtlasZookeeperURLManager.java | 17 +++++++++++------
 .../impl/AtlasZookeeperURLManagerTest.java         | 10 ++++++++++
 2 files changed, 21 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/5db4c8c1/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 9eaf2b8..2f489a1 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
@@ -29,14 +29,16 @@ import java.nio.charset.Charset;
 import java.util.*;
 
 public class AtlasZookeeperURLManager extends DefaultURLManager {
+    private static final String DEFAULT_ZOOKEEPER_NAMESPACE = "/apache_atlas";
+
+    private static final String APACHE_ATLAS_ACTIVE_SERVER_INFO = "/active_server_info";
+
     private static final HaMessages LOG = MessagesFactory.get(HaMessages.class);
 
     private String zooKeeperEnsemble;
 
     private String zooKeeperNamespace;
 
-    public static final String APACHE_ATLAS_ACTIVE_SERVER_INFO = "/active_server_info";
-
 
     @Override
     public boolean supportsConfig(HaServiceConfig config) {
@@ -44,16 +46,19 @@ public class AtlasZookeeperURLManager extends DefaultURLManager {
             return false;
         }
         String zookeeperEnsemble = config.getZookeeperEnsemble();
-        String zookeeperNamespace = config.getZookeeperNamespace();
-        return zookeeperEnsemble != null && zookeeperNamespace != null &&
!zookeeperEnsemble.trim().isEmpty() && !zookeeperNamespace.trim().isEmpty();
+        return zookeeperEnsemble != null && !zookeeperEnsemble.trim().isEmpty();
     }
 
     @Override
     public void setConfig(HaServiceConfig config) {
         zooKeeperEnsemble = config.getZookeeperEnsemble();
         zooKeeperNamespace = config.getZookeeperNamespace();
-        if (!zooKeeperNamespace.startsWith("/")) {
-            zooKeeperNamespace = "/" + zooKeeperNamespace;
+        if (zooKeeperNamespace != null) {
+            if (!zooKeeperNamespace.startsWith("/")) {
+                zooKeeperNamespace = "/" + zooKeeperNamespace;
+            }
+        } else {
+            zooKeeperNamespace = DEFAULT_ZOOKEEPER_NAMESPACE;
         }
         setURLs(lookupURLs());
     }

http://git-wip-us.apache.org/repos/asf/knox/blob/5db4c8c1/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 e0b805c..6f6c6ce 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
@@ -102,6 +102,16 @@ public class AtlasZookeeperURLManagerTest {
     }
 
     @Test
+    public void testAtlasURLManagerDefaultNamespace() {
+        doTestAtlasZooKeeperURLManager("ATLAS", true, cluster.getConnectString(), null);
+    }
+
+    @Test
+    public void testAtlasAPIURLManagerDefaultNamespace() {
+        doTestAtlasZooKeeperURLManager("ATLAS-API", true, cluster.getConnectString(), null);
+    }
+
+    @Test
     public void testAtlasURLManagerWithLeadingSlashNamespace() {
         doTestAtlasZooKeeperURLManager("ATLAS", true, cluster.getConnectString(), "/apache_atlas");
     }


Mime
View raw message