[ 
https://issues.apache.org/jira/browse/HDFS-15783?focusedWorklogId=538207&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-538207
 ]

ASF GitHub Bot logged work on HDFS-15783:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 20/Jan/21 04:28
            Start Date: 20/Jan/21 04:28
    Worklog Time Spent: 10m 
      Work Description: 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:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 538207)
    Time Spent: 40m  (was: 0.5h)

> Speed up BlockPlacementPolicyRackFaultTolerant#verifyBlockPlacement
> -------------------------------------------------------------------
>
>                 Key: HDFS-15783
>                 URL: https://issues.apache.org/jira/browse/HDFS-15783
>             Project: Hadoop HDFS
>          Issue Type: Improvement
>          Components: block placement
>            Reporter: Akira Ajisaka
>            Assignee: Akira Ajisaka
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> {code:java}
> Set<String> racks = new TreeSet<>();
> for (DatanodeInfo dn : locs) {
>   racks.add(dn.getNetworkLocation());
> }
> return new BlockPlacementStatusDefault(racks.size(), numberOfReplicas,
>     clusterMap.getNumOfRacks());{code}
> Here, HashMap should be used instead of TreeSet.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: hdfs-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: hdfs-issues-h...@hadoop.apache.org

Reply via email to