yandrey321 commented on code in PR #11971:
URL: https://github.com/apache/ozone/pull/11971#discussion_r4569932552
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/OzoneFileSystemTestBase.java:
##########
@@ -167,6 +168,32 @@ static void listLocatedStatusForZeroByteFile(FileSystem
fs, Path path) throws IO
assertFalse(fileStatuses[0] instanceof LocatedFileStatus);
}
+ /**
+ * Like HDFS, getFileStatus returns no block locations and
getFileBlockLocations fetches them; for a file deleted
+ * after its getFileStatus, getFileBlockLocations fails with
FileNotFoundException. Deletes the file.
+ */
+ static void fileBlockLocations(FileSystem fs, Path path, long length) throws
IOException {
+ FileStatus status = fs.getFileStatus(path);
+ assertThat(status).isNotInstanceOf(LocatedFileStatus.class);
+ assertEquals(length, status.getLen());
+
+ BlockLocation[] expected =
fs.listLocatedStatus(path).next().getBlockLocations();
+ assertThat(expected.length).isGreaterThanOrEqualTo(1);
+ for (BlockLocation[] blockLocations : new BlockLocation[][] {
+ fs.getFileBlockLocations(status, 0, status.getLen()),
fs.getFileBlockLocations(path, 0, status.getLen())}) {
+ assertEquals(expected.length, blockLocations.length);
+ for (int i = 0; i < expected.length; i++) {
+
assertThat(blockLocations[i].getNames().length).isGreaterThanOrEqualTo(1);
+ assertArrayEquals(expected[i].getHosts(),
blockLocations[i].getHosts());
Review Comment:
Fixed. The hosts are now compared with `containsExactlyInAnyOrder`. With
topology-aware read, OM sorts datanodes by distance and shuffles those at the
same distance, so `listLocatedStatus` and `getFileBlockLocations` can list them
in a different order.
--
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]