sodonnel commented on a change in pull request #678: HDDS-3179 Pipeline placement based on Topology does not have fallback URL: https://github.com/apache/hadoop-ozone/pull/678#discussion_r394322320
########## File path: hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/PipelinePlacementPolicy.java ########## @@ -292,10 +294,15 @@ DatanodeDetails fallBackPickNodes( int nodesToFind = nodesRequired - results.size(); for (int x = 0; x < nodesToFind; x++) { // Pick remaining nodes based on the existence of rack awareness. - DatanodeDetails pick = rackAwareness - ? chooseNodeFromNetworkTopology( - nodeManager.getClusterNetworkTopologyMap(), anchor, exclude) - : fallBackPickNodes(healthyNodes, exclude); + DatanodeDetails pick; + try { + pick = rackAwareness + ? chooseNodeFromNetworkTopology( + nodeManager.getClusterNetworkTopologyMap(), anchor, exclude) + : fallBackPickNodes(healthyNodes, exclude); + } catch (SCMException e) { Review comment: Could we avoid the exception block here, especially if we think the exception block will be the "normal code path" if the rack only has one node? Eg, if we change `chooseNodeFromNetworkTopology()` to return null or the picked node, and then refactor this code block to look like this: ``` DatanodeDetails pick = null; if (rackAwareness) { pick = chooseNodeFromNetworkTopology( nodeManager.getClusterNetworkTopologyMap(), anchor, exclude); } if (pick == null) { pick = fallBackPickNodes(healthyNodes, exclude); if (rackAwareness) { LOG.debug("Failed to choose node based on topology. Fallback " + "picks node as: {}", pick); } } ``` I think that is easier to read and avoid the expensive exception handler. What do you think? ---------------------------------------------------------------- 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 With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: ozone-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: ozone-issues-h...@hadoop.apache.org