Browse Source

commit 29cbffa625f517765dea4ccfa949322bd0e1283a
Author: Arun C Murthy <acmurthy@apache.org>
Date: Thu Jul 15 19:40:51 2010 -0700

MAPREDUCE-323. Added versioning to JobHistory directories to be future-proof.


git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.20-security-patches@1077548 13f79535-47bb-0310-9956-ffa450edef68

Owen O'Malley 14 years ago
parent
commit
a8037edb59

+ 12 - 2
src/mapred/org/apache/hadoop/mapred/JobHistory.java

@@ -92,6 +92,12 @@ import org.apache.hadoop.util.StringUtils;
 public class JobHistory {
   
   static final long VERSION = 1L;
+
+  static final int DONE_DIRECTORY_FORMAT_VERSION = 1;
+
+  static final String DONE_DIRECTORY_FORMAT_DIRNAME
+    = "version-" + DONE_DIRECTORY_FORMAT_VERSION;
+
   public static final Log LOG = LogFactory.getLog(JobHistory.class);
   private static final char DELIMITER = ' ';
   static final char LINE_DELIMITER_CHAR = '.';
@@ -411,7 +417,9 @@ public class JobHistory {
   }
 
   private static String historyLogSubdirectory(JobID id, long millisecondTime) {
-    String result = jobtrackerDirectoryComponent(id);
+    String result
+      = (DONE_DIRECTORY_FORMAT_DIRNAME
+         + "/" + jobtrackerDirectoryComponent(id));
 
     String serialNumberDirectory = serialNumberDirectoryComponent(id);
 
@@ -429,7 +437,9 @@ public class JobHistory {
 
   private static String doneSubdirsBeforeSerialTail() {
     // job tracker ID
-    String result = "/*";   // job tracker instance ID
+    String result
+      = ("/" + DONE_DIRECTORY_FORMAT_DIRNAME
+         + "/*");   // job tracker instance ID
 
     // date
     result = result + "/*/*/*";  // YYYY/MM/DD ;

+ 7 - 0
src/test/org/apache/hadoop/mapred/TestJobHistory.java

@@ -473,6 +473,13 @@ public class TestJobHistory extends TestCase {
     // Check if the history file exists
     assertTrue("History file does not exist", fileSys.exists(logFile));
 
+    // Check that the log file name includes a directory level for the version number
+    assertTrue("History filename does not include a directory level "
+                 + "for the version number.",
+               logFile.toString()
+                 .contains("/"
+                           + JobHistory.DONE_DIRECTORY_FORMAT_DIRNAME
+                           + "/"));
 
     // check if the history file is parsable
     String[] jobDetails = JobHistory.JobInfo.decodeJobHistoryFileName(

+ 5 - 1
src/webapps/job/jobhistory.jsp

@@ -182,6 +182,8 @@ window.location.href = url;
       }
     };
 
+    String versionComponent = JobHistory.DONE_DIRECTORY_FORMAT_DIRNAME;
+
     String trackerComponent = "*";
 
     // build the glob
@@ -214,7 +216,9 @@ window.location.href = url;
     // number directories, but not the individual files.
     Path historyPath = new Path(historyLogDir);
 
-    String leadGlob = (trackerComponent + "/" + dateComponent);
+    String leadGlob = (versionComponent
+            + "/" + trackerComponent
+            + "/" + dateComponent);
 
     // Atomicity is unimportant here.
     // I would have used MutableBoxedBoolean if such had been provided.