yandrey321 commented on code in PR #11971:
URL: https://github.com/apache/ozone/pull/11971#discussion_r4569935768


##########
hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicOzoneFileSystem.java:
##########
@@ -887,9 +892,30 @@ public BlockLocation[] getFileBlockLocations(FileStatus 
fileStatus,
       throws IOException {
     if (fileStatus instanceof LocatedFileStatus) {
       return getBlockLocationsInRange((LocatedFileStatus) fileStatus, start, 
len);
-    } else {
-      return super.getFileBlockLocations(fileStatus, start, len);
     }
+    if (needsBlockLocations(fileStatus, start, len)) {
+      // getFileStatus returns no block locations: fetch them by path, as HDFS 
does.
+      return getFileBlockLocations(fileStatus.getPath(), start, len);
+    }
+    return super.getFileBlockLocations(fileStatus, start, len);
+  }
+
+  @Override
+  public BlockLocation[] getFileBlockLocations(Path p, long start, long len) 
throws IOException {
+    // One GetFileStatus with block locations, instead of getFileStatus 
followed by another for the locations.
+    FileStatus fileStatus = getFileStatus(p, false);
+    if (fileStatus instanceof LocatedFileStatus) {
+      return getBlockLocationsInRange((LocatedFileStatus) fileStatus, start, 
len);
+    }
+    return super.getFileBlockLocations(fileStatus, start, len);
+  }

Review Comment:
   Fixed. Both `getFileBlockLocations(Path, long, long)` overloads (o3fs and 
ofs) now reject a negative `start` or `len` before calling OM. They use 
`checkBlockLocationsRange`, which `getBlockLocationsInRange` now shares. The 
exception and message are the same as before. Added 
`getFileBlockLocationsOfPathRejectsInvalidRangeWithoutRpc` to both HeadOp tests.
   



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

To unsubscribe, e-mail: [email protected]

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