You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oozie.apache.org by vi...@apache.org on 2012/06/29 20:08:01 UTC

svn commit: r1355489 - in /incubator/oozie/trunk: ./ client/src/main/resources/ core/src/main/java/org/apache/oozie/action/hadoop/ core/src/test/java/org/apache/oozie/action/hadoop/ docs/src/site/twiki/

Author: virag
Date: Fri Jun 29 18:07:56 2012
New Revision: 1355489

URL: http://svn.apache.org/viewvc?rev=1355489&view=rev
Log:
OOZIE-881 Support for recursive chmod (britt via virag)

Modified:
    incubator/oozie/trunk/client/src/main/resources/oozie-workflow-0.4.xsd
    incubator/oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/FsActionExecutor.java
    incubator/oozie/trunk/core/src/test/java/org/apache/oozie/action/hadoop/TestFsActionExecutor.java
    incubator/oozie/trunk/docs/src/site/twiki/WorkflowFunctionalSpec.twiki
    incubator/oozie/trunk/release-log.txt

Modified: incubator/oozie/trunk/client/src/main/resources/oozie-workflow-0.4.xsd
URL: http://svn.apache.org/viewvc/incubator/oozie/trunk/client/src/main/resources/oozie-workflow-0.4.xsd?rev=1355489&r1=1355488&r2=1355489&view=diff
==============================================================================
--- incubator/oozie/trunk/client/src/main/resources/oozie-workflow-0.4.xsd (original)
+++ incubator/oozie/trunk/client/src/main/resources/oozie-workflow-0.4.xsd Fri Jun 29 18:07:56 2012
@@ -263,6 +263,9 @@
     </xs:complexType>
 
     <xs:complexType name="CHMOD">
+        <xs:sequence>
+            <xs:element name="recursive" type="workflow:FLAG" minOccurs="0" maxOccurs="1"></xs:element>
+        </xs:sequence>
         <xs:attribute name="path" type="xs:string" use="required"/>
         <xs:attribute name="permissions" type="xs:string" use="required"/>
         <xs:attribute name="dir-files" type="xs:string"/>

