hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From omal...@apache.org
Subject svn commit: r1077632 - in /hadoop/common/branches/branch-0.20-security-patches/src: mapred/org/apache/hadoop/mapred/JobHistory.java test/org/apache/hadoop/mapred/TestJobHistory.java
Date Fri, 04 Mar 2011 04:38:31 GMT
Author: omalley
Date: Fri Mar  4 04:38:30 2011
New Revision: 1077632

URL: http://svn.apache.org/viewvc?rev=1077632&view=rev
Log:
commit ef735b317e99351d7a98b11fa48de4dc9a55bd8b
Author: Arun C Murthy <acmurthy@apache.org>
Date:   Tue Aug 3 15:27:20 2010 -0700

    MAPREDUCE-323. Fixed job history files' permissions.

Modified:
    hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/JobHistory.java
    hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/TestJobHistory.java

Modified: hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/JobHistory.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/JobHistory.java?rev=1077632&r1=1077631&r2=1077632&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/JobHistory.java
(original)
+++ hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/JobHistory.java
Fri Mar  4 04:38:30 2011
@@ -402,7 +402,7 @@ public class JobHistory {
       if (!DONEDIR_FS.exists(dir)) {
         LOG.info("Creating DONE subfolder at "+ dir);
 
-        if (!DONEDIR_FS.mkdirs(dir,
+        if (!FileSystem.mkdirs(DONEDIR_FS, dir,
                                new FsPermission(HISTORY_DIR_PERMISSION))) {
           throw new IOException("Mkdirs failed to create " + dir.toString());
         }

Modified: hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/TestJobHistory.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/TestJobHistory.java?rev=1077632&r1=1077631&r2=1077632&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/TestJobHistory.java
(original)
+++ hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/TestJobHistory.java
Fri Mar  4 04:38:30 2011
@@ -32,8 +32,10 @@ import java.util.regex.Pattern;
 import junit.framework.TestCase;
 
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.PathFilter;
 import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.hdfs.MiniDFSCluster;
 import org.apache.hadoop.mapred.JobHistory.*;
@@ -885,7 +887,32 @@ public class TestJobHistory extends Test
 
       assertTrue("Completed job and config file aren't in the same directory",
                  confFile.getParent().toString().equals(logFile.getParent().toString()));
+
+      // Test that all of the ancestors of the log file have the same
+      //   permissions as the done directory
       
+      Path cursor = logFile.getParent();
+
+      Path doneParent = doneDir.getParent();
+
+      FsPermission donePermission = getStatus(fileSys, doneDir).getPermission();
+
+      System.err.println("testDoneFolderOnHDFS: done dir permission = "
+                         + donePermission);
+
+      while (!cursor.equals(doneParent)) {
+        FileStatus cursorStatus = getStatus(fileSys, cursor);
+        FsPermission cursorPermission = cursorStatus.getPermission();
+
+        assertEquals("testDoneFolderOnHDFS: A done directory descendant, "
+                     + cursor
+                     + " does not have the same permisison as the done directory, "
+                     + doneDir,
+                     donePermission,
+                     cursorPermission);
+
+        cursor = cursor.getParent();
+      }      
 
       // check if the job file is removed from the history location 
       Path runningJobsHistoryFolder = logFile.getParent().getParent();
@@ -910,6 +937,26 @@ public class TestJobHistory extends Test
     }
   }
 
+  private static FileStatus getStatus(FileSystem fs, final Path path) {
+    Path pathParent = path.getParent();
+
+    try {
+      FileStatus[] statuses
+        = fs.listStatus(pathParent,
+                        new PathFilter() {
+                          @Override
+                            public boolean accept(Path filterPath) {
+                            return filterPath.getName().equals(path.getName());
+                          }
+                        }
+                        );
+
+      return statuses[0];
+    } catch (IOException e) {
+      return null;
+    }
+  }
+
   /** Run a job that will be succeeded and validate its history file format
    *  and its content.
    */



Mime
View raw message