浏览代码

Merge -r 722912:722913 from trunk to 0.19 branch. Fixes: HADOOP-4420.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/branches/branch-0.19@722921 13f79535-47bb-0310-9956-ffa450edef68
Thomas White 16 年之前
父节点
当前提交
642903ccee

+ 3 - 0
CHANGES.txt

@@ -12,6 +12,9 @@ Release 0.19.1 - Unreleased
     HADOOP-4697. Fix getBlockLocations in KosmosFileSystem to handle multiple
     blocks correctly. (Sriram Rao via cdouglas)
 
+    HADOOP-4420. Add null checks for job, caused by invalid job IDs.
+    (Aaron Kimball via tomwhite)
+
 Release 0.19.0 - 2008-11-18
 
   INCOMPATIBLE CHANGES

+ 6 - 0
src/mapred/org/apache/hadoop/mapred/CompletedJobStatusStore.java

@@ -219,6 +219,12 @@ class CompletedJobStatusStore implements Runnable {
    */
   public JobStatus readJobStatus(JobID jobId) {
     JobStatus jobStatus = null;
+    
+    if (null == jobId) {
+      LOG.warn("Could not read job status for null jobId");
+      return null;
+    }
+    
     if (active) {
       try {
         FSDataInputStream dataIn = getJobInfoFile(jobId);

+ 21 - 0
src/mapred/org/apache/hadoop/mapred/JobTracker.java

@@ -2285,7 +2285,18 @@ public class JobTracker implements MRConstants, InterTrackerProtocol,
   }
     
   public synchronized void killJob(JobID jobid) throws IOException {
+    if (null == jobid) {
+      LOG.info("Null jobid object sent to JobTracker.killJob()");
+      return;
+    }
+    
     JobInProgress job = jobs.get(jobid);
+    
+    if (null == job) {
+      LOG.info("killJob(): JobId " + jobid.toString() + " is not a valid job");
+      return;
+    }
+        
     JobStatus prevStatus = (JobStatus)job.getStatus().clone();
     checkAccess(job, QueueManager.QueueOperation.ADMINISTER_JOBS);
     job.kill();
@@ -2315,6 +2326,11 @@ public class JobTracker implements MRConstants, InterTrackerProtocol,
                                               String priority)
                                                 throws IOException {
     JobInProgress job = jobs.get(jobid);
+    if (null == job) {
+        LOG.info("setJobPriority(): JobId " + jobid.toString()
+            + " is not a valid job");
+        return;
+    }
     checkAccess(job, QueueManager.QueueOperation.ADMINISTER_JOBS);
     JobPriority newPriority = JobPriority.valueOf(priority);
     setJobPriority(jobid, newPriority);
@@ -2329,6 +2345,11 @@ public class JobTracker implements MRConstants, InterTrackerProtocol,
     }
   }
   public synchronized JobStatus getJobStatus(JobID jobid) {
+    if (null == jobid) {
+      LOG.warn("JobTracker.getJobStatus() cannot get status for null jobid");
+      return null;
+    }
+    
     JobInProgress job = jobs.get(jobid);
     if (job != null) {
       return job.getStatus();