From ba406b723d4b978d2dd02f35a2a8e20a812a3cee Mon Sep 17 00:00:00 2001 From: Andrew Wang Date: Thu, 25 Jun 2015 17:29:24 -0700 Subject: [PATCH] HDFS-8665. Fix replication check in DFSTestUtils#waitForReplication. (cherry picked from commit ff0e5e572f5dcf7b49381cbe901360f6e171d423) --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 2 ++ .../test/java/org/apache/hadoop/hdfs/DFSTestUtil.java | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 8e439b0e614..e423c6df3f1 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -336,6 +336,8 @@ Release 2.8.0 - UNRELEASED HDFS-8640. Make reserved RBW space visible through JMX. (kanaka kumar avvaru via Arpit Agarwal) + HDFS-8665. Fix replication check in DFSTestUtils#waitForReplication. (wang) + OPTIMIZATIONS HDFS-8026. Trace FSOutputSummer#writeChecksumChunks rather than diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/DFSTestUtil.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/DFSTestUtil.java index 009babf1ab4..c07969163b6 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/DFSTestUtil.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/DFSTestUtil.java @@ -549,7 +549,14 @@ public class DFSTestUtil { public Boolean get() { try { FileStatus stat = dfs.getFileStatus(file); - return replication == stat.getReplication(); + BlockLocation[] locs = dfs.getFileBlockLocations(stat, 0, stat + .getLen()); + for (BlockLocation loc : locs) { + if (replication != loc.getHosts().length) { + return false; + } + } + return true; } catch (IOException e) { LOG.info("getFileStatus on path " + file + " failed!", e); return false;