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/08/21 19:33:17 UTC

svn commit: r1619488 - in /hive/trunk: itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/TestUtilitiesDfs.java ql/src/java/org/apache/hadoop/hive/ql/exec/Utilities.java ql/src/test/org/apache/hadoop/hive/ql/exec/TestUtilities.java

Author: brock
Date: Thu Aug 21 17:33:17 2014
New Revision: 1619488

URL: http://svn.apache.org/r1619488
Log:
HIVE-7807 - Refer to umask property using FsPermission.UMASK_LABEL (Venki Korukanti via Brock)

Added:
    hive/trunk/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/TestUtilitiesDfs.java
Modified:
    hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/Utilities.java
    hive/trunk/ql/src/test/org/apache/hadoop/hive/ql/exec/TestUtilities.java

Added: hive/trunk/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/TestUtilitiesDfs.java
URL: http://svn.apache.org/viewvc/hive/trunk/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/TestUtilitiesDfs.java?rev=1619488&view=auto
==============================================================================
--- hive/trunk/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/TestUtilitiesDfs.java (added)
+++ hive/trunk/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/TestUtilitiesDfs.java Thu Aug 21 17:33:17 2014
@@ -0,0 +1,69 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.ql;
+
+import java.io.IOException;
+
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.permission.FsPermission;
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.ql.exec.Utilities;
+import org.apache.hadoop.hive.shims.HadoopShims.MiniDFSShim;
+import org.apache.hadoop.hive.shims.ShimLoader;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class TestUtilitiesDfs {
+  private static final FsPermission FULL_PERM = new FsPermission((short) 00777);
+  private static MiniDFSShim dfs;
+  private static HiveConf conf;
+
+  @BeforeClass
+  public static void setupDfs() throws Exception {
+    conf = new HiveConf();
+    dfs = ShimLoader.getHadoopShims().getMiniDfs(conf, 4, true, null);
+
+    assertNotNull("MiniDFS is not initialized", dfs);
+    assertNotNull("HiveConf is not initialized", conf);
+  }
+
+  @Test
+  public void testCreateDirWithPermissionRecursive() throws IllegalArgumentException, IOException {
+    FileSystem fs = dfs.getFileSystem();
+    Path dir = new Path(new Path(fs.getUri()), "/testUtilitiesUMaskReset");
+    Utilities.createDirsWithPermission(conf, dir, FULL_PERM, true);
+    FileStatus status = fs.getFileStatus(dir);
+    assertEquals("Created dir has invalid permissions.",
+        FULL_PERM.toString(), status.getPermission().toString());
+  }
+
+  @AfterClass
+  public static void shutdownDfs() throws Exception {
+    if (dfs != null) {
+      dfs.shutdown();
+      dfs = null;
+    }
+  }
+}

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/Utilities.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/Utilities.java?rev=1619488&r1=1619487&r2=1619488&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/Utilities.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/Utilities.java Thu Aug 21 17:33:17 2014
@@ -3466,9 +3466,9 @@ public final class Utilities {
       String origUmask, FileSystem fs) throws IOException {
     if (unsetUmask) {
       if (origUmask != null) {
-        conf.set("fs.permissions.umask-mode", origUmask);
+        conf.set(FsPermission.UMASK_LABEL, origUmask);
       } else {
-        conf.unset("fs.permissions.umask-mode");
+        conf.unset(FsPermission.UMASK_LABEL);
       }
     }
 
@@ -3482,10 +3482,10 @@ public final class Utilities {
         recursive);
 
     if (recursive) {
-      origUmask = conf.get("fs.permissions.umask-mode");
+      origUmask = conf.get(FsPermission.UMASK_LABEL);
       // this umask is required because by default the hdfs mask is 022 resulting in
       // all parents getting the fsPermission & !(022) permission instead of fsPermission
-      conf.set("fs.permissions.umask-mode", "000");
+      conf.set(FsPermission.UMASK_LABEL, "000");
     }
 
     FileSystem fs = ShimLoader.getHadoopShims().getNonCachedFileSystem(mkdirPath.toUri(), conf);

Modified: hive/trunk/ql/src/test/org/apache/hadoop/hive/ql/exec/TestUtilities.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/org/apache/hadoop/hive/ql/exec/TestUtilities.java?rev=1619488&r1=1619487&r2=1619488&view=diff
==============================================================================
--- hive/trunk/ql/src/test/org/apache/hadoop/hive/ql/exec/TestUtilities.java (original)
+++ hive/trunk/ql/src/test/org/apache/hadoop/hive/ql/exec/TestUtilities.java Thu Aug 21 17:33:17 2014
@@ -118,14 +118,13 @@ public class TestUtilities extends TestC
   }
 
   private void checkFSUMaskReset(boolean recursiveArg) throws IllegalArgumentException, IOException {
-    final String FS_MASK_PARAM = "fs.permissions.umask-mode";
     final String FS_MASK_VAL = "055";
     HiveConf conf = new HiveConf();
     String dir = System.getProperty("test.tmp.dir") + "/testUtilitiesUMaskReset";
-    conf.set(FS_MASK_PARAM, FS_MASK_VAL);
+    conf.set(FsPermission.UMASK_LABEL, FS_MASK_VAL);
     Utilities.createDirsWithPermission(conf, new Path(dir), new FsPermission((short) 00777),
         recursiveArg);
-    assertEquals(conf.get(FS_MASK_PARAM), FS_MASK_VAL);
+    assertEquals(conf.get(FsPermission.UMASK_LABEL), FS_MASK_VAL);
   }