hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From da...@apache.org
Subject hive git commit: HIVE-15137: metastore add partitions background thread should use current username (Daniel Dai, reviewed by Thejas Nair)
Date Fri, 11 Nov 2016 23:36:17 GMT
Repository: hive
Updated Branches:
  refs/heads/master 623d2921a -> be4fbeba0


HIVE-15137: metastore add partitions background thread should use current username (Daniel
Dai, 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/be4fbeba
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/be4fbeba
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/be4fbeba

Branch: refs/heads/master
Commit: be4fbeba063bfbc0bf7dc53c7191f0f4c3aa9cdb
Parents: 623d292
Author: Daniel Dai <daijy@hortonworks.com>
Authored: Fri Nov 11 15:36:02 2016 -0800
Committer: Daniel Dai <daijy@hortonworks.com>
Committed: Fri Nov 11 15:36:02 2016 -0800

----------------------------------------------------------------------
 .../hadoop/hive/metastore/HiveMetaStore.java    | 67 +++++++++++++++-----
 .../test/results/clientnegative/external2.q.out |  2 +-
 2 files changed, 51 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/be4fbeba/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
----------------------------------------------------------------------
diff --git a/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java b/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
index 09211f4..2a604bf 100644
--- a/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
+++ b/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
@@ -138,6 +138,7 @@ import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.net.UnknownHostException;
 import java.nio.ByteBuffer;
+import java.security.PrivilegedExceptionAction;
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.AbstractMap;
@@ -2384,18 +2385,33 @@ public class HiveMetaStore extends ThriftHiveMetastore {
             continue;
           }
 
-
+          final UserGroupInformation ugi;
+          try {
+            ugi = UserGroupInformation.getCurrentUser();
+          } catch (IOException e) {
+            throw new RuntimeException(e);
+          }
           partFutures.add(threadPool.submit(new Callable() {
             @Override
             public Partition call() throws Exception {
-              boolean madeDir = createLocationForAddedPartition(table, part);
-              if (addedPartitions.put(new PartValEqWrapper(part), madeDir) != null) {
-                // Technically, for ifNotExists case, we could insert one and discard the
other
-                // because the first one now "exists", but it seems better to report the
problem
-                // upstream as such a command doesn't make sense.
-                throw new MetaException("Duplicate partitions in the list: " + part);
-              }
-              initializeAddedPartition(table, part, madeDir);
+              ugi.doAs(new PrivilegedExceptionAction<Object>() {
+                @Override
+                public Object run() throws Exception {
+                  try {
+                    boolean madeDir = createLocationForAddedPartition(table, part);
+                    if (addedPartitions.put(new PartValEqWrapper(part), madeDir) != null)
{
+                      // Technically, for ifNotExists case, we could insert one and discard
the other
+                      // because the first one now "exists", but it seems better to report
the problem
+                      // upstream as such a command doesn't make sense.
+                      throw new MetaException("Duplicate partitions in the list: " + part);
+                    }
+                    initializeAddedPartition(table, part, madeDir);
+                  } catch (MetaException e) {
+                    throw new IOException(e.getMessage(), e);
+                  }
+                  return null;
+                }
+              });
               return part;
             }
           }));
@@ -2547,16 +2563,33 @@ public class HiveMetaStore extends ThriftHiveMetastore {
             LOG.info("Not adding partition " + part + " as it already exists");
             continue;
           }
+
+          final UserGroupInformation ugi;
+          try {
+            ugi = UserGroupInformation.getCurrentUser();
+          } catch (IOException e) {
+            throw new RuntimeException(e);
+          }
           partFutures.add(threadPool.submit(new Callable() {
             @Override public Object call() throws Exception {
-              boolean madeDir = createLocationForAddedPartition(table, part);
-              if (addedPartitions.put(new PartValEqWrapperLite(part), madeDir) != null) {
-                // Technically, for ifNotExists case, we could insert one and discard the
other
-                // because the first one now "exists", but it seems better to report the
problem
-                // upstream as such a command doesn't make sense.
-                throw new MetaException("Duplicate partitions in the list: " + part);
-              }
-              initializeAddedPartition(table, part, madeDir);
+              ugi.doAs(new PrivilegedExceptionAction<Object>() {
+                @Override
+                public Object run() throws Exception {
+                  try {
+                    boolean madeDir = createLocationForAddedPartition(table, part);
+                    if (addedPartitions.put(new PartValEqWrapperLite(part), madeDir) != null)
{
+                      // Technically, for ifNotExists case, we could insert one and discard
the other
+                      // because the first one now "exists", but it seems better to report
the problem
+                      // upstream as such a command doesn't make sense.
+                      throw new MetaException("Duplicate partitions in the list: " + part);
+                    }
+                    initializeAddedPartition(table, part, madeDir);
+                  } catch (MetaException e) {
+                    throw new IOException(e.getMessage(), e);
+                  }
+                  return null;
+                }
+              });
               return part;
             }
           }));

http://git-wip-us.apache.org/repos/asf/hive/blob/be4fbeba/ql/src/test/results/clientnegative/external2.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientnegative/external2.q.out b/ql/src/test/results/clientnegative/external2.q.out
index 91b5de4..706432a 100644
--- a/ql/src/test/results/clientnegative/external2.q.out
+++ b/ql/src/test/results/clientnegative/external2.q.out
@@ -10,4 +10,4 @@ POSTHOOK: Output: default@external2
 PREHOOK: type: ALTERTABLE_ADDPARTS
 #### A masked pattern was here ####
 PREHOOK: Output: default@external2
-FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. MetaException(message:MetaException(message:Got
exception: java.io.IOException No FileSystem for scheme: invalidscheme))
+FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. MetaException(message:java.io.IOException:
Got exception: java.io.IOException No FileSystem for scheme: invalidscheme)


Mime
View raw message