You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by se...@apache.org on 2016/04/08 20:53:37 UTC

[2/2] hive git commit: HIVE-13428 : ZK SM in LLAP should have unique paths per cluster (Sergey Shelukhin, reviewed by Siddharth Seth)

HIVE-13428 : ZK SM in LLAP should have unique paths per cluster (Sergey Shelukhin, reviewed by Siddharth Seth)


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

Branch: refs/heads/branch-2.0
Commit: c66c7cb28011c2152e4949433d831aff6c121529
Parents: b2b61da
Author: Sergey Shelukhin <se...@apache.org>
Authored: Fri Apr 8 11:34:47 2016 -0700
Committer: Sergey Shelukhin <se...@apache.org>
Committed: Fri Apr 8 11:53:23 2016 -0700

----------------------------------------------------------------------
 .../hadoop/hive/llap/security/SecretManager.java  | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/c66c7cb2/llap-server/src/java/org/apache/hadoop/hive/llap/security/SecretManager.java
----------------------------------------------------------------------
diff --git a/llap-server/src/java/org/apache/hadoop/hive/llap/security/SecretManager.java b/llap-server/src/java/org/apache/hadoop/hive/llap/security/SecretManager.java
index bbdca7b..8c7a539 100644
--- a/llap-server/src/java/org/apache/hadoop/hive/llap/security/SecretManager.java
+++ b/llap-server/src/java/org/apache/hadoop/hive/llap/security/SecretManager.java
@@ -18,6 +18,7 @@ import java.io.DataInputStream;
 import java.io.IOException;
 import java.security.PrivilegedAction;
 import java.util.concurrent.TimeUnit;
+import java.util.regex.Pattern;
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hive.conf.HiveConf;
@@ -81,6 +82,14 @@ public class SecretManager extends ZKDelegationTokenSecretManager<LlapTokenIdent
     return id;
   }
 
+  private final static Pattern hostsRe = Pattern.compile("[^A-Za-z0-9_-]");
+  private static String deriveZkPath(Configuration conf) throws IOException {
+    String hosts = HiveConf.getTrimmedVar(conf, ConfVars.LLAP_DAEMON_SERVICE_HOSTS);
+    String clusterName = hosts.startsWith("@") ? hosts.substring(1) : hosts;
+    String userName = UserGroupInformation.getCurrentUser().getShortUserName();
+    return hostsRe.matcher(userName + "_" + clusterName).replaceAll("_") ;
+  }
+
   public static SecretManager createSecretManager(
       final Configuration conf, String llapPrincipal, String llapKeytab) {
     // Create ZK connection under a separate ugi (if specified) - ZK works in mysterious ways.
@@ -101,7 +110,14 @@ public class SecretManager extends ZKDelegationTokenSecretManager<LlapTokenIdent
     zkConf.setLong(DelegationTokenManager.RENEW_INTERVAL, tokenLifetime);
     zkConf.set(SecretManager.ZK_DTSM_ZK_KERBEROS_PRINCIPAL, principal);
     zkConf.set(SecretManager.ZK_DTSM_ZK_KERBEROS_KEYTAB, keyTab);
-    setZkConfIfNotSet(zkConf, SecretManager.ZK_DTSM_ZNODE_WORKING_PATH, "llapzkdtsm");
+    String zkPath;
+    try {
+      zkPath = deriveZkPath(conf);
+    } catch (IOException e) {
+      throw new RuntimeException(e);
+    }
+    LOG.info("Using {} as ZK secret manager path", zkPath);
+    zkConf.set(SecretManager.ZK_DTSM_ZNODE_WORKING_PATH, "zkdtsm_" + zkPath);
     setZkConfIfNotSet(zkConf, SecretManager.ZK_DTSM_ZK_AUTH_TYPE, "sasl");
     setZkConfIfNotSet(zkConf, SecretManager.ZK_DTSM_ZK_CONNECTION_STRING,
         HiveConf.getVar(zkConf, ConfVars.LLAP_ZKSM_ZK_CONNECTION_STRING));