From 4a212242d99071d028b40c2f5d40afb7f337e471 Mon Sep 17 00:00:00 2001 From: Inigo Goiri Date: Thu, 27 Jun 2019 10:00:05 -0700 Subject: [PATCH] HDFS-14599. HDFS-12487 breaks test TestDiskBalancer.testDiskBalancerWithFedClusterWithOneNameServiceEmpty. Contributed by He Xiaoqiao. --- .../hadoop/hdfs/server/datanode/DiskBalancer.java | 6 ++---- .../hdfs/server/diskbalancer/TestDiskBalancer.java | 11 ++++------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DiskBalancer.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DiskBalancer.java index 91833444d94..ffa8524a2f9 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DiskBalancer.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DiskBalancer.java @@ -906,8 +906,8 @@ public class DiskBalancer { try { ExtendedBlock block = iter.nextBlock(); if(null == block){ - LOG.info("NextBlock call returned null.No valid block to copy. {}", - item.toJson()); + LOG.info("NextBlock call returned null. No valid block to copy. {}", + item.toJson()); return null; } // A valid block is a finalized block, we iterate until we get @@ -923,13 +923,11 @@ public class DiskBalancer { item.incErrorCount(); } } - if (item.getErrorCount() >= getMaxError(item)) { item.setErrMsg("Error count exceeded."); LOG.info("Maximum error count exceeded. Error count: {} Max error:{} ", item.getErrorCount(), item.getMaxDiskErrors()); } - return null; } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/diskbalancer/TestDiskBalancer.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/diskbalancer/TestDiskBalancer.java index 094da09ae83..b400391dbb2 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/diskbalancer/TestDiskBalancer.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/diskbalancer/TestDiskBalancer.java @@ -316,14 +316,12 @@ public class TestDiskBalancer { final Path filePath = new Path(fileName); long fileLen = blockCount * blockSize; - //Writing data only to one nameservice. FileSystem fs = cluster.getFileSystem(0); TestBalancer.createFile(cluster, filePath, fileLen, (short) 1, 0); DFSTestUtil.waitReplication(fs, filePath, (short) 1); - GenericTestUtils.LogCapturer logCapturer = GenericTestUtils.LogCapturer .captureLogs(DiskBalancer.LOG); @@ -334,15 +332,14 @@ public class TestDiskBalancer { NodePlan plan = dataMover.generatePlan(); dataMover.executePlan(plan); dataMover.verifyPlanExectionDone(); - //Because here we have one nameservice empty, don't check - // blockPoolCount. + // Because here we have one nameservice empty, don't check blockPoolCount. dataMover.verifyAllVolumesHaveData(false); } finally { - Assert.assertTrue(logCapturer.getOutput().contains("There are no " + - "blocks in the blockPool")); + String logOut = logCapturer.getOutput(); + Assert.assertTrue("Wrong log: " + logOut, logOut.contains( + "NextBlock call returned null. No valid block to copy.")); cluster.shutdown(); } - } @Test