Author: acmurthy Date: Sat Aug 13 20:27:21 2011 New Revision: 1157423 URL: http://svn.apache.org/viewvc?rev=1157423&view=rev Log: MAPREDUCE-2727. Fix divide-by-zero error in SleepJob for sleepCount equals 0. Contributed by Jeffrey Naisbitt.
Modified: hadoop/common/branches/MR-279/mapreduce/CHANGES.txt hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/SleepJob.java hadoop/common/branches/MR-279/mapreduce/src/test/mapred/org/apache/hadoop/mapreduce/SleepJob.java Modified: hadoop/common/branches/MR-279/mapreduce/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/CHANGES.txt?rev=1157423&r1=1157422&r2=1157423&view=diff ============================================================================== --- hadoop/common/branches/MR-279/mapreduce/CHANGES.txt (original) +++ hadoop/common/branches/MR-279/mapreduce/CHANGES.txt Sat Aug 13 20:27:21 2011 @@ -4,6 +4,9 @@ Trunk (unreleased changes) MAPREDUCE-279 + MAPREDUCE-2727. Fix divide-by-zero error in SleepJob for sleepCount equals + 0. (Jeffrey Naisbitt via acmurthy) + MAPREDUCE-2839. Fixed TokenCache to get delegation tokens using both new and old apis. (Siddharth Seth via acmurthy) Modified: hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/SleepJob.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/SleepJob.java?rev=1157423&r1=1157422&r2=1157423&view=diff ============================================================================== --- hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/SleepJob.java (original) +++ hadoop/common/branches/MR-279/mapreduce/mr-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/SleepJob.java Sat Aug 13 20:27:21 2011 @@ -108,6 +108,9 @@ public class SleepJob extends Configured public boolean nextKeyValue() throws IOException { + if (count == 0) { + return false; + } key = new IntWritable(); key.set(emitCount); int emit = emitPerMapTask / count; @@ -123,7 +126,7 @@ public class SleepJob extends Configured public IntWritable getCurrentValue() { return value; } public void close() throws IOException { } public float getProgress() throws IOException { - return records / ((float)count); + return count == 0 ? 100 : records / ((float)count); } }; } @@ -140,7 +143,7 @@ public class SleepJob extends Configured Configuration conf = context.getConfiguration(); this.mapSleepCount = conf.getInt(MAP_SLEEP_COUNT, mapSleepCount); - this.mapSleepDuration = + this.mapSleepDuration = mapSleepCount == 0 ? 0 : conf.getLong(MAP_SLEEP_TIME , 100) / mapSleepCount; } @@ -177,7 +180,7 @@ public class SleepJob extends Configured Configuration conf = context.getConfiguration(); this.reduceSleepCount = conf.getInt(REDUCE_SLEEP_COUNT, reduceSleepCount); - this.reduceSleepDuration = + this.reduceSleepDuration = reduceSleepCount == 0 ? 0 : conf.getLong(REDUCE_SLEEP_TIME , 100) / reduceSleepCount; } @@ -239,7 +242,7 @@ public class SleepJob extends Configured ToolRunner.printGenericCommandUsage(System.err); return 2; } - + int numMapper = 1, numReducer = 1; long mapSleepTime = 100, reduceSleepTime = 100, recSleepTime = 100; int mapSleepCount = 1, reduceSleepCount = 1; Modified: hadoop/common/branches/MR-279/mapreduce/src/test/mapred/org/apache/hadoop/mapreduce/SleepJob.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-279/mapreduce/src/test/mapred/org/apache/hadoop/mapreduce/SleepJob.java?rev=1157423&r1=1157422&r2=1157423&view=diff ============================================================================== --- hadoop/common/branches/MR-279/mapreduce/src/test/mapred/org/apache/hadoop/mapreduce/SleepJob.java (original) +++ hadoop/common/branches/MR-279/mapreduce/src/test/mapred/org/apache/hadoop/mapreduce/SleepJob.java Sat Aug 13 20:27:21 2011 @@ -97,6 +97,9 @@ public class SleepJob extends Configured public boolean nextKeyValue() throws IOException { + if (count == 0) { + return false; + } key = new IntWritable(); key.set(emitCount); int emit = emitPerMapTask / count; @@ -112,7 +115,7 @@ public class SleepJob extends Configured public IntWritable getCurrentValue() { return value; } public void close() throws IOException { } public float getProgress() throws IOException { - return records / ((float)count); + return count == 0 ? 100 : records / ((float)count); } }; } @@ -129,7 +132,7 @@ public class SleepJob extends Configured Configuration conf = context.getConfiguration(); this.mapSleepCount = conf.getInt(MAP_SLEEP_COUNT, mapSleepCount); - this.mapSleepDuration = + this.mapSleepDuration = mapSleepCount == 0 ? 0 : conf.getLong(MAP_SLEEP_TIME , 100) / mapSleepCount; } @@ -166,7 +169,7 @@ public class SleepJob extends Configured Configuration conf = context.getConfiguration(); this.reduceSleepCount = conf.getInt(REDUCE_SLEEP_COUNT, reduceSleepCount); - this.reduceSleepDuration = + this.reduceSleepDuration = reduceSleepCount == 0 ? 0 : conf.getLong(REDUCE_SLEEP_TIME , 100) / reduceSleepCount; }