Skip to content

Commit

Permalink
LIHADOOP-20392: NullPointerException on zero mappers or reducers
Browse files Browse the repository at this point in the history
  • Loading branch information
nntnag17 committed May 27, 2016
1 parent d8baeb5 commit 12ea974
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ public void aggregate(HadoopApplicationData hadoopData) {

long reduceIdealStartTime = mapTasks.getNthPercentileFinishTime(reduceTaskSlowStartPercentage);

// Mappers list is empty
if(reduceIdealStartTime == -1) {
// ideal start time for reducer is infinite since it cannot start
reduceIdealStartTime = Long.MAX_VALUE;
}

reduceTasks = new TaskLevelAggregatedMetrics(data.getReducerData(), reduceTaskContainerSize, reduceIdealStartTime);

_hadoopAggregatedData.setResourceUsed(mapTasks.getResourceUsed() + reduceTasks.getResourceUsed());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public class TaskLevelAggregatedMetrics {
*/
public long getNthPercentileFinishTime(int percentile)
{
if(finishTimes == null || finishTimes.size() == 0 ) {
return -1;
}
return Statistics.percentile(finishTimes, percentile);
}

Expand Down Expand Up @@ -98,7 +101,7 @@ private void compute(MapReduceTaskData[] taskDatas, long containerSize, long ide
long taskDurationMax = 0;

// if there are zero tasks, then nothing to compute.
if(taskDatas.length == 0) {
if(taskDatas == null || taskDatas.length == 0) {
return;
}

Expand Down Expand Up @@ -133,6 +136,11 @@ private void compute(MapReduceTaskData[] taskDatas, long containerSize, long ide
// Compute the delay in starting the task.
_delay = taskFinishTimeMax - (idealStartTime + taskDurationMax);

// invalid delay
if(_delay < 0) {
_delay = 0;
}

// wastedResources
long wastedMemory = containerSize - (long) (peakMemoryNeed * MEMORY_BUFFER); // give a 50% buffer
if(wastedMemory > 0) {
Expand Down
Binary file modified public/images/runtime.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/usedmemory.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/waittime.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/wastedmemory.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ public void testZeroTasks() {
Assert.assertEquals(taskMetrics.getResourceWasted(), 0);
}

@Test
public void testNullTaskArray() {
TaskLevelAggregatedMetrics taskMetrics = new TaskLevelAggregatedMetrics(null, 0, 0);
Assert.assertEquals(taskMetrics.getDelay(), 0);
Assert.assertEquals(taskMetrics.getResourceUsed(), 0);
Assert.assertEquals(taskMetrics.getResourceWasted(), 0);
}

@Test
public void testTaskLevelData() {
MapReduceTaskData taskData[] = new MapReduceTaskData[2];
Expand Down

0 comments on commit 12ea974

Please sign in to comment.