You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by br...@apache.org on 2014/05/12 17:04:55 UTC

svn commit: r1593991 - in /hive/trunk: common/src/java/org/apache/hadoop/hive/common/ metastore/src/java/org/apache/hadoop/hive/metastore/ ql/src/java/org/apache/hadoop/hive/ql/exec/ ql/src/java/org/apache/hadoop/hive/ql/metadata/

Author: brock
Date: Mon May 12 15:04:55 2014
New Revision: 1593991

URL: http://svn.apache.org/r1593991
Log:
HIVE-7015 - Failing to inherit group/permission should not fail the operation (Szehon via Brock)

Modified:
    hive/trunk/common/src/java/org/apache/hadoop/hive/common/FileUtils.java
    hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/Warehouse.java
    hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/CopyTask.java
    hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java

Modified: hive/trunk/common/src/java/org/apache/hadoop/hive/common/FileUtils.java
URL: http://svn.apache.org/viewvc/hive/trunk/common/src/java/org/apache/hadoop/hive/common/FileUtils.java?rev=1593991&r1=1593990&r2=1593991&view=diff
==============================================================================
--- hive/trunk/common/src/java/org/apache/hadoop/hive/common/FileUtils.java (original)
+++ hive/trunk/common/src/java/org/apache/hadoop/hive/common/FileUtils.java Mon May 12 15:04:55 2014
@@ -451,10 +451,11 @@ public final class FileUtils {
    * @param fs FileSystem to use
    * @param f path to create.
    * @param inheritPerms whether directory inherits the permission of the last-existing parent path
+   * @param conf Hive configuration
    * @return true if directory created successfully.  False otherwise, including if it exists.
    * @throws IOException exception in creating the directory
    */
-  public static boolean mkdir(FileSystem fs, Path f, boolean inheritPerms) throws IOException {
+  public static boolean mkdir(FileSystem fs, Path f, boolean inheritPerms, Configuration conf) throws IOException {
     LOG.info("Creating directory if it doesn't exist: " + f);
     if (!inheritPerms) {
       //just create the directory
@@ -479,13 +480,17 @@ public final class FileUtils {
         return false;
       } else {
         FsPermission parentPerm = fs.getFileStatus(path).getPermission();
-        String parentGroup = fs.getFileStatus(path).getGroup();
+        String permString = Integer.toString(parentPerm.toShort(), 8);
         for (Path pathToSet : pathsToSet) {
-          String currOwner = fs.getFileStatus(pathToSet).getOwner();
-          LOG.info("Setting permission and group of parent directory: " + path.toString() +
+          LOG.info("Setting permission of parent directory: " + path.toString() +
             " on new directory: " + pathToSet.toString());
-          fs.setPermission(pathToSet, parentPerm);
-          fs.setOwner(pathToSet, currOwner, parentGroup);
+          try {
+            FsShell fshell = new FsShell();
+            fshell.setConf(conf);
+            fshell.run(new String[]{"-chmod", "-R", permString, pathToSet.toString()});
+          } catch (Exception e) {
+            LOG.warn("Error setting permissions of " + pathToSet, e);
+          }
         }
         return true;
       }
@@ -514,7 +519,7 @@ public final class FileUtils {
         fshell.run(new String[]{"-chgrp", "-R", group, dst.toString()});
         fshell.run(new String[]{"-chmod", "-R", permString, dst.toString()});
       } catch (Exception e) {
-        throw new IOException("Unable to set permissions of " + dst, e);
+        LOG.warn("Error setting permissions or group of " + dst, e);
       }
     }
     return copied;

Modified: hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/Warehouse.java
URL: http://svn.apache.org/viewvc/hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/Warehouse.java?rev=1593991&r1=1593990&r2=1593991&view=diff
==============================================================================
--- hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/Warehouse.java (original)
+++ hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/Warehouse.java Mon May 12 15:04:55 2014
@@ -189,7 +189,7 @@ public class Warehouse {
     FileSystem fs = null;
     try {
       fs = getFs(f);
-      return FileUtils.mkdir(fs, f, inheritPerms);
+      return FileUtils.mkdir(fs, f, inheritPerms, conf);
     } catch (IOException e) {
       closeFs(fs);
       MetaStoreUtils.logAndThrowMetaException(e);

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/CopyTask.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/CopyTask.java?rev=1593991&r1=1593990&r2=1593991&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/CopyTask.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/CopyTask.java Mon May 12 15:04:55 2014
@@ -71,7 +71,7 @@ public class CopyTask extends Task<CopyW
       }
 
       boolean inheritPerms = conf.getBoolVar(HiveConf.ConfVars.HIVE_WAREHOUSE_SUBDIR_INHERIT_PERMS);
-      if (!FileUtils.mkdir(dstFs, toPath, inheritPerms)) {
+      if (!FileUtils.mkdir(dstFs, toPath, inheritPerms, conf)) {
         console.printError("Cannot make target directory: " + toPath.toString());
         return 2;
       }

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java?rev=1593991&r1=1593990&r2=1593991&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java Mon May 12 15:04:55 2014
@@ -2305,7 +2305,7 @@ private void constructOneLBLocationMap(F
     try {
       // create the destination if it does not exist
       if (!fs.exists(destf)) {
-        FileUtils.mkdir(fs, destf, inheritPerms);
+        FileUtils.mkdir(fs, destf, inheritPerms, conf);
       }
     } catch (IOException e) {
       throw new HiveException(