Author: cutting Date: Thu May 17 12:55:52 2007 New Revision: 539093 URL: http://svn.apache.org/viewvc?view=rev&rev=539093 Log: HADOOP-1368. Fix inconsistent synchronization in JobInProgress. Contributed by Owen.
Modified: lucene/hadoop/trunk/CHANGES.txt lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/JobInProgress.java lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/JobStatus.java Modified: lucene/hadoop/trunk/CHANGES.txt URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/CHANGES.txt?view=diff&rev=539093&r1=539092&r2=539093 ============================================================================== --- lucene/hadoop/trunk/CHANGES.txt (original) +++ lucene/hadoop/trunk/CHANGES.txt Thu May 17 12:55:52 2007 @@ -422,6 +422,9 @@ 118. HADOOP-1363. Fix locking bug in JobClient#waitForCompletion(). (omalley via cutting) +119. HADOOP-1368. Fix inconsistent synchronization in JobInProgress. + (omalley via cutting) + Release 0.12.3 - 2007-04-06 Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/JobInProgress.java URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/JobInProgress.java?view=diff&rev=539093&r1=539092&r2=539093 ============================================================================== --- lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/JobInProgress.java (original) +++ lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/JobInProgress.java Thu May 17 12:55:52 2007 @@ -220,7 +220,9 @@ // Finished time need to be setted here to prevent this job to be retired // from the job tracker jobs at the next retire iteration. this.finishTime = System.currentTimeMillis(); - this.status = new JobStatus(status.getJobId(), 1.0f, 1.0f, JobStatus.SUCCEEDED); + status.setMapProgress(1.0f); + status.setReduceProgress(1.0f); + status.setRunState(JobStatus.SUCCEEDED); tasksInited = true; // Special case because the Job is not queued @@ -263,7 +265,7 @@ public int desiredMaps() { return numMapTasks; } - public int finishedMaps() { + public synchronized int finishedMaps() { return finishedMapTasks; } public int desiredReduces() { @@ -275,7 +277,7 @@ public synchronized int runningReduces() { return runningReduceTasks; } - public int finishedReduces() { + public synchronized int finishedReduces() { return finishedReduceTasks; } @@ -485,8 +487,9 @@ /** * Return a MapTask, if appropriate, to run on the given tasktracker */ - public Task obtainNewMapTask(TaskTrackerStatus tts, int clusterSize - ) throws IOException { + public synchronized Task obtainNewMapTask(TaskTrackerStatus tts, + int clusterSize + ) throws IOException { if (!tasksInited) { LOG.info("Cannot create task split for " + profile.getJobId()); return null; @@ -513,8 +516,9 @@ * We don't have cache-sensitivity for reduce tasks, as they * work on temporary MapRed files. */ - public Task obtainNewReduceTask(TaskTrackerStatus tts, - int clusterSize) throws IOException { + public synchronized Task obtainNewReduceTask(TaskTrackerStatus tts, + int clusterSize + ) throws IOException { if (!tasksInited) { LOG.info("Cannot create task split for " + profile.getJobId()); return null; Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/JobStatus.java URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/JobStatus.java?view=diff&rev=539093&r1=539092&r2=539093 ============================================================================== --- lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/JobStatus.java (original) +++ lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/JobStatus.java Thu May 17 12:55:52 2007 @@ -30,8 +30,6 @@ * Describes the current status of a job. This is * not intended to be a comprehensive piece of data. * For that, look at JobProfile. - * - * @author Mike Cafarella **************************************************/ public class JobStatus implements Writable { @@ -83,39 +81,38 @@ /** * @return Percentage of progress in maps */ - public float mapProgress() { return mapProgress; } + public synchronized float mapProgress() { return mapProgress; } /** * Sets the map progress of this job * @param p The value of map progress to set to */ - void setMapProgress(float p) { + synchronized void setMapProgress(float p) { this.mapProgress = (float) Math.min(1.0, Math.max(0.0, p)); - } /** * @return Percentage of progress in reduce */ - public float reduceProgress() { return reduceProgress; } + public synchronized float reduceProgress() { return reduceProgress; } /** * Sets the reduce progress of this Job * @param p The value of reduce progress to set to */ - void setReduceProgress(float p) { + synchronized void setReduceProgress(float p) { this.reduceProgress = (float) Math.min(1.0, Math.max(0.0, p)); } /** * @return running state of the job */ - public int getRunState() { return runState; } + public synchronized int getRunState() { return runState; } /** * Change the current run state of the job. */ - public void setRunState(int state) { + public synchronized void setRunState(int state) { this.runState = state; } @@ -123,22 +120,22 @@ * Set the start time of the job * @param startTime The startTime of the job */ - void setStartTime(long startTime) { this.startTime = startTime;}; + synchronized void setStartTime(long startTime) { this.startTime = startTime;} /** * @return start time of the job */ - public long getStartTime() { return startTime;}; + synchronized public long getStartTime() { return startTime;} /** * @param user The username of the job */ - void setUsername(String userName) { this.user = userName;}; + synchronized void setUsername(String userName) { this.user = userName;} /** * @return the username of the job */ - public String getUsername() { return this.user;}; + public synchronized String getUsername() { return this.user;} /////////////////////////////////////// // Writable