Modified: incubator/oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/FsActionExecutor.java
URL: http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/FsActionExecutor.java?rev=1355489&r1=1355488&r2=1355489&view=diff
==============================================================================
--- incubator/oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/FsActionExecutor.java (original)
+++ incubator/oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/FsActionExecutor.java Fri Jun 29 18:07:56 2012
@@ -113,10 +113,11 @@ public class FsActionExecutor extends Ac
                         else {
                             if (command.equals("chmod")) {
                                 Path path = getPath(commandElement, "path");
+                                boolean recursive = commandElement.getChild("recursive") != null;
                                 String str = commandElement.getAttributeValue("dir-files");
                                 boolean dirFiles = (str == null) || Boolean.parseBoolean(str);
                                 String permissionsMask = commandElement.getAttributeValue("permissions").trim();
-                                chmod(context, path, permissionsMask, dirFiles);
+                                chmod(context, path, permissionsMask, dirFiles, recursive);
                             }
                             else {
                                 if (command.equals("touchz")) {
@@ -257,7 +258,7 @@ public class FsActionExecutor extends Ac
         }
     }
 
-    void chmod(Context context, Path path, String permissions, boolean dirFiles) throws ActionExecutorException {
+    void chmod(Context context, Path path, String permissions, boolean dirFiles, boolean recursive) throws ActionExecutorException {
         try {
             validatePath(path, true);
             FileSystem fs = getFileSystemFor(path, context);
@@ -275,6 +276,9 @@ public class FsActionExecutor extends Ac
                 paths = new Path[filesStatus.length];
                 for (int i = 0; i < filesStatus.length; i++) {
                     paths[i] = filesStatus[i].getPath();
+                    if (recursive && filesStatus[i].isDir()){
+                        chmod(context, paths[i], permissions, dirFiles, recursive);
+                    }
                 }
             }
             else {

Modified: incubator/oozie/trunk/core/src/test/java/org/apache/oozie/action/hadoop/TestFsActionExecutor.java
URL: http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/test/java/org/apache/oozie/action/hadoop/TestFsActionExecutor.java?rev=1355489&r1=1355488&r2=1355489&view=diff
==============================================================================
--- incubator/oozie/trunk/core/src/test/java/org/apache/oozie/action/hadoop/TestFsActionExecutor.java (original)
+++ incubator/oozie/trunk/core/src/test/java/org/apache/oozie/action/hadoop/TestFsActionExecutor.java Fri Jun 29 18:07:56 2012
@@ -209,17 +209,50 @@ public class TestFsActionExecutor extend
 
         Context context = createContext("<fs/>");
 
-        ae.chmod(context, path, "-rwx-----x", false);
+        ae.chmod(context, path, "-rwx-----x", false, false);
         assertEquals("rwx-----x", fs.getFileStatus(path).getPermission().toString());
         assertEquals("rwxr-----", fs.getFileStatus(child).getPermission().toString());
         assertEquals("rwx---r--", fs.getFileStatus(grandchild).getPermission().toString());
 
-        ae.chmod(context, path, "-rwxr----x", true);
+        ae.chmod(context, path, "-rwxr----x", true, false);
         assertEquals("rwxr----x", fs.getFileStatus(path).getPermission().toString());
         assertEquals("rwxr----x", fs.getFileStatus(child).getPermission().toString());
         assertEquals("rwx---r--", fs.getFileStatus(grandchild).getPermission().toString());
     }
 
+public void testChmodRecursive() throws Exception {
+        FsActionExecutor ae = new FsActionExecutor();
+        FileSystem fs = getFileSystem();
+
+        Path path = new Path(getFsTestCaseDir(), "dir");
+        Path child = new Path(path, "child");
+        Path grandchild = new Path(child, "grandchild");
+        fs.mkdirs(grandchild);
+        fs.setPermission(path, FsPermission.valueOf("-rwx------"));
+        fs.setPermission(child, FsPermission.valueOf("-rwxr-----"));
+        fs.setPermission(grandchild, FsPermission.valueOf("-rwx---r--"));
+        assertEquals("rwx------", fs.getFileStatus(path).getPermission().toString());
+        assertEquals("rwxr-----", fs.getFileStatus(child).getPermission().toString());
+        assertEquals("rwx---r--", fs.getFileStatus(grandchild).getPermission().toString());
+
+        Context context = createContext("<fs/>");
+
+        ae.chmod(context, path, "-rwx-----x", false, false);
+        assertEquals("rwx-----x", fs.getFileStatus(path).getPermission().toString());
+        assertEquals("rwxr-----", fs.getFileStatus(child).getPermission().toString());
+        assertEquals("rwx---r--", fs.getFileStatus(grandchild).getPermission().toString());
+
+        ae.chmod(context, path, "-rwx-----x", false, true);
+        assertEquals("rwx-----x", fs.getFileStatus(path).getPermission().toString());
+        assertEquals("rwxr-----", fs.getFileStatus(child).getPermission().toString());
+        assertEquals("rwx---r--", fs.getFileStatus(grandchild).getPermission().toString());
+
+        ae.chmod(context, path, "-rwxr----x", true, true);
+        assertEquals("rwxr----x", fs.getFileStatus(path).getPermission().toString());
+        assertEquals("rwxr----x", fs.getFileStatus(child).getPermission().toString());
+        assertEquals("rwxr----x", fs.getFileStatus(grandchild).getPermission().toString());
+    }
+
     public void testTouchz() throws Exception {
         FsActionExecutor ae = new FsActionExecutor();
         FileSystem fs = getFileSystem();
@@ -293,6 +326,12 @@ public class TestFsActionExecutor extend
         Path newFile1 = new Path(mkdir + "newFile1");
         Path newFile2 = new Path(mkdir + "newFile2");
         fs.createNewFile(newFile1);
+        Path chmod3 = new Path(getFsTestCaseDir(), "chmod3");
+        fs.mkdirs(chmod3);
+        Path child3 = new Path(chmod3, "child3");
+        fs.mkdirs(child3);
+        Path grandchild3 = new Path(child3, "grandchild1");
+        fs.mkdirs(grandchild3);
 
         String str = MessageFormat.format("<root><mkdir path=''{0}''/>" +
                 "<delete path=''{1}''/>" +
@@ -301,7 +340,8 @@ public class TestFsActionExecutor extend
                 "<chmod path=''{5}'' permissions=''-rwxrwx---'' dir-files=''false''/>" +
                 "<touchz path=''{6}''/>" +
                 "<touchz path=''{7}''/>" +
-                "</root>", mkdir, delete, source, target, chmod1, chmod2, newFile1, newFile2);
+                "<chmod path=''{8}'' permissions=''-rwxrwx---'' recursive/>" +
+                "</root>", mkdir, delete, source, target, chmod1, chmod2, newFile1, newFile2, chmod3);
 
         Element xml = XmlUtils.parseXml(str);
 
@@ -319,6 +359,11 @@ public class TestFsActionExecutor extend
         assertEquals("rwxrwx---", fs.getFileStatus(chmod2).getPermission().toString());
         assertNotSame("rwxrwx---", fs.getFileStatus(child2).getPermission().toString());
 
+        assertEquals("rwxrwx---", fs.getFileStatus(child3).getPermission().toString());
+        assertEquals("rwxrwx---", fs.getFileStatus(grandchild3).getPermission().toString());
+
+        assertEquals("rwxrwx---", fs.getFileStatus(child3).getPermission().toString());
+        assertEquals("rwxrwx---", fs.getFileStatus(grandchild3).getPermission().toString());
     }
 
     public void testSubmit() throws Exception {

Modified: incubator/oozie/trunk/docs/src/site/twiki/WorkflowFunctionalSpec.twiki
URL: http://svn.apache.org/viewvc/incubator/oozie/trunk/docs/src/site/twiki/WorkflowFunctionalSpec.twiki?rev=1355489&r1=1355488&r2=1355489&view=diff
==============================================================================
--- incubator/oozie/trunk/docs/src/site/twiki/WorkflowFunctionalSpec.twiki (original)
+++ incubator/oozie/trunk/docs/src/site/twiki/WorkflowFunctionalSpec.twiki Fri Jun 29 18:07:56 2012
@@ -1045,7 +1045,7 @@ In the =move= command the =source= path 
    * However, if the =target= path is an already existing directory, the =move= action will place your =source= as a child of the =target= directory.
 
 The =chmod= command changes the permissions for the specified path. Permissions can be specified using the Unix Symbolic representation (e.g. -rwxrw-rw-) or an octal representation (755).
- When doing a =chmod= command on a directory, by default the command is applied to the directory and the files one level within the directory. To apply the =chmod= command to the directory, without affecting the files within it, the =dir-files= attribute must be set to =false=.
+ When doing a =chmod= command on a directory, by default the command is applied to the directory and the files one level within the directory. To apply the =chmod= command to the directory, without affecting the files within it, the =dir-files= attribute must be set to =false=. To apply the =chmod= command recursively to all levels within a directory, put a <recursive/> element inside the <chmod> element.
 
 The =touchz= command creates a zero length file in the specified path if none exists. If one already exists, then touchz will perform a touch operation.
 

Modified: incubator/oozie/trunk/release-log.txt
URL: http://svn.apache.org/viewvc/incubator/oozie/trunk/release-log.txt?rev=1355489&r1=1355488&r2=1355489&view=diff
==============================================================================
--- incubator/oozie/trunk/release-log.txt (original)
+++ incubator/oozie/trunk/release-log.txt Fri Jun 29 18:07:56 2012
@@ -1,5 +1,6 @@
 -- Oozie 3.3.0 release (trunk - unreleased)
 
+OOZIE-881 Support for recursive chmod (britt via virag)
 OOZIE-872 Support touchz in fs node of oozie worklfow (britt via virag)
 OOZIE-769 Adding "-debug" option to Oozie CLI for debug statements to stdout (mona via virag)
 OOZIE-795 update the oozie commit build profile (virag)