You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by om...@apache.org on 2011/03/04 05:21:41 UTC

svn commit: r1077505 - in /hadoop/common/branches/branch-0.20-security-patches/src: mapred/org/apache/hadoop/mapred/CompletedJobStatusStore.java test/org/apache/hadoop/mapred/TestJobStatusPersistency.java

Author: omalley
Date: Fri Mar  4 04:21:41 2011
New Revision: 1077505

URL: http://svn.apache.org/viewvc?rev=1077505&view=rev
Log:
commit 52e16cc8832c8f293e75dc4820fbf1c371d54602
Author: Arun C Murthy <ac...@apache.org>
Date:   Tue Jun 15 18:58:56 2010 -0700

    MAPREDUCE-1778. Ensure failure to setup CompletedJobStatusStore is not silently ignored by the JobTracker. Contributed by Krishna Ramachandran.
    
    +++ b/YAHOO-CHANGES.txt
    +    MAPREDUCE-1778. Ensure failure to setup CompletedJobStatusStore is not
    +    silently ignored by the JobTracker. (Krishna Ramachandran via acmurthy)
    +

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

Modified: hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/CompletedJobStatusStore.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/CompletedJobStatusStore.java?rev=1077505&r1=1077504&r2=1077505&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/CompletedJobStatusStore.java (original)
+++ hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/CompletedJobStatusStore.java Fri Mar  4 04:21:41 2011
@@ -30,6 +30,9 @@ import org.apache.hadoop.fs.Path;
 
 import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.hadoop.security.AccessControlException;
+import org.apache.hadoop.fs.permission.FsAction;
+import org.apache.hadoop.fs.permission.FsPermission;
+import org.apache.hadoop.util.DiskChecker.DiskErrorException;
 
 /**
  * Persists and retrieves the Job info of a job into/from DFS.
@@ -55,7 +58,8 @@ class CompletedJobStatusStore implements
 
   private static long HOUR = 1000 * 60 * 60;
   private static long SLEEP_TIME = 1 * HOUR;
-
+  final static FsPermission JOB_STATUS_STORE_DIR_PERMISSION = FsPermission
+      .createImmutable((short) 0750); // rwxr-x--
 
   CompletedJobStatusStore(Configuration conf, ACLsManager aclsManager)
       throws IOException {
@@ -74,12 +78,24 @@ class CompletedJobStatusStore implements
       // set the fs
       this.fs = path.getFileSystem(conf);
       if (!fs.exists(path)) {
-        if (!fs.mkdirs(path)) {
-          active = false;
-          LOG.warn("Couldn't create " + jobInfoDir
-              + ". CompletedJobStore will be inactive.");
-          return;
-        }
+        if (!fs.mkdirs(path, new FsPermission(JOB_STATUS_STORE_DIR_PERMISSION))) {
+          throw new IOException(
+              "CompletedJobStatusStore mkdirs failed to create "
+                  + path.toString());
+        }
+      } else {
+        FileStatus stat = fs.getFileStatus(path);
+        FsPermission actual = stat.getPermission();
+        if (!stat.isDir())
+          throw new DiskErrorException("not a directory: "
+                                   + path.toString());
+        FsAction user = actual.getUserAction();
+        if (!user.implies(FsAction.READ))
+          throw new DiskErrorException("directory is not readable: "
+                                   + path.toString());
+        if (!user.implies(FsAction.WRITE))
+          throw new DiskErrorException("directory is not writable: "
+                                   + path.toString());
       }
 
       if (retainTime == 0) {

Modified: hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/TestJobStatusPersistency.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/TestJobStatusPersistency.java?rev=1077505&r1=1077504&r2=1077505&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/TestJobStatusPersistency.java (original)
+++ hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/TestJobStatusPersistency.java Fri Mar  4 04:21:41 2011
@@ -21,6 +21,7 @@ import java.io.File;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
 import java.io.Writer;
+import java.io.IOException;
 import java.util.Properties;
 
 import org.apache.hadoop.fs.FileSystem;
@@ -167,15 +168,15 @@ public class TestJobStatusPersistency ex
       config.set("mapred.job.tracker.persist.jobstatus.hours", "1");
       config.set("mapred.job.tracker.persist.jobstatus.dir", new Path(parent,
           "child").toUri().getPath());
-      mr = new MiniMRCluster(0, "file:///", 4, null, null, config);
-      assertFalse(
-          "CompletedJobStore is unexpectly active!",
-          mr.getJobTrackerRunner().getJobTracker().completedJobStatusStore.isActive());
+      boolean started = true;
+      JobConf conf = MiniMRCluster.configureJobConf(config, "file:///", 0, 0, null);
+      try {
+        JobTracker jt = JobTracker.startTracker(conf);
+      } catch (IOException ex) {
+        started = false;
+      }
     } finally {
       new File(parent.toUri().getPath()).setWritable(true, false);
-      if (mr != null) {
-        mr.shutdown();
-      }
     }
   }
 }