Skip to content

Commit 39b2ace

Browse files
author
Ashutosh Gupta
committed
Disabling the ping check feature by default and added a test case for ping check feature
1 parent f242db0 commit 39b2ace

File tree

4 files changed

+38
-4
lines changed

4 files changed

+38
-4
lines changed

hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapred/TaskAttemptListenerImpl.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,10 @@ public AMFeedback statusUpdate(TaskAttemptID taskAttemptID,
410410
LOG.debug("Ping from " + taskAttemptID.toString());
411411
}
412412
// Consider ping from the tasks for liveliness check
413-
taskHeartbeatHandler.progressing(yarnAttemptID);
413+
if (getConfig().getBoolean(MRJobConfig.MR_TASK_ENABLE_PING_FOR_LIVELINESS_CHECK,
414+
MRJobConfig.DEFAULT_MR_TASK_ENABLE_PING_FOR_LIVELINESS_CHECK)) {
415+
taskHeartbeatHandler.progressing(yarnAttemptID);
416+
}
414417
return feedback;
415418
}
416419

hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapred/TestTaskAttemptListenerImpl.java

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -415,18 +415,35 @@ public void testStatusUpdateProgress()
415415
startListener(true);
416416
verify(hbHandler).register(attemptId);
417417

418-
// make sure a ping does report progress
418+
// make sure a ping doesn't report progress
419419
AMFeedback feedback = listener.statusUpdate(attemptID, null);
420420
assertTrue(feedback.getTaskFound());
421-
verify(hbHandler, times(1)).progressing(eq(attemptId));
421+
verify(hbHandler, never()).progressing(eq(attemptId));
422422

423423
// make sure a status update does report progress
424424
MapTaskStatus mockStatus = new MapTaskStatus(attemptID, 0.0f, 1,
425425
TaskStatus.State.RUNNING, "", "RUNNING", "", TaskStatus.Phase.MAP,
426426
new Counters());
427427
feedback = listener.statusUpdate(attemptID, mockStatus);
428428
assertTrue(feedback.getTaskFound());
429-
verify(hbHandler, times(2)).progressing(eq(attemptId));
429+
verify(hbHandler).progressing(eq(attemptId));
430+
}
431+
432+
@Test
433+
public void testPingUpdateProgress() throws IOException, InterruptedException {
434+
configureMocks();
435+
Configuration conf = new Configuration();
436+
conf.setBoolean(MRJobConfig.MR_TASK_ENABLE_PING_FOR_LIVELINESS_CHECK, true);
437+
listener.init(conf);
438+
listener.start();
439+
listener.registerPendingTask(task, wid);
440+
listener.registerLaunchedTask(attemptId, wid);
441+
verify(hbHandler).register(attemptId);
442+
443+
// make sure a ping does report progress
444+
AMFeedback feedback = listener.statusUpdate(attemptID, null);
445+
assertTrue(feedback.getTaskFound());
446+
verify(hbHandler, times(1)).progressing(eq(attemptId));
430447
}
431448

432449
@Test

hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/MRJobConfig.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,13 @@ public interface MRJobConfig {
919919
MR_AM_PREFIX + "scheduler.heartbeat.interval-ms";
920920
public static final int DEFAULT_MR_AM_TO_RM_HEARTBEAT_INTERVAL_MS = 1000;
921921

922+
/** Whether to consider ping from tasks in liveliness check. */
923+
String MR_TASK_ENABLE_PING_FOR_LIVELINESS_CHECK =
924+
"mapreduce.task.enable.ping-for-liveliness-check";
925+
boolean DEFAULT_MR_TASK_ENABLE_PING_FOR_LIVELINESS_CHECK
926+
= false;
927+
928+
922929
/**
923930
* If contact with RM is lost, the AM will wait MR_AM_TO_RM_WAIT_INTERVAL_MS
924931
* milliseconds before aborting. During this interval, AM will still try

hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/resources/mapred-default.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,13 @@
286286
</description>
287287
</property>
288288

289+
<property>
290+
<name>mapreduce.task.enable.ping-for-liveliness-check</name>
291+
<value>false</value>
292+
<description>Whether to consider ping from tasks in liveliness check.
293+
</description>
294+
</property>
295+
289296
<property>
290297
<name>mapreduce.map.memory.mb</name>
291298
<value>-1</value>

0 commit comments

Comments
 (0)