ChenSammi commented on a change in pull request #1094: HDDS-1787. NPE thrown 
while trying to find DN closest to client.
URL: https://github.com/apache/hadoop/pull/1094#discussion_r303705636
 
 

 ##########
 File path: 
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMBlockProtocolServer.java
 ##########
 @@ -290,7 +290,12 @@ public ScmInfo getScmInfo() throws IOException {
       NodeManager nodeManager = scm.getScmNodeManager();
       Node client = nodeManager.getNode(clientMachine);
       List<Node> nodeList = new ArrayList();
-      nodes.stream().forEach(path -> nodeList.add(nodeManager.getNode(path)));
+      nodes.stream().forEach(path -> {
+        DatanodeDetails node = nodeManager.getNode(path);
+        if (node != null) {
 
 Review comment:
   nodeManager.getNode will return null when it can't find the node in the 
network topology or the node found is not a leaf node.  The WARN log for all 
these cases are  in nodeManager.getNode function.  
   
       if (node != null) {
         if (node instanceof InnerNode) {
           LOG.warn("Get node for {} return {}, it's an inner node, " +
               "not a datanode", address, node.getNetworkFullPath());
         } else {
           LOG.debug("Get node for {} return {}", address,
               node.getNetworkFullPath());
           return (DatanodeDetails)node;
         }
       } else {
         LOG.warn("Cannot find node for {}", address);
       }
     return null;

----------------------------------------------------------------
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]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to