-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-23584 : Descrease rpc getFileStatus count when open a storefile #958
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
a41081d
6800ae1
8cbca97
b122afd
cfa10c5
0948726
10cd97a
f1dac8f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,6 +51,7 @@ | |
| 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. | ||
|
|
@@ -108,6 +109,7 @@ public class StoreFileInfo { | |
| private RegionCoprocessorHost coprocessorHost; | ||
|
|
||
| // timestamp on when the file was created, is 0 and ignored for reference or link files | ||
| // 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; | ||
|
|
||
| private long size; | ||
|
|
@@ -168,9 +170,8 @@ private StoreFileInfo(final Configuration conf, final FileSystem fs, final FileS | |
| 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; | ||
|
|
@@ -296,7 +297,7 @@ ReaderContext createReaderContext(boolean doDropBehind, long readahead, ReaderTy | |
| 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()); | ||
|
|
@@ -310,11 +311,12 @@ ReaderContext createReaderContext(boolean doDropBehind, long readahead, ReaderTy | |
| 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); | ||
| } | ||
| status = this.getFileStatus(); | ||
| long length = status.getLen(); | ||
| ReaderContextBuilder contextBuilder = new ReaderContextBuilder() | ||
| .withInputStreamWrapper(in) | ||
|
|
@@ -370,13 +372,16 @@ private HDFSBlocksDistribution computeHDFSBlocksDistributionInternal(final FileS | |
| */ | ||
| 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; | ||
|
|
@@ -386,23 +391,27 @@ public FileStatus getReferencedFileStatus(final FileSystem fs) throws IOExceptio | |
| } 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) { | ||
| FileNotFoundException exToThrow = null; | ||
| 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; | ||
| } | ||
| } | ||
| throw exToThrow; | ||
| } else { | ||
| status = fs.getFileStatus(initialPath); | ||
| this.localStatus = fs.getFileStatus(initialPath); | ||
| status = this.localStatus; | ||
|
||
| } | ||
| } | ||
| return status; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like idea of caching status. When does it get invalidated?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now it will be updated when reopened only because hfile will not be modified after writen i think . Is there some scenarios fileStatus will be modified?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not that I can think of.