ayushtkn commented on a change in pull request #2605:
URL: https://github.com/apache/hadoop/pull/2605#discussion_r557382660



##########
File path: 
hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterWebHdfsMethods.java
##########
@@ -453,21 +456,25 @@ private DatanodeInfo chooseDatanode(final Router router,
       final String path, final HttpOpParam.Op op, final long openOffset,
       final String excludeDatanodes) throws IOException {
     final RouterRpcServer rpcServer = getRPCServer(router);
-    DatanodeInfo[] dns = null;
+    DatanodeInfo[] dns = {};
+    String resolvedNs = "";
     try {
       dns = rpcServer.getCachedDatanodeReport(DatanodeReportType.LIVE);
+      // for simplicity, just take the first remote location to create the file
+      resolvedNs = rpcServer.getLocationsForPath(path, true)
+          .get(0).getNameserviceId();

Review comment:
       Thanx @fengnanli, Seems I have got little confused here -
   This method will get call for (OPEN/APPEND/GETFILECHECKSUM) also, There is a 
check below as well for these operations.
   So, Here we are taking the first nameservice as the resolvedNs, and 
datanodes from other namespace we add into excluded nodes. What I understood by 
this check below -
   ``
         if (collection.contains(dn.getName()) ||
             !ns.equals(resolvedNs)) {
           excludes.add(dn);
   ``
   So, In case the file was in the other namespace, rather than being in the 
first one in case of say RANDOM or SPACE order, so will we not put those 
datanodes into the excluded ones? and apparently the call may fail for say 
APPEND or OPEN.
   Am I missing some check here? if not, the resolvedNs for these cases we 
should get from the `getFileInfo`?
   
   Secondly, In case of create call, we are taking the datanodes from the first 
namespace, are we sure the create call was to the first Namespace only?
   




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

Reply via email to