* @throws IOException
*/
static JobInfo getJobInfo(Path logFile, FileSystem fs,
JobConf jobConf, ACLsManager acLsManager, String user) throws IOException {
String jobid = getJobID(logFile.getName());
JobInfo jobInfo = null;
synchronized(jobHistoryCache) {
jobInfo = jobHistoryCache.remove(jobid);
if (jobInfo == null) {
jobInfo = new JobHistory.JobInfo(jobid);
LOG.info("Loading Job History file "+jobid + ". Cache size is " +
jobHistoryCache.size());
DefaultJobHistoryParser.parseJobTasks(logFile.toUri().getPath(),
jobInfo, fs);
}
jobHistoryCache.put(jobid, jobInfo);
int CACHE_SIZE =
jobConf.getInt("mapred.job.tracker.jobhistory.lru.cache.size", 5);
if (jobHistoryCache.size() > CACHE_SIZE) {
Iterator<Map.Entry<String, JobInfo>> it =
jobHistoryCache.entrySet().iterator();
String removeJobId = it.next().getKey();
it.remove();
LOG.info("Job History file removed form cache "+removeJobId);
}
}
UserGroupInformation currentUser;
if (user == null) {
currentUser = UserGroupInformation.getCurrentUser();
} else {
currentUser = UserGroupInformation.createRemoteUser(user);
}
// Authorize the user for view access of this job
acLsManager.checkAccess(jobid, currentUser,
jobInfo.getJobQueue(), Operation.VIEW_JOB_DETAILS,
jobInfo.get(Keys.USER), jobInfo.getJobACLs().get(JobACL.VIEW_JOB));
return jobInfo;
}