sentry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ak...@apache.org
Subject sentry git commit: SENTRY-1692: ZK namespace configuration doesn't work (Alex Kolbasov, reviewed by Na Li)
Date Wed, 05 Apr 2017 02:19:29 GMT
Repository: sentry
Updated Branches:
  refs/heads/sentry-ha-redesign 9739dd80a -> f0f77668b


SENTRY-1692: ZK namespace configuration doesn't work (Alex Kolbasov, reviewed by Na Li)


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

Branch: refs/heads/sentry-ha-redesign
Commit: f0f77668b3e8468d00f61de10897db80ce382929
Parents: 9739dd8
Author: Alexander Kolbasov <akolb@cloudera.com>
Authored: Tue Apr 4 19:18:56 2017 -0700
Committer: Alexander Kolbasov <akolb@cloudera.com>
Committed: Tue Apr 4 19:19:22 2017 -0700

----------------------------------------------------------------------
 .../sentry/provider/db/service/persistent/HAContext.java    | 7 +++++--
 .../apache/sentry/service/thrift/LeaderStatusMonitor.java   | 9 ++-------
 2 files changed, 7 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sentry/blob/f0f77668/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/HAContext.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/HAContext.java
b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/HAContext.java
index 00eec4e..e0f8a9e 100644
--- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/HAContext.java
+++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/HAContext.java
@@ -73,8 +73,11 @@ public final class HAContext implements AutoCloseable {
             SENTRY_HA_ZOOKEEPER_RETRIES_MAX_COUNT_DEFAULT);
     int sleepMsBetweenRetries = conf.getInt(SENTRY_HA_ZOOKEEPER_SLEEP_BETWEEN_RETRIES_MS,
             SENTRY_HA_ZOOKEEPER_SLEEP_BETWEEN_RETRIES_MS_DEFAULT);
-    this.namespace = conf.get(SENTRY_HA_ZOOKEEPER_NAMESPACE,
-        SENTRY_HA_ZOOKEEPER_NAMESPACE_DEFAULT);
+    String ns = conf.get(SENTRY_HA_ZOOKEEPER_NAMESPACE, SENTRY_HA_ZOOKEEPER_NAMESPACE_DEFAULT);
+    // Namespace shouldn't start with slash.
+    // If config namespace starts with slash, remove it first
+    this.namespace = ns.startsWith("/") ? ns.substring(1) : ns;
+
     this.zkSecure = conf.getBoolean(SENTRY_HA_ZOOKEEPER_SECURITY,
         SENTRY_HA_ZOOKEEPER_SECURITY_DEFAULT);
     this.validateConf();

http://git-wip-us.apache.org/repos/asf/sentry/blob/f0f77668/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/LeaderStatusMonitor.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/LeaderStatusMonitor.java
b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/LeaderStatusMonitor.java
index 1d79bd1..f78118c 100644
--- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/LeaderStatusMonitor.java
+++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/LeaderStatusMonitor.java
@@ -93,7 +93,6 @@ final class LeaderStatusMonitor
   /** Unique instance of the singleton object */
   private static LeaderStatusMonitor leaderStatusMonitor = null;
 
-  private final String zkNamespace;
   private final HAContext haContext;
 
   /** Unique string describing this instance */
@@ -120,7 +119,6 @@ final class LeaderStatusMonitor
    * specifies ZooKeeper servers.
    * @param conf Configuration. The fields we are interested in are:
    *             <ul>
-   *             <li>SENTRY_HA_ZOOKEEPER_NAMESPACE</li>
    *             <li>SENTRY_HA_ZOOKEEPER_QUORUM</li>
    *             </ul>
    *             Configuration is also passed to the
@@ -130,7 +128,6 @@ final class LeaderStatusMonitor
    */
   private LeaderStatusMonitor(Configuration conf) throws Exception {
     // Only enable HA configuration if zookeeper is configured
-    zkNamespace = conf.get(SENTRY_HA_ZOOKEEPER_NAMESPACE, "");
     String zkServers = conf.get(SENTRY_HA_ZOOKEEPER_QUORUM, "");
     if (zkServers.isEmpty()) {
       isSingleNodeMode = true;
@@ -142,8 +139,7 @@ final class LeaderStatusMonitor
     isSingleNodeMode = false;
     haContext = HAContext.getHAServerContext(conf);
 
-    LOG.info("Created LeaderStatusMonitor(zkNamespace=" + zkNamespace +
-        ", incarnationId=" + incarnationId +
+    LOG.info("Created LeaderStatusMonitor(incarnationId=" + incarnationId +
         ", zkServers='" + zkServers + "')");
   }
 
@@ -156,8 +152,7 @@ final class LeaderStatusMonitor
       return;
     }
 
-    leaderSelector = haContext.newLeaderSelector(zkNamespace + "/" +
-            LEADER_SELECTOR_SUFFIX, this);
+    leaderSelector = haContext.newLeaderSelector("/" + LEADER_SELECTOR_SUFFIX, this);
     leaderSelector.setId(incarnationId);
     leaderSelector.autoRequeue();
     leaderSelector.start();


Mime
View raw message