From 7ef290cfefdb03f89d08b3131dcd8440ecb37498 Mon Sep 17 00:00:00 2001 From: Jason Lowe Date: Wed, 16 Nov 2016 15:23:12 +0000 Subject: [PATCH] MAPREDUCE-6804. Add timeout when starting JobHistoryServer in MiniMRYarnCluster. Contributed by Andras Bokor --- .../org/apache/hadoop/mapreduce/v2/MiniMRYarnCluster.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapreduce/v2/MiniMRYarnCluster.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapreduce/v2/MiniMRYarnCluster.java index 2d3d6ed9e4..06e37dd0f0 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapreduce/v2/MiniMRYarnCluster.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapreduce/v2/MiniMRYarnCluster.java @@ -45,6 +45,7 @@ import org.apache.hadoop.net.NetUtils; import org.apache.hadoop.service.AbstractService; import org.apache.hadoop.service.Service; +import org.apache.hadoop.test.GenericTestUtils; import org.apache.hadoop.util.JarFinder; import org.apache.hadoop.yarn.conf.YarnConfiguration; import org.apache.hadoop.yarn.exceptions.YarnRuntimeException; @@ -255,11 +256,8 @@ public void run() { }; }.start(); - while (!jhsStarted) { - LOG.info("Waiting for HistoryServer to start..."); - Thread.sleep(1500); - } - //TODO Add a timeout. State.STOPPED check ? + GenericTestUtils.waitFor(() -> jhsStarted, 1500, 60_000); + if (historyServer.getServiceState() != STATE.STARTED) { throw new IOException("HistoryServer failed to start"); }