From 596831bcba7bb2eea497855de598086302220a96 Mon Sep 17 00:00:00 2001 From: Alejandro Abdelnur Date: Fri, 27 Apr 2012 16:30:56 +0000 Subject: [PATCH] Merge -r 1331492:1331493 from trunk to branch. FIXES: HDFS-3309 git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1331494 13f79535-47bb-0310-9956-ffa450edef68 --- .../hadoop/fs/http/server/FSOperations.java | 8 +++----- .../hadoop/fs/http/server/HttpFSParams.java | 2 +- .../fs/http/client/TestHttpFSFileSystem.java | 20 ++++++++++++++----- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/server/FSOperations.java b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/server/FSOperations.java index 1a7ad1d9f49..4b3b587a247 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/server/FSOperations.java +++ b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/server/FSOperations.java @@ -43,8 +43,8 @@ import java.util.Map; public class FSOperations { /** - * Converts a Unix permission octal & symbolic representation - * (i.e. 655 or -rwxr--r--) into a FileSystemAccess permission. + * Converts a Unix permission octal + * (i.e. 655 or 1777) into a FileSystemAccess permission. * * @param str Unix permission symbolic representation. * @@ -55,10 +55,8 @@ public class FSOperations { FsPermission permission; if (str.equals(HttpFSFileSystem.DEFAULT_PERMISSION)) { permission = FsPermission.getDefault(); - } else if (str.length() == 3) { - permission = new FsPermission(Short.parseShort(str, 8)); } else { - permission = FsPermission.valueOf(str); + permission = new FsPermission(Short.parseShort(str, 8)); } return permission; } diff --git a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/server/HttpFSParams.java b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/server/HttpFSParams.java index 4088aad4261..3c7b5f74993 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/server/HttpFSParams.java +++ b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/server/HttpFSParams.java @@ -446,7 +446,7 @@ public class HttpFSParams { * Symbolic Unix permissions regular expression pattern. */ private static final Pattern PERMISSION_PATTERN = - Pattern.compile(DEFAULT + "|(-[-r][-w][-x][-r][-w][-x][-r][-w][-x])" + "|[0-7][0-7][0-7]"); + Pattern.compile(DEFAULT + "|[0-1]?[0-7][0-7][0-7]"); /** * Constructor. diff --git a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/client/TestHttpFSFileSystem.java b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/client/TestHttpFSFileSystem.java index 4837352fc3b..a55d5e2a463 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/client/TestHttpFSFileSystem.java +++ b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/client/TestHttpFSFileSystem.java @@ -310,11 +310,8 @@ public class TestHttpFSFileSystem extends HFSTestCase { private void testSetPermission() throws Exception { FileSystem fs = FileSystem.get(TestHdfsHelper.getHdfsConf()); - Path path = new Path(TestHdfsHelper.getHdfsTestDir(), "foo.txt"); - OutputStream os = fs.create(path); - os.write(1); - os.close(); - fs.close(); + Path path = new Path(TestHdfsHelper.getHdfsTestDir(), "foodir"); + fs.mkdirs(path); fs = getHttpFileSystem(); FsPermission permission1 = new FsPermission(FsAction.READ_WRITE, FsAction.NONE, FsAction.NONE); @@ -326,6 +323,19 @@ public class TestHttpFSFileSystem extends HFSTestCase { fs.close(); FsPermission permission2 = status1.getPermission(); Assert.assertEquals(permission2, permission1); + + //sticky bit + fs = getHttpFileSystem(); + permission1 = new FsPermission(FsAction.READ_WRITE, FsAction.NONE, FsAction.NONE, true); + fs.setPermission(path, permission1); + fs.close(); + + fs = FileSystem.get(TestHdfsHelper.getHdfsConf()); + status1 = fs.getFileStatus(path); + fs.close(); + permission2 = status1.getPermission(); + Assert.assertTrue(permission2.getStickyBit()); + Assert.assertEquals(permission2, permission1); } private void testSetOwner() throws Exception { diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 1fe88f52426..eec36808807 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -445,6 +445,9 @@ Release 2.0.0 - UNRELEASED HDFS-3181. Fix a test case in TestLeaseRecovery2. (szetszwo) + HDFS-3309. HttpFS (Hoop) chmod not supporting octal and sticky bit + permissions. (tucu) + BREAKDOWN OF HDFS-1623 SUBTASKS HDFS-2179. Add fencing framework and mechanisms for NameNode HA. (todd)