[ 
https://issues.apache.org/jira/browse/HDFS-5207?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13768113#comment-13768113
 ] 

Tsz Wo (Nicholas), SZE commented on HDFS-5207:
----------------------------------------------

{code}
   private DatanodeDescriptor chooseTarget(int numOfReplicas,
-                                          DatanodeDescriptor writer,
-                                          Map<Node, Node> excludedNodes,
+                                          Node writer,
+                                          Set<Node> excludedNodes,
                                           long blocksize,
                                           int maxNodesPerRack,
                                           List<DatanodeDescriptor> results,
                                           final boolean avoidStaleNodes) {
     if (numOfReplicas == 0 || clusterMap.getNumOfLeaves()==0) {
-      return writer;
+      return null;
     }
     int totalReplicasExpected = numOfReplicas + results.size();
       
     int numOfResults = results.size();
     boolean newBlock = (numOfResults==0);
-    if (writer == null && !newBlock) {
+    if ((writer == null || !(writer instanceof DatanodeDescriptor)) && 
!newBlock) {
       writer = results.get(0);
     }
   ...
 }
{code}
- In the above method, chooseTarget(..) is supposed to return the local node.
-* It should return writer instead of null even if (numOfReplicas == 0 || 
clusterMap.getNumOfLeaves()==0).
-* We need to change the return type to Node since the local node could 
theoretically be a non-DatanodeDescriptor.  Then, we don't need to cast writer 
to DatanodeDescriptor when returning it.
-* You may also want to add a @return tag in the javadoc to mention that the 
method returns the local node but not the chosen node.
                
> In BlockPlacementPolicy, update 2 parameters of chooseTarget()
> --------------------------------------------------------------
>
>                 Key: HDFS-5207
>                 URL: https://issues.apache.org/jira/browse/HDFS-5207
>             Project: Hadoop HDFS
>          Issue Type: Improvement
>          Components: namenode
>            Reporter: Junping Du
>            Assignee: Junping Du
>         Attachments: HDFS-5207-v1.patch, HDFS-5207-v2.patch
>
>
> We should change chooseTarget(..., DatanodeDescriptor writer, ...) to 
> chooseTarget (..., node writer, ...) as the only important property of writer 
> is to identify other nodes' location relationship so more generic one could 
> be better. It also helps to cover cases that client node is not a Datanode. 
> Also, the excluded nodes are not necessary to be a HashMap with the same key 
> and value, Set is more proper in this case.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to