浏览代码

Merge -r 648881:648882 from trunk to branch-0.17 to fix HADOOP-3263

git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/branches/branch-0.17@648885 13f79535-47bb-0310-9956-ffa450edef68
Arun Murthy 17 年之前
父节点
当前提交
a524d62116
共有 2 个文件被更改,包括 18 次插入8 次删除
  1. 5 0
      CHANGES.txt
  2. 13 8
      src/java/org/apache/hadoop/mapred/JobHistory.java

+ 5 - 0
CHANGES.txt

@@ -584,6 +584,11 @@ Release 0.17.0 - Unreleased
     HADOOP-3162. Ensure that comma-separated input paths are treated correctly
     as multiple input paths. (Amareshwari Sri Ramadasu via acmurthy)
 
+    HADOOP-3263. Ensure that the job-history log file always follows the
+    pattern of hostname_timestamp_jobid_username_jobname even if username
+    and/or jobname are not specfied. This helps to avoid wrong assumptions
+    made about the job-history log filename in jobhistory.jsp. (acmurthy) 
+
 Release 0.16.3 - 2008-04-16
 
   BUG FIXES

+ 13 - 8
src/java/org/apache/hadoop/mapred/JobHistory.java

@@ -70,7 +70,6 @@ public class JobHistory {
   private static final String VALUE = "[[^\"]?]+"; // anything but a " in ""
   
   private static final Pattern pattern = Pattern.compile(KEY + "=" + "\"" + VALUE + "\"");
-  private static final int MAX_FILENAME_SIZE = 255;
   
   public static final String JOBTRACKER_START_TIME =
                                String.valueOf(System.currentTimeMillis());
@@ -434,21 +433,27 @@ public class JobHistory {
     public static void logSubmitted(String jobId, JobConf jobConf, 
                                     String jobConfPath, long submitTime) 
     throws IOException {
-      String jobName = jobConf.getJobName();
-      String user = jobConf.getUser(); 
       FileSystem fs = null;
       String userLogDir = null;
       String jobUniqueString = JOBTRACKER_UNIQUE_STRING + jobId;
 
       if (!disableHistory){
+        // Get the username and job name to be used in the actual log filename;
+        // sanity check them too
+        String jobName = jobConf.getJobName();
+        if (jobName == null || jobName.length() == 0) {
+          jobName = "NA";
+        }
+
+        String user = jobConf.getUser();
+        if (user == null || user.length() == 0) {
+          user = "NA";
+        }
+        
         // setup the history log file for this job
         String logFileName = 
-            encodeJobHistoryFileName(jobUniqueString +  "_" + user+ "_" + 
+            encodeJobHistoryFileName(jobUniqueString +  "_" + user + "_" + 
                                      jobName);
-        
-        if (logFileName.length() > MAX_FILENAME_SIZE) {
-          logFileName = logFileName.substring(0, MAX_FILENAME_SIZE-1);
-        }
 
         // find user log directory 
         Path outputPath = FileOutputFormat.getOutputPath(jobConf);