hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r753114 - in /hadoop/core/branches/branch-0.20: ./ CHANGES.txt src/mapred/org/apache/hadoop/mapred/JobHistory.java src/test/org/apache/hadoop/mapred/TestJobHistory.java
Date Fri, 13 Mar 2009 05:04:28 GMT
Author: ddas
Date: Fri Mar 13 05:04:28 2009
New Revision: 753114

URL: http://svn.apache.org/viewvc?rev=753114&view=rev
Log:
Merge -r 753111:753113 from trunk onto 0.20 branch. Fixes HADOOP-5449.

Modified:
    hadoop/core/branches/branch-0.20/   (props changed)
    hadoop/core/branches/branch-0.20/CHANGES.txt   (contents, props changed)
    hadoop/core/branches/branch-0.20/src/mapred/org/apache/hadoop/mapred/JobHistory.java
    hadoop/core/branches/branch-0.20/src/test/org/apache/hadoop/mapred/TestJobHistory.java

Propchange: hadoop/core/branches/branch-0.20/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Mar 13 05:04:28 2009
@@ -1,2 +1,2 @@
 /hadoop/core/branches/branch-0.19:713112
-/hadoop/core/trunk:727001,727117,727191,727212,727217,727228,727255,727869,728187,729052,729987,732385,732572,732613,732777,732838,732869,733887,734870,734916,736426,738328,738697,740077,740157,741703,741762,743745,743816,743892,744894,745180,746010,746206,746227,746233,746274,746902-746903,746944,746968,746970,747279,747289,747802,748084,748090,748783,749262,749318,749863,750533,752073,752609,752834,752836,752913,752932
+/hadoop/core/trunk:727001,727117,727191,727212,727217,727228,727255,727869,728187,729052,729987,732385,732572,732613,732777,732838,732869,733887,734870,734916,736426,738328,738697,740077,740157,741703,741762,743745,743816,743892,744894,745180,746010,746206,746227,746233,746274,746902-746903,746944,746968,746970,747279,747289,747802,748084,748090,748783,749262,749318,749863,750533,752073,752609,752834,752836,752913,752932,753112-753113

Modified: hadoop/core/branches/branch-0.20/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.20/CHANGES.txt?rev=753114&r1=753113&r2=753114&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.20/CHANGES.txt (original)
+++ hadoop/core/branches/branch-0.20/CHANGES.txt Fri Mar 13 05:04:28 2009
@@ -755,6 +755,9 @@
  
     HADOOP-5446. Restore TaskTracker metrics. (cdouglas)
 
+    HADOOP-5449. Fixes the history cleaner thread. 
+    (Amareshwari Sriramadasu via ddas)
+
 Release 0.19.1 - Unreleased
 
   IMPROVEMENTS

Propchange: hadoop/core/branches/branch-0.20/CHANGES.txt
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Mar 13 05:04:28 2009
@@ -1,3 +1,3 @@
 /hadoop/core/branches/branch-0.18/CHANGES.txt:727226
 /hadoop/core/branches/branch-0.19/CHANGES.txt:713112
-/hadoop/core/trunk/CHANGES.txt:727001,727117,727191,727212,727228,727255,727869,728187,729052,729987,732385,732572,732613,732777,732838,732869,733887,734870,734916,735082,736426,738602,738697,739416,740077,740157,741703,741762,743296,743745,743816,743892,744894,745180,745268,746010,746193,746206,746227,746233,746274,746902-746903,746944,746968,746970,747279,747289,747802,748084,748090,748783,749262,749318,749863,750533,752073,752514,752555,752590,752609,752834,752836,752913,752932
+/hadoop/core/trunk/CHANGES.txt:727001,727117,727191,727212,727228,727255,727869,728187,729052,729987,732385,732572,732613,732777,732838,732869,733887,734870,734916,735082,736426,738602,738697,739416,740077,740157,741703,741762,743296,743745,743816,743892,744894,745180,745268,746010,746193,746206,746227,746233,746274,746902-746903,746944,746968,746970,747279,747289,747802,748084,748090,748783,749262,749318,749863,750533,752073,752514,752555,752590,752609,752834,752836,752913,752932,753112-753113

