hadoop-hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zs...@apache.org
Subject svn commit: r738406 - in /hadoop/hive/trunk: CHANGES.txt common/src/java/org/apache/hadoop/hive/conf/HiveConf.java ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java
Date Wed, 28 Jan 2009 08:55:17 GMT
Author: zshao
Date: Wed Jan 28 08:55:17 2009
New Revision: 738406

URL: http://svn.apache.org/viewvc?rev=738406&view=rev
Log:
HIVE-255. Propagate user name to Hive metastore. (Prasad Chakka via zshao)

Modified:
    hadoop/hive/trunk/CHANGES.txt
    hadoop/hive/trunk/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
    hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java

Modified: hadoop/hive/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/CHANGES.txt?rev=738406&r1=738405&r2=738406&view=diff
==============================================================================
--- hadoop/hive/trunk/CHANGES.txt (original)
+++ hadoop/hive/trunk/CHANGES.txt Wed Jan 28 08:55:17 2009
@@ -84,6 +84,8 @@
 
   BUG FIXES
 
+    HIVE-255. Propagate user name to Hive metastore. (Prasad Chakka via zshao)
+
     HIVE-235. Fixed DynamicSerDe to work with null values with Thrift
     Protocols that can have missing fields for null values. (zshao)
 

Modified: hadoop/hive/trunk/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java?rev=738406&r1=738405&r2=738406&view=diff
==============================================================================
--- hadoop/hive/trunk/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java (original)
+++ hadoop/hive/trunk/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java Wed Jan 28
08:55:17 2009
@@ -18,16 +18,20 @@
 
 package org.apache.hadoop.hive.conf;
 
+import java.io.IOException;
 import java.io.PrintStream;
 import java.net.URL;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Properties;
 
+import javax.security.auth.login.LoginException;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.mapred.JobConf;
+import org.apache.hadoop.security.UserGroupInformation;
 
 import org.apache.commons.lang.StringUtils;
 
@@ -106,7 +110,7 @@
     public final String defaultVal;
     public final int defaultIntVal;
     public final float defaultFloatVal;
-    public final Class valClass;
+    public final Class<?> valClass;
     public final boolean defaultBoolVal;
 
     ConfVars(String varname, String defaultVal) {
@@ -154,7 +158,7 @@
     assert(var.valClass == Integer.class);
     return conf.getInt(var.varname, var.defaultIntVal);
   }
-
+  
   public int getIntVar(ConfVars var) {
     return getIntVar(this, var);
   }
@@ -202,12 +206,12 @@
   }
 
 
-  public HiveConf(Class cls) {
+  public HiveConf(Class<?> cls) {
     super();
     initialize(cls);
   }
 
-  public HiveConf(Configuration other, Class cls) {
+  public HiveConf(Configuration other, Class<?> cls) {
     super(other);
     initialize(cls);
   }
@@ -223,7 +227,7 @@
   }
 
 
-  private void initialize(Class cls) {
+  private void initialize(Class<?> cls) {
     hiveJar = (new JobConf(cls)).getJar();
     
     // preserve the original configuration
@@ -311,4 +315,18 @@
   public void setAuxJars(String auxJars) {
     this.auxJars = auxJars;
   }
+  
+  /**
+   * @return the user name set in hadoop.job.ugi param or the current user from System
+   * @throws IOException
+   */
+  public String getUser() throws IOException {
+    try {
+      return UserGroupInformation.login(this).getUserName();
+    } catch (LoginException e) {
+      throw (IOException)new IOException().initCause(e);
+    }
+  }
+
+
 }

Modified: hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java?rev=738406&r1=738405&r2=738406&view=diff
==============================================================================
--- hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java (original)
+++ hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java Wed Jan 28 08:55:17
2009
@@ -549,7 +549,11 @@
     }
 
     // set last modified by properties
-    tbl.setProperty("last_modified_by", System.getProperty("user.name"));
+    try {
+      tbl.setProperty("last_modified_by", conf.getUser());
+    } catch (IOException e) {
+      console.printError("Unable to get current user: " + e.getMessage(), StringUtils.stringifyException(e));
+    }
     tbl.setProperty("last_modified_time", Long.toString(System
         .currentTimeMillis() / 1000));
 
@@ -634,7 +638,7 @@
         Iterator<Map.Entry<String, String>> iter = crtTbl.getMapProp()
             .entrySet().iterator();
         while (iter.hasNext()) {
-          Map.Entry<String, String> m = (Map.Entry) iter.next();
+          Map.Entry<String, String> m = (Map.Entry<String, String>) iter.next();
           tbl.setSerdeParam(m.getKey(), m.getValue());
         }
       }



Mime
View raw message