コード例 #1
0
ファイル: UserLogCleaner.java プロジェクト: ukulililixl/core
 /**
  * Clears all the logs in userlog directory.
  *
  * <p>Adds the job directories for deletion with default retain hours. Deletes all other
  * directories, if any. This is usually called on reinit/restart of the TaskTracker
  *
  * @param conf
  * @throws IOException
  */
 void clearOldUserLogs(Configuration conf) throws IOException {
   File userLogDir = TaskLog.getUserLogDir();
   if (userLogDir.exists()) {
     String[] logDirs = userLogDir.list();
     if (logDirs.length > 0) {
       // add all the log dirs to taskLogsMnonitor.
       long now = clock.getTime();
       for (String logDir : logDirs) {
         if (logDir.equals(logAsyncDisk.TOBEDELETED)) {
           // skip this
           continue;
         }
         JobID jobid = null;
         try {
           jobid = JobID.forName(logDir);
         } catch (IllegalArgumentException ie) {
           // if the directory is not a jobid, delete it immediately
           deleteLogPath(new File(userLogDir, logDir).getAbsolutePath());
           continue;
         }
         // add the job log directory with default retain hours, if it is not
         // already added
         if (!completedJobs.containsKey(jobid)) {
           markJobLogsForDeletion(now, conf, jobid);
         }
       }
     }
   }
 }
コード例 #2
0
ファイル: UserLogCleaner.java プロジェクト: ukulililixl/core
 void processCompletedJobs() throws IOException {
   long now = clock.getTime();
   // iterate through completedJobs and remove old logs.
   synchronized (completedJobs) {
     Iterator<Entry<JobID, Long>> completedJobIter = completedJobs.entrySet().iterator();
     while (completedJobIter.hasNext()) {
       Entry<JobID, Long> entry = completedJobIter.next();
       // see if the job is old enough
       if (entry.getValue().longValue() <= now) {
         // add the job logs directory to for delete
         deleteLogPath(TaskLog.getJobDir(entry.getKey()).getAbsolutePath());
         completedJobIter.remove();
       }
     }
   }
 }