Modified: hadoop/core/branches/branch-0.20/src/mapred/org/apache/hadoop/mapred/JobHistory.java
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.20/src/mapred/org/apache/hadoop/mapred/JobHistory.java?rev=753114&r1=753113&r2=753114&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.20/src/mapred/org/apache/hadoop/mapred/JobHistory.java (original)
+++ hadoop/core/branches/branch-0.20/src/mapred/org/apache/hadoop/mapred/JobHistory.java Fri
Mar 13 05:04:28 2009
@@ -98,6 +98,7 @@
   private static final String SECONDARY_FILE_SUFFIX = ".recover";
   private static long jobHistoryBlockSize = 0;
   private static String jobtrackerHostname;
+  private static JobConf jtConf;
   /**
    * Record types are identifiers for each line of log in history files. 
    * A record type appears as the first token in a single line of log. 
@@ -163,6 +164,7 @@
       jobHistoryBlockSize = 
         conf.getLong("mapred.jobtracker.job.history.block.size", 
                      3 * 1024 * 1024);
+      jtConf = conf;
     } catch(IOException e) {
         LOG.error("Failed to initialize JobHistory log file", e); 
         disableHistory = true;
@@ -1678,7 +1680,7 @@
     static final long THIRTY_DAYS_IN_MS = 30 * ONE_DAY_IN_MS;
     private long now; 
     private static boolean isRunning = false; 
-    private static long lastRan; 
+    private static long lastRan = 0; 
 
     /**
      * Cleans up history data. 
@@ -1689,26 +1691,34 @@
       }
       now = System.currentTimeMillis();
       // clean history only once a day at max
-      if (lastRan ==0 || (now - lastRan) < ONE_DAY_IN_MS){
+      if (lastRan != 0 && (now - lastRan) < ONE_DAY_IN_MS) {
         return; 
       }
       lastRan = now;  
       isRunning = true; 
-      File[] oldFiles = new File(LOG_DIR).listFiles(new FileFilter(){
-          public boolean accept(File file){
-            // delete if older than 30 days
-            if (now - file.lastModified() > THIRTY_DAYS_IN_MS){
-              return true; 
+      try {
+        Path logDir = new Path(LOG_DIR);
+        FileSystem fs = logDir.getFileSystem(jtConf);
+        FileStatus[] historyFiles = fs.listStatus(logDir);
+        // delete if older than 30 days
+        if (historyFiles != null) {
+          for (FileStatus f : historyFiles) {
+            if (now - f.getModificationTime() > THIRTY_DAYS_IN_MS) {
+              fs.delete(f.getPath(), true); 
+              LOG.info("Deleting old history file : " + f.getPath());
             }
-            return false; 
           }
-        });
-      for(File f : oldFiles){
-        f.delete(); 
-        LOG.info("Deleting old history file : " + f.getName());
+        }
+      } catch (IOException ie) {
+        LOG.info("Error cleaning up history directory" + 
+                 StringUtils.stringifyException(ie));
       }
       isRunning = false; 
     }
+    
+    static long getLastRan() {
+      return lastRan;
+    }
   }
 
   /**

Modified: hadoop/core/branches/branch-0.20/src/test/org/apache/hadoop/mapred/TestJobHistory.java
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.20/src/test/org/apache/hadoop/mapred/TestJobHistory.java?rev=753114&r1=753113&r2=753114&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.20/src/test/org/apache/hadoop/mapred/TestJobHistory.java
(original)
+++ hadoop/core/branches/branch-0.20/src/test/org/apache/hadoop/mapred/TestJobHistory.java
Fri Mar 13 05:04:28 2009
@@ -970,16 +970,20 @@
       // existing in history file
       RunningJob job = UtilsForTests.runJobSucceed(conf, inDir, outDir);
       validateJobHistoryJobStatus(job.getID(), conf, "SUCCESS");
+      long historyCleanerRanAt = JobHistory.HistoryCleaner.getLastRan();
+      assertTrue(historyCleanerRanAt != 0);
       
       // Run a job that will be failed and validate its job status
       // existing in history file
       job = UtilsForTests.runJobFail(conf, inDir, outDir);
       validateJobHistoryJobStatus(job.getID(), conf, "FAILED");
+      assertTrue(historyCleanerRanAt == JobHistory.HistoryCleaner.getLastRan());
       
       // Run a job that will be killed and validate its job status
       // existing in history file
       job = UtilsForTests.runJobKill(conf, inDir, outDir);
       validateJobHistoryJobStatus(job.getID(), conf, "KILLED");
+      assertTrue(historyCleanerRanAt == JobHistory.HistoryCleaner.getLastRan());
       
     } finally {
       if (mr != null) {



Mime
View raw message