From e88c01fa5808afc4176c35cf5cd49eecdbd13d8c Mon Sep 17 00:00:00 2001 From: Vinayakumar B Date: Wed, 17 Feb 2016 10:13:41 +0530 Subject: [PATCH] HADOOP-12810. FileSystem#listLocatedStatus causes unnecessary RPC calls (Contributed by Ryan Blue) (cherry picked from commit 96ea3094315bb1e1a5e268e3817c7fdedc3e9462) (cherry picked from commit 2bf5a005fab287689a148c1928f3b04c0a8dcedf) --- hadoop-common-project/hadoop-common/CHANGES.txt | 3 +++ .../src/main/java/org/apache/hadoop/fs/FileSystem.java | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index bd6b08a2eea..5f49c952b3b 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -1019,6 +1019,9 @@ Release 2.7.3 - UNRELEASED OPTIMIZATIONS + HADOOP-12810. FileSystem#listLocatedStatus causes unnecessary RPC calls + (Ryan Blue via vinayakumarb) + BUG FIXES HADOOP-12296. when setnetgrent returns 0 in linux, exception should be diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java index e0320c0b64a..4eb3ed53eb9 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java @@ -1732,8 +1732,10 @@ public abstract class FileSystem extends Configured implements Closeable { throw new NoSuchElementException("No more entry in " + f); } FileStatus result = stats[i++]; + // for files, use getBlockLocations(FileStatus, int, int) to avoid + // calling getFileStatus(Path) to load the FileStatus again BlockLocation[] locs = result.isFile() ? - getFileBlockLocations(result.getPath(), 0, result.getLen()) : + getFileBlockLocations(result, 0, result.getLen()) : null; return new LocatedFileStatus(result, locs); }