Skip to content
This repository has been archived by the owner on Feb 9, 2021. It is now read-only.

Commit

Permalink
MAPREDUCE-2727. Fix divide-by-zero error in SleepJob for sleepCount e…
Browse files Browse the repository at this point in the history
…quals 0. Contributed by Jeffrey Naisbitt.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/MR-279@1157423 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
acmurthy committed Aug 13, 2011
1 parent 45cc78b commit 844a8e7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
3 changes: 3 additions & 0 deletions mapreduce/CHANGES.txt
Expand Up @@ -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)

Expand Down
Expand Up @@ -108,6 +108,9 @@ public void initialize(InputSplit split, TaskAttemptContext context) {

public boolean nextKeyValue()
throws IOException {
if (count == 0) {
return false;
}
key = new IntWritable();
key.set(emitCount);
int emit = emitPerMapTask / count;
Expand All @@ -123,7 +126,7 @@ public boolean nextKeyValue()
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);
}
};
}
Expand All @@ -140,7 +143,7 @@ protected void setup(Context context)
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;
}

Expand Down Expand Up @@ -177,7 +180,7 @@ protected void setup(Context context)
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;
}

Expand Down Expand Up @@ -239,7 +242,7 @@ public int run(String[] args) throws Exception {
ToolRunner.printGenericCommandUsage(System.err);
return 2;
}

int numMapper = 1, numReducer = 1;
long mapSleepTime = 100, reduceSleepTime = 100, recSleepTime = 100;
int mapSleepCount = 1, reduceSleepCount = 1;
Expand Down
Expand Up @@ -97,6 +97,9 @@ public void initialize(InputSplit split, TaskAttemptContext context) {

public boolean nextKeyValue()
throws IOException {
if (count == 0) {
return false;
}
key = new IntWritable();
key.set(emitCount);
int emit = emitPerMapTask / count;
Expand All @@ -112,7 +115,7 @@ public boolean nextKeyValue()
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);
}
};
}
Expand All @@ -129,7 +132,7 @@ protected void setup(Context context)
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;
}

Expand Down Expand Up @@ -166,7 +169,7 @@ protected void setup(Context context)
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;
}

Expand Down

0 comments on commit 844a8e7

Please sign in to comment.