Forráskód Böngészése

HADOOP-4420. Add null checks for job, caused by invalid job IDs. Contributed by Aaron Kimball.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/trunk@722913 13f79535-47bb-0310-9956-ffa450edef68
Thomas White 16 éve
szülő
commit
9928327368

+ 3 - 0
CHANGES.txt

@@ -244,6 +244,9 @@ Trunk (unreleased changes)
     HADOOP-4732. Pass connection and read timeouts in the correct order when
     setting up fetch in reduce. (Amareshwari Sriramadasu via cdouglas)
 
+    HADOOP-4420. Add null checks for job, caused by invalid job IDs.
+    (Aaron Kimball via tomwhite)
+
 Release 0.19.1 - Unreleased
 
   IMPROVEMENTS

+ 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

@@ -2292,7 +2292,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();
@@ -2322,6 +2333,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);
@@ -2336,6 +2352,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();