You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by GitBox <gi...@apache.org> on 2020/12/14 21:59:16 UTC

[GitHub] [hadoop] amahussein commented on a change in pull request #2528: HDFS-15716. WaitforReplication in TestUpgradeDomainBlockPlacementPolicy

amahussein commented on a change in pull request #2528:
URL: https://github.com/apache/hadoop/pull/2528#discussion_r542842876



##########
File path: hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestUpgradeDomainBlockPlacementPolicy.java
##########
@@ -231,32 +229,34 @@ public Boolean get() {
         } catch (IOException ioe) {
           return false;
         }
-        for(LocatedBlock block : locatedBlocks.getLocatedBlocks()) {
+        for (LocatedBlock block : locatedBlocks.getLocatedBlocks()) {
           Set<DatanodeInfo> locs = new HashSet<>();
           for (DatanodeInfo datanodeInfo : block.getLocations()) {
-            if (datanodeInfo.getAdminState() ==
-                DatanodeInfo.AdminStates.NORMAL) {
+            if (datanodeInfo.getAdminState().equals(
+                DatanodeInfo.AdminStates.NORMAL)) {
               locs.add(datanodeInfo);
             }
           }
           for (DatanodeID datanodeID : expectedDatanodeIDs) {
-            successful = successful && locs.contains(datanodeID);
+            if (!locs.contains(datanodeID)) {
+              return false;
+            }
           }
         }
-        return successful;
+        return true;
       }
-    }, 1000, 60000);
+    }, 1000, WAIT_TIMEOUT_MS);
 
     // Verify block placement policy of each block.
-    LocatedBlocks locatedBlocks;
-    locatedBlocks =
+    LocatedBlocks locatedBlocks =
         cluster.getFileSystem().getClient().getLocatedBlocks(
             path.toString(), 0, fileSize);
-    for(LocatedBlock block : locatedBlocks.getLocatedBlocks()) {
-      BlockPlacementStatus status = cluster.getNamesystem().getBlockManager().
-          getBlockPlacementPolicy().verifyBlockPlacement(
-              block.getLocations(), REPLICATION_FACTOR);
-      assertTrue(status.isPlacementPolicySatisfied());

Review comment:
       Sorry @goiri  I did not know that static imports are preferred. I remembered it used to be not favorable because of code readability.
   I will take a note of that for future changes.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org