Repository: hive
Updated Branches:
  refs/heads/branch-1.2 66fd257c6 -> 229c512e6


HIVE-13017: Child process of HiveServer2 fails to get delegation token from non 
default FileSystem (Sushanth Sowmyan reviewed by Thejas Nair)


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

Branch: refs/heads/branch-1.2
Commit: 229c512e625ff2e496564aed0f83b431df3c0b33
Parents: 66fd257
Author: Vaibhav Gumashta <vgumas...@hortonworks.com>
Authored: Fri Mar 17 13:20:37 2017 -0700
Committer: Vaibhav Gumashta <vgumas...@hortonworks.com>
Committed: Fri Mar 17 13:20:37 2017 -0700

----------------------------------------------------------------------
 .../hadoop/hive/ql/exec/SecureCmdDoAs.java      | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/229c512e/ql/src/java/org/apache/hadoop/hive/ql/exec/SecureCmdDoAs.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/SecureCmdDoAs.java 
b/ql/src/java/org/apache/hadoop/hive/ql/exec/SecureCmdDoAs.java
index 974c74e..e1228cc 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/SecureCmdDoAs.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/SecureCmdDoAs.java
@@ -19,6 +19,8 @@ package org.apache.hadoop.hive.ql.exec;
 
 import java.io.File;
 import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.util.Map;
 
 import org.apache.hadoop.fs.FileSystem;
@@ -28,6 +30,8 @@ import org.apache.hadoop.hive.ql.metadata.HiveException;
 import org.apache.hadoop.hive.shims.ShimLoader;
 import org.apache.hadoop.security.Credentials;
 import org.apache.hadoop.security.UserGroupInformation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * SecureCmdDoAs - Helper class for setting parameters and env necessary for
@@ -36,6 +40,9 @@ import org.apache.hadoop.security.UserGroupInformation;
  *
  */
 public class SecureCmdDoAs {
+
+  private static final Logger LOG = 
LoggerFactory.getLogger(SecureCmdDoAs.class);
+
   private final Path tokenPath;
   private final File tokenFile;
 
@@ -45,7 +52,18 @@ public class SecureCmdDoAs {
     String uname = UserGroupInformation.getLoginUser().getShortUserName();
     FileSystem fs = FileSystem.get(conf);
     Credentials cred = new Credentials();
-    ShimLoader.getHadoopShims().addDelegationTokens(fs, cred, uname);
+
+    ShimLoader.getHadoopShims().addDelegationTokens(fs, cred, uname); // ask 
default fs first
+    for (String uri : conf.getStringCollection("mapreduce.job.hdfs-servers")) {
+      try {
+        ShimLoader.getHadoopShims().addDelegationTokens(
+            FileSystem.get(new URI(uri), conf),
+            cred, uname);
+      } catch (URISyntaxException e) {
+        LOG.warn("Invalid URI in mapreduce.job.hdfs-servers:["+uri+"], 
ignoring.", e);
+      }
+    }
+
     tokenFile = File.createTempFile("hive_hadoop_delegation_token", null);
     tokenPath = new Path(tokenFile.toURI());
 

Reply via email to