Browse Source

HDFS-14599. HDFS-12487 breaks test TestDiskBalancer.testDiskBalancerWithFedClusterWithOneNameServiceEmpty. Contributed by He Xiaoqiao.

(cherry picked from commit 4a212242d99071d028b40c2f5d40afb7f337e471)
Inigo Goiri 6 years ago
parent
commit
5612537df0

+ 2 - 4
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;
     }
 

+ 4 - 7
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