aajisaka commented on a change in pull request #2626:
URL: https://github.com/apache/hadoop/pull/2626#discussion_r560667352
##########
File path:
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockPlacementPolicyRackFaultTolerant.java
##########
@@ -237,14 +237,11 @@ public BlockPlacementStatus
verifyBlockPlacement(DatanodeInfo[] locs,
// only one rack
return new BlockPlacementStatusDefault(1, 1, 1);
}
- // 1. Check that all locations are different.
- // 2. Count locations on different racks.
- Set<String> racks = new TreeSet<>();
- for (DatanodeInfo dn : locs) {
- racks.add(dn.getNetworkLocation());
- }
- return new BlockPlacementStatusDefault(racks.size(), numberOfReplicas,
- clusterMap.getNumOfRacks());
+ // Count locations on different racks.
+ final long rackCount = Arrays.stream(locs)
+ .map(DatanodeInfo::getNetworkLocation).distinct().count();
+ return new BlockPlacementStatusDefault(Math.toIntExact(rackCount),
Review comment:
Removed the casting. Thank you @goiri.
----------------------------------------------------------------
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:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]