From f0c3ed79dd51aee13feaefc81da6d3306ab6e594 Mon Sep 17 00:00:00 2001 From: Eli Collins Date: Wed, 12 Sep 2012 04:21:31 +0000 Subject: [PATCH] HDFS-3919. MiniDFSCluster:waitClusterUp can hang forever. Contributed by Andy Isaacson git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1383759 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 5aafbe622ac..036609ad4e5 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -230,6 +230,9 @@ Release 2.0.3-alpha - Unreleased BUG FIXES + HDFS-3919. MiniDFSCluster:waitClusterUp can hang forever. + (Andy Isaacson via eli) + Release 2.0.2-alpha - 2012-09-07 INCOMPATIBLE CHANGES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java index 78483466792..9d9b5c24484 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java @@ -918,7 +918,8 @@ public class MiniDFSCluster { /** * wait for the cluster to get out of safemode. */ - public void waitClusterUp() { + public void waitClusterUp() throws IOException { + int i = 0; if (numDataNodes > 0) { while (!isClusterUp()) { try { @@ -926,6 +927,9 @@ public class MiniDFSCluster { Thread.sleep(1000); } catch (InterruptedException e) { } + if (++i > 10) { + throw new IOException("Timed out waiting for Mini HDFS Cluster to start"); + } } } }