Author: ryota
Date: Thu Aug 15 07:36:27 2013
New Revision: 1514189
URL: http://svn.apache.org/r1514189
Log:
OOZIE-1495 inconsistent behavior of chmod/chgrp when path doesn't exist after
glob support (ryota)
Modified:
oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/FsActionExecutor.java
oozie/trunk/core/src/test/java/org/apache/oozie/action/hadoop/TestFsActionExecutor.java
oozie/trunk/release-log.txt
Modified:
oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/FsActionExecutor.java
URL:
http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/FsActionExecutor.java?rev=1514189&r1=1514188&r2=1514189&view=diff
==============================================================================
---
oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/FsActionExecutor.java
(original)
+++
oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/FsActionExecutor.java
Thu Aug 15 07:36:27 2013
@@ -216,12 +216,15 @@ public class FsActionExecutor extends Ac
argsMap.put("group", group);
try {
FileSystem fs = getFileSystemFor(path, context, fsConf);
+ path = resolveToFullPath(nameNodePath, path, true);
Path[] pathArr = FileUtil.stat2Paths(fs.globStatus(path));
- if (pathArr != null && pathArr.length > 0) {
- checkGlobMax(pathArr);
- for (Path p : pathArr) {
- recursiveFsOperation("chgrp", fs, nameNodePath, p,
argsMap, dirFiles, recursive, true);
- }
+ if (pathArr == null || pathArr.length == 0) {
+ throw new
ActionExecutorException(ActionExecutorException.ErrorType.ERROR, "FS009",
"chgrp"
+ + ", path(s) that matches [{0}] does not exist", path);
+ }
+ checkGlobMax(pathArr);
+ for (Path p : pathArr) {
+ recursiveFsOperation("chgrp", fs, nameNodePath, p, argsMap,
dirFiles, recursive, true);
}
}
catch (Exception ex) {
@@ -234,11 +237,6 @@ public class FsActionExecutor extends Ac
throws ActionExecutorException {
try {
- path = resolveToFullPath(nameNodePath, path, true);
- if (!fs.exists(path)) {
- throw new
ActionExecutorException(ActionExecutorException.ErrorType.ERROR, "FS009", op
- + ", path [{0}] does not exist", path);
- }
FileStatus pathStatus = fs.getFileStatus(path);
List<Path> paths = new ArrayList<Path>();
@@ -471,13 +469,17 @@ public class FsActionExecutor extends Ac
argsMap.put("permissions", permissions);
try {
FileSystem fs = getFileSystemFor(path, context, fsConf);
+ path = resolveToFullPath(nameNodePath, path, true);
Path[] pathArr = FileUtil.stat2Paths(fs.globStatus(path));
- if (pathArr != null && pathArr.length > 0) {
- checkGlobMax(pathArr);
- for (Path p : pathArr) {
- recursiveFsOperation("chmod", fs, nameNodePath, p,
argsMap, dirFiles, recursive, true);
- }
+ if (pathArr == null || pathArr.length == 0) {
+ throw new
ActionExecutorException(ActionExecutorException.ErrorType.ERROR, "FS009",
"chmod"
+ + ", path(s) that matches [{0}] does not exist", path);
}
+ checkGlobMax(pathArr);
+ for (Path p : pathArr) {
+ recursiveFsOperation("chmod", fs, nameNodePath, p, argsMap,
dirFiles, recursive, true);
+ }
+
}
catch (Exception ex) {
throw convertException(ex);
Modified:
oozie/trunk/core/src/test/java/org/apache/oozie/action/hadoop/TestFsActionExecutor.java
URL:
http://svn.apache.org/viewvc/oozie/trunk/core/src/test/java/org/apache/oozie/action/hadoop/TestFsActionExecutor.java?rev=1514189&r1=1514188&r2=1514189&view=diff
==============================================================================
---
oozie/trunk/core/src/test/java/org/apache/oozie/action/hadoop/TestFsActionExecutor.java
(original)
+++
oozie/trunk/core/src/test/java/org/apache/oozie/action/hadoop/TestFsActionExecutor.java
Thu Aug 15 07:36:27 2013
@@ -21,13 +21,11 @@ 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.oozie.ErrorCode;
import org.apache.oozie.WorkflowActionBean;
import org.apache.oozie.WorkflowJobBean;
import org.apache.oozie.client.WorkflowAction;
import org.apache.oozie.action.ActionExecutorException;
import org.apache.oozie.service.HadoopAccessorService;
-import org.apache.oozie.service.ServiceException;
import org.apache.oozie.service.Services;
import org.apache.oozie.service.WorkflowAppService;
import org.apache.oozie.util.XConfiguration;
@@ -128,10 +126,15 @@ public class TestFsActionExecutor extend
assertEquals(new Path("hdfs://x/bla"), ae.resolveToFullPath(new
Path("hdfs://x"), new Path("/bla"), true));
+ assertEquals(new Path("hdfs://x/bla/[0-1]*"), ae.resolveToFullPath(new
Path("hdfs://x"), new Path("/bla/[0-1]*"), true));
+
assertEquals(new Path("hdfs://x/bla"), ae.resolveToFullPath(new
Path("hdfs://x/ha"), new Path("/bla"), true));
assertEquals(new Path("hdfs://x/bla"), ae.resolveToFullPath(new
Path("hdfs://z"), new Path("hdfs://x/bla"), true));
+ assertEquals(new Path("hdfs://x/bla/[0-1]*"),
+ ae.resolveToFullPath(new Path("hdfs://z"), new
Path("hdfs://x/bla/[0-1]*"), true));
+
assertEquals(new Path("hdfs://x/bla"), ae.resolveToFullPath(new
Path("hdfs://x"), new Path("hdfs://x/bla"), true));
try {
@@ -412,11 +415,7 @@ public class TestFsActionExecutor extend
assertEquals("rwx---r--",
fs.getFileStatus(grandchild).getPermission().toString());
}
- public void testChmodWithGlob() throws Exception {
- FsActionExecutor ae = new FsActionExecutor();
- FileSystem fs = getFileSystem();
- Context context = createContext("<fs/>");
- Path basePath = new Path(getFsTestCaseDir(), "2010");
+ private void createTestDirForChmod(Path basePath, FileSystem fs) throws
Exception {
fs.mkdirs(basePath);
fs.mkdirs(new Path(basePath, "10"));
fs.mkdirs(new Path(basePath + "/10/dir1"));
@@ -425,7 +424,6 @@ public class TestFsActionExecutor extend
fs.mkdirs(new Path(basePath, "11"));
fs.mkdirs(new Path(basePath + "/11/dir3"));
fs.mkdirs(new Path(basePath, "12"));
-
fs.setPermission(new Path(basePath, "10"),
FsPermission.valueOf("-rwxrwxrwx"));
fs.setPermission(new Path(basePath + "/10/dir1"),
FsPermission.valueOf("-rwxrwxrwx"));
fs.setPermission(new Path(basePath + "/10/dir2"),
FsPermission.valueOf("-rwxrwxrwx"));
@@ -433,7 +431,14 @@ public class TestFsActionExecutor extend
fs.setPermission(new Path(basePath, "11"),
FsPermission.valueOf("-rwxrwxrwx"));
fs.setPermission(new Path(basePath + "/11/dir3"),
FsPermission.valueOf("-rwxrwxrwx"));
fs.setPermission(new Path(basePath, "12"),
FsPermission.valueOf("-rwxrwxrwx"));
+ }
+ public void testChmodWithGlob() throws Exception {
+ FsActionExecutor ae = new FsActionExecutor();
+ FileSystem fs = getFileSystem();
+ Context context = createContext("<fs/>");
+ Path basePath = new Path(getFsTestCaseDir(), "2010");
+ createTestDirForChmod(basePath, fs);
Path globPath = new Path(basePath +"/1[0-1]");
ae.chmod(context, globPath, "-rwx------", false, false);
assertEquals("rwx------", fs.getFileStatus(new Path(basePath,
"10")).getPermission().toString());
@@ -465,6 +470,35 @@ public class TestFsActionExecutor extend
fs.delete(basePath, true);
}
+ public void testChmodRelativePath() throws Exception {
+
+ FsActionExecutor ae = new FsActionExecutor();
+ FileSystem fs = getFileSystem();
+ Context context = createContext("<fs/>");
+ Path basePath = new Path(getFsTestCaseDir(), "2010");
+ createTestDirForChmod(basePath, fs);
+ Path globPath = new Path(basePath +"/1[0-1]");
+ Path relativePath = new Path(globPath.toUri().getPath());
+ Path nameNode = new Path(globPath.toUri().getScheme() + "://" +
globPath.toUri().getAuthority());
+
+ ae.chmod(context, null, nameNode, relativePath, "-rwx------", false,
false);
+ assertEquals("rwx------", fs.getFileStatus(new Path(basePath,
"10")).getPermission().toString());
+ assertEquals("rwx------", fs.getFileStatus(new Path(basePath,
"11")).getPermission().toString());
+ assertEquals("rwxrwxrwx", fs.getFileStatus(new Path(basePath,
"12")).getPermission().toString());
+ assertEquals("rwxrwxrwx", fs.getFileStatus(new Path(basePath +
"/10/dir1")).getPermission().toString());
+ assertEquals("rwxrwxrwx", fs.getFileStatus(new Path(basePath +
"/10/dir2")).getPermission().toString());
+ assertEquals("rwxrwxrwx", fs.getFileStatus(new Path(basePath +
"/11/dir3")).getPermission().toString());
+ assertEquals("rw-rw-rw-", fs.getFileStatus(new Path(basePath +
"/10/dir1/file1")).getPermission().toString());
+
+ try{
+ ae.chmod(context, null, null, relativePath, "-rwx-----", false,
false);
+ fail();
+ } catch (ActionExecutorException e){
+ assertEquals(e.getErrorCode(), "FS001");
+ }
+ fs.delete(basePath, true);
+ }
+
public void testChmodRecursive() throws Exception {
FsActionExecutor ae = new FsActionExecutor();
FileSystem fs = getFileSystem();
@@ -960,15 +994,9 @@ public void testChmodRecursive() throws
assertEquals(testGroup2,
fs.getFileStatus(grandchild).getGroup().toString());
}
- public void testChgrpWithGlob() throws Exception {
-
+ private void createTestDirForChgrp(Path basePath, FileSystem fs) throws
Exception {
String testUser = getTestUser();
String testGroup = getTestGroup();
- String testGroup2 = getTestGroup2();
- FsActionExecutor ae = new FsActionExecutor();
- FileSystem fs = getFileSystem();
- Context context = createContext("<fs/>");
- Path basePath = new Path(getFsTestCaseDir(), "2010");
fs.mkdirs(basePath);
fs.mkdirs(new Path(basePath, "10"));
fs.mkdirs(new Path(basePath + "/10/dir1"));
@@ -985,7 +1013,18 @@ public void testChmodRecursive() throws
fs.setOwner(new Path(basePath, "11"), testUser, testGroup);
fs.setOwner(new Path(basePath + "/11/dir3"), testUser, testGroup);
fs.setOwner(new Path(basePath, "12"), testUser, testGroup);
+ }
+
+ public void testChgrpWithGlob() throws Exception {
+ String testUser = getTestUser();
+ String testGroup = getTestGroup();
+ String testGroup2 = getTestGroup2();
+ FsActionExecutor ae = new FsActionExecutor();
+ FileSystem fs = getFileSystem();
+ Context context = createContext("<fs/>");
+ Path basePath = new Path(getFsTestCaseDir(), "2010");
+ createTestDirForChgrp(basePath, fs);
Path globPath = new Path(basePath +"/1[0-1]");
ae.chgrp(context, null, null, globPath, testUser, testGroup2, false,
false);
assertEquals(testGroup2, fs.getFileStatus(new Path(basePath,
"10")).getGroup().toString());
@@ -1016,4 +1055,38 @@ public void testChmodRecursive() throws
fs.delete(basePath, true);
}
+
+ public void testChgrpRelativePath() throws Exception {
+
+ String testUser = getTestUser();
+ String testGroup = getTestGroup();
+ String testGroup2 = getTestGroup2();
+ FsActionExecutor ae = new FsActionExecutor();
+ FileSystem fs = getFileSystem();
+ Context context = createContext("<fs/>");
+ Path basePath = new Path(getFsTestCaseDir(), "2010");
+ createTestDirForChgrp(basePath, fs);
+
+ Path globPath = new Path(basePath +"/1[0-1]");
+ Path relativePath = new Path(globPath.toUri().getPath());
+ Path nameNode = new Path(globPath.toUri().getScheme() + "://" +
globPath.toUri().getAuthority());
+
+ ae.chgrp(context, null, nameNode, relativePath, testUser, testGroup2,
false, false);
+ assertEquals(testGroup2, fs.getFileStatus(new Path(basePath,
"10")).getGroup().toString());
+ assertEquals(testGroup2, fs.getFileStatus(new Path(basePath,
"11")).getGroup().toString());
+ assertEquals(testGroup, fs.getFileStatus(new Path(basePath,
"12")).getGroup().toString());
+ assertEquals(testGroup, fs.getFileStatus(new Path(basePath +
"/10/dir1")).getGroup().toString());
+ assertEquals(testGroup, fs.getFileStatus(new Path(basePath +
"/10/dir2")).getGroup().toString());
+ assertEquals(testGroup, fs.getFileStatus(new Path(basePath +
"/11/dir3")).getGroup().toString());
+ assertEquals(testGroup, fs.getFileStatus(new Path(basePath +
"/10/dir1/file1")).getGroup().toString());
+
+ try{
+ ae.chgrp(context, null, null, relativePath, testUser, testGroup2,
false, false);
+ fail();
+ } catch (ActionExecutorException e){
+ assertEquals(e.getErrorCode(), "FS001");
+ }
+
+ fs.delete(basePath, true);
+ }
}
Modified: oozie/trunk/release-log.txt
URL:
http://svn.apache.org/viewvc/oozie/trunk/release-log.txt?rev=1514189&r1=1514188&r2=1514189&view=diff
==============================================================================
--- oozie/trunk/release-log.txt (original)
+++ oozie/trunk/release-log.txt Thu Aug 15 07:36:27 2013
@@ -1,5 +1,6 @@
-- Oozie 4.1.0 release (trunk - unreleased)
+OOZIE-1495 inconsistent behavior of chmod/chgrp when path doesn't exist after
glob support (ryota)
OOZIE-1463 Remove discriminator column (virag)
OOZIE-1448 A CoordActionUpdateXCommand gets queued for all workflows even if
they were not launched by a coordinator (rkanter)
OOZIE-1443 forkjoin validation should not allow a fork to go to the same node
multiple times (rkanter)