FAQ
Author: vgumashta
Date: Wed Sep 17 20:51:53 2014
New Revision: 1625820

URL: http://svn.apache.org/r1625820
Log:
HIVE-8143: Create root scratch dir with 733 instead of 777 perms (Vaibhav Gumashta reviewed by Gopal Vijayaraghavan)

Modified:
     hive/trunk/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
     hive/trunk/itests/hive-unit/src/main/java/org/apache/hive/jdbc/miniHS2/MiniHS2.java
     hive/trunk/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcWithMiniHS2.java
     hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java

Modified: hive/trunk/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
URL: http://svn.apache.org/viewvc/hive/trunk/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java?rev=1625820&r1=1625819&r2=1625820&view=diff
==============================================================================
--- hive/trunk/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java (original)
+++ hive/trunk/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java Wed Sep 17 20:51:53 2014
@@ -206,7 +206,7 @@ public class HiveConf extends Configurat
          "Query plan format serialization between client and task nodes. \n" +
          "Two supported values are : kryo and javaXML. Kryo is default."),
      SCRATCHDIR("hive.exec.scratchdir", "/tmp/hive",
- "HDFS root scratch dir for Hive jobs which gets created with 777 permission. " +
+ "HDFS root scratch dir for Hive jobs which gets created with write all (733) permission. " +
          "For each connecting user, an HDFS scratch dir: ${hive.exec.scratchdir}/<username> is created, " +
          "with ${hive.scratch.dir.permission}."),
      LOCALSCRATCHDIR("hive.exec.local.scratchdir",

Modified: hive/trunk/itests/hive-unit/src/main/java/org/apache/hive/jdbc/miniHS2/MiniHS2.java
URL: http://svn.apache.org/viewvc/hive/trunk/itests/hive-unit/src/main/java/org/apache/hive/jdbc/miniHS2/MiniHS2.java?rev=1625820&r1=1625819&r2=1625820&view=diff
==============================================================================
--- hive/trunk/itests/hive-unit/src/main/java/org/apache/hive/jdbc/miniHS2/MiniHS2.java (original)
+++ hive/trunk/itests/hive-unit/src/main/java/org/apache/hive/jdbc/miniHS2/MiniHS2.java Wed Sep 17 20:51:53 2014
@@ -32,6 +32,7 @@ import org.apache.hadoop.fs.permission.F
  import org.apache.hadoop.hive.conf.HiveConf;
  import org.apache.hadoop.hive.conf.HiveConf.ConfVars;
  import org.apache.hadoop.hive.metastore.MetaStoreUtils;
+import org.apache.hadoop.hive.ql.exec.Utilities;
  import org.apache.hadoop.hive.shims.HadoopShims.MiniDFSShim;
  import org.apache.hadoop.hive.shims.HadoopShims.MiniMrShim;
  import org.apache.hadoop.hive.shims.ShimLoader;
@@ -50,6 +51,7 @@ public class MiniHS2 extends AbstractHiv
    public static final String HS2_HTTP_MODE = "http";
    private static final String driverName = "org.apache.hive.jdbc.HiveDriver";
    private static final FsPermission FULL_PERM = new FsPermission((short)00777);
+ private static final FsPermission WRITE_ALL_PERM = new FsPermission((short)00733);
    private HiveServer2 hiveServer2 = null;
    private final File baseDir;
    private final Path baseDfsDir;
@@ -200,9 +202,8 @@ public class MiniHS2 extends AbstractHiv
      hiveConf.setIntVar(ConfVars.HIVE_SERVER2_THRIFT_HTTP_PORT, getHttpPort());

      Path scratchDir = new Path(baseDfsDir, "scratch");
-
- // Create scratchdir with 777, so that user impersonation has no issues.
- FileSystem.mkdirs(fs, scratchDir, FULL_PERM);
+ // Create root scratchdir with write all, so that user impersonation has no issues.
+ Utilities.createDirsWithPermission(hiveConf, scratchDir, WRITE_ALL_PERM, true);
      System.setProperty(HiveConf.ConfVars.SCRATCHDIR.varname, scratchDir.toString());
      hiveConf.setVar(ConfVars.SCRATCHDIR, scratchDir.toString());


Modified: hive/trunk/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcWithMiniHS2.java
URL: http://svn.apache.org/viewvc/hive/trunk/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcWithMiniHS2.java?rev=1625820&r1=1625819&r2=1625820&view=diff
==============================================================================
--- hive/trunk/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcWithMiniHS2.java (original)
+++ hive/trunk/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcWithMiniHS2.java Wed Sep 17 20:51:53 2014
@@ -388,7 +388,7 @@ public class TestJdbcWithMiniHS2 {
    }

    /**
- * Tests the creation of the root hdfs scratch dir, which should be writable by all (777).
+ * Tests the creation of the root hdfs scratch dir, which should be writable by all.
     *
     * @throws Exception
     */
@@ -410,7 +410,7 @@ public class TestJdbcWithMiniHS2 {
      hs2Conn = getConnection(miniHS2.getJdbcURL(), userName, "password");
      // FS
      FileSystem fs = miniHS2.getLocalFS();
- FsPermission expectedFSPermission = new FsPermission("777");
+ FsPermission expectedFSPermission = new FsPermission((short)00733);
      // Verify scratch dir paths and permission
      // HDFS scratch dir
      scratchDirPath = new Path(HiveConf.getVar(conf, HiveConf.ConfVars.SCRATCHDIR));

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java?rev=1625820&r1=1625819&r2=1625820&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java Wed Sep 17 20:51:53 2014
@@ -515,16 +515,17 @@ public class SessionState {
     */
    private Path createRootHDFSDir(HiveConf conf) throws IOException {
      Path rootHDFSDirPath = new Path(HiveConf.getVar(conf, HiveConf.ConfVars.SCRATCHDIR));
- FsPermission expectedHDFSDirPermission = new FsPermission("777");
+ FsPermission writableHDFSDirPermission = new FsPermission((short)00733);
      FileSystem fs = rootHDFSDirPath.getFileSystem(conf);
      if (!fs.exists(rootHDFSDirPath)) {
- Utilities.createDirsWithPermission(conf, rootHDFSDirPath, expectedHDFSDirPermission, true);
+ Utilities.createDirsWithPermission(conf, rootHDFSDirPath, writableHDFSDirPermission, true);
      }
      FsPermission currentHDFSDirPermission = fs.getFileStatus(rootHDFSDirPath).getPermission();
      LOG.debug("HDFS root scratch dir: " + rootHDFSDirPath + ", permission: "
          + currentHDFSDirPermission);
- // If the root HDFS scratch dir already exists, make sure the permissions are 777.
- if (!expectedHDFSDirPermission.equals(fs.getFileStatus(rootHDFSDirPath).getPermission())) {
+ // If the root HDFS scratch dir already exists, make sure it is writeable.
+ if (!((currentHDFSDirPermission.toShort() & writableHDFSDirPermission
+ .toShort()) == writableHDFSDirPermission.toShort())) {
        throw new RuntimeException("The root scratch dir: " + rootHDFSDirPath
            + " on HDFS should be writable. Current permissions are: " + currentHDFSDirPermission);
      }

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcommits @
categorieshive, hadoop
postedSep 17, '14 at 8:52p
activeSep 17, '14 at 8:52p
posts1
users1
websitehive.apache.org

1 user in discussion

Vgumashta: 1 post

People

Translate

site design / logo © 2021 Grokbase