From 9e46213b7a38475f64667c47f009ae508b712c60 Mon Sep 17 00:00:00 2001 Date: Wed, 18 Dec 2019 15:46:01 +0800 Subject: [PATCH] for HBASE-23584 --- .../hadoop/hbase/regionserver/StoreFileInfo.java | 36 ++++++++++++++-------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileInfo.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileInfo.java index a76e0fe..9043a24 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileInfo.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileInfo.java @@ -47,6 +47,7 @@ import org.apache.hadoop.hbase.util.FSUtils; public class StoreFileInfo { private static final Logger LOG = LoggerFactory.getLogger(StoreFileInfo.class); + private FileStatus localStatus; /** * A non-capture group, for hfiles, so that this can be embedded. * HFiles are uuid ([0-9a-z]+). Bulk loaded hfiles has (_SeqId_[0-9]+_) has suffix. @@ -99,8 +100,8 @@ public class StoreFileInfo { private RegionCoprocessorHost coprocessorHost; // timestamp on when the file was created, is 0 and ignored for reference or link files - private long createdTimestamp; - + // the before timestamp is shown as above ! Now i change to use the createdTimestamp of reference or link files , will it create some problem later ? + private long createdTimestamp = 0l; private long size; /** @@ -147,9 +148,8 @@ public class StoreFileInfo { this.createdTimestamp = fileStatus.getModificationTime(); this.size = fileStatus.getLen(); } else { - FileStatus fStatus = fs.getFileStatus(initialPath); - this.createdTimestamp = fStatus.getModificationTime(); - this.size = fStatus.getLen(); + this.createdTimestamp = this.getFileStatus().getModificationTime(); + this.size = this.getFileStatus().getLen(); } this.reference = null; this.link = null; @@ -281,7 +281,7 @@ public class StoreFileInfo { if (this.link != null) { // HFileLink in = new FSDataInputStreamWrapper(fs, this.link, doDropBehind, readahead); - status = this.link.getFileStatus(fs); + //status = this.link.getFileStatus(fs); } else if (this.reference != null) { // HFile Reference Path referencePath = getReferredToFile(this.getPath()); @@ -295,13 +295,14 @@ public class StoreFileInfo { newFnfe.initCause(fnfe); throw newFnfe; } - status = fs.getFileStatus(referencePath); + //status = fs.getFileStatus(referencePath); } else { in = new FSDataInputStreamWrapper(fs, this.getPath(), doDropBehind, readahead); - status = fs.getFileStatus(initialPath); + //status = fs.getFileStatus(initialPath); } - long length = status.getLen(); hdfsBlocksDistribution = computeHDFSBlocksDistribution(fs); + status = this.getFileStatus(); + long length = status.getLen(); StoreFileReader reader = null; if (this.coprocessorHost != null) { @@ -364,13 +365,18 @@ public class StoreFileInfo { */ public FileStatus getReferencedFileStatus(final FileSystem fs) throws IOException { FileStatus status; + if(this.localStatus != null){ + return this.localStatus; + } if (this.reference != null) { if (this.link != null) { FileNotFoundException exToThrow = null; for (int i = 0; i < this.link.getLocations().length; i++) { // HFileLink Reference try { - return link.getFileStatus(fs); + this.localStatus = link.getFileStatus(fs); + status = this.localStatus; + return status; } catch (FileNotFoundException ex) { // try the other location exToThrow = ex; @@ -380,7 +386,8 @@ public class StoreFileInfo { } else { // HFile Reference Path referencePath = getReferredToFile(this.getPath()); - status = fs.getFileStatus(referencePath); + this.localStatus = fs.getFileStatus(referencePath); + status = this.localStatus; } } else { if (this.link != null) { @@ -388,7 +395,9 @@ public class StoreFileInfo { for (int i = 0; i < this.link.getLocations().length; i++) { // HFileLink try { - return link.getFileStatus(fs); + this.localStatus = link.getFileStatus(fs); + status = this.localStatus; + return status; } catch (FileNotFoundException ex) { // try the other location exToThrow = ex; @@ -396,7 +405,8 @@ public class StoreFileInfo { } throw exToThrow; } else { - status = fs.getFileStatus(initialPath); + this.localStatus = fs.getFileStatus(initialPath); + status = this.localStatus; } } return status; -- 1.8.3.1