-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
HBASE-27794: Tooling for parsing/reading the prefetch files list file #5468
Conversation
🎊 +1 overall
This message was automatically generated. |
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.
Thanks for adding this @Kota-SH ! I had a few nits.
Also, can we add a tool to parse the persistent cache map file and read the list of cached files from there? I think it would be good for troubleshooting if we could analyse the persistent cache file contents.
server.getBlockCache().ifPresent(blockCache -> { | ||
if (blockCache instanceof CombinedBlockCache) { | ||
BlockCache l2 = ((CombinedBlockCache) blockCache).getSecondLevelCache(); | ||
if (l2 instanceof BucketCache) { | ||
if (((BucketCache) l2).isCachePersistenceEnabled()) { |
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.
Use the static method BucketCache.getBucketCacheFromCacheConfig for finding the bucket cache instance.
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.
Thanks for the feedback @wchevreuil, However, my idea is that we have RegionServer.getBlockCache(), so I added a getter (getBucketCacheIfPresent()) for the bucket cache as a property of the RS.
WDYT?
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.
It's fine to add the additional getter, but we should not duplicate code. This whole implementation is identical to BucketCache.getBucketCacheFromCacheConfig, so you should just call it inside your method.
/** | ||
* Get the list of prefetched files | ||
*/ | ||
List<String> getPrefetchedFilesList(ServerName serverName) throws IOException; |
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.
Nit: let's call it "getCachedFilesList".
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
Admin admin = TEST_UTIL.getAdmin(); | ||
List<String> prefetchedFilesList = | ||
admin.getPrefetchedFilesList(regionServingRS.getServerName()); | ||
assertEquals(1, ((List<?>) prefetchedFilesList).size()); |
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.
Nit: (List<?>) Redundant cast can be removed as prefetchedFilesList type is List
e1dde58
to
ccc3689
Compare
💔 -1 overall
This message was automatically generated. |
70e8c80
to
6e07f26
Compare
🎊 +1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
6e07f26
to
153d50c
Compare
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
153d50c
to
aa2607f
Compare
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
CacheConfig cacheConfig = server.getRegions().get(0).getStores().get(0).getCacheConfig(); | ||
BucketCache.getBucketCacheFromCacheConfig(cacheConfig).ifPresent(bucketCache -> { | ||
if (bucketCache.isCachePersistenceEnabled()) { |
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.
Maybe we should encapsulate this in the BlockCache.
public List<String> getCachedFilesList() throws IOException { | ||
List<String> tmp = new ArrayList<>(); | ||
File persistedFile = new File(persistencePath); | ||
try (FileInputStream fis = new FileInputStream(persistedFile)) { | ||
if (fis.skip(ProtobufMagic.lengthOfPBMagic()) != ProtobufMagic.lengthOfPBMagic()) { | ||
throw new IOException( | ||
"Incorrect number of bytes read while checking for protobuf magic number"); | ||
} | ||
BucketCacheProtos.BucketCacheEntry proto = | ||
BucketCacheProtos.BucketCacheEntry.parseDelimitedFrom(fis); | ||
tmp.addAll(proto.getPrefetchedFilesMap().keySet()); | ||
} | ||
return tmp; | ||
} |
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.
So this would make sense for a standalone tool, but since we are implementing this whole thing as part of the RS RPC API, why don't we simply return the in-memory contents?
aa2607f
to
4703d5d
Compare
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
4703d5d
to
f6d0786
Compare
💔 -1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
@@ -1965,8 +1965,8 @@ public AtomicBoolean getBackingMapValidated() { | |||
return backingMapValidated; | |||
} | |||
|
|||
public Map<String, Boolean> getFullyCachedFiles() { | |||
return fullyCachedFiles; | |||
public Optional<Map<String, Boolean>> getFullyCachedFiles() { |
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.
nit: mark with Override annotation.
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.
LGTM, but please address the two javac warnings (missing Override annotation) before we can merge it.
f6d0786
to
abf4e0c
Compare
🎊 +1 overall
This message was automatically generated. |
abf4e0c
to
e7ddc29
Compare
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
…#5468) Signed-off-by: Wellington Chevreuil <wchevreuil@apache.org>
…#5468) Signed-off-by: Wellington Chevreuil <wchevreuil@apache.org>
…apache#5468) Signed-off-by: Wellington Chevreuil <wchevreuil@apache.org> (cherry picked from commit fa4c896)
…apache#5468) Signed-off-by: Wellington Chevreuil <wchevreuil@apache.org> (cherry picked from commit fa4c896)
…apache#5468) Signed-off-by: Wellington Chevreuil <wchevreuil@apache.org> (cherry picked from commit fa4c896)
…apache#5468) Signed-off-by: Wellingt
…ist file (apache#5468)" This reverts commit c37fba6.
…apache#5468) Signed-off-by: Wellington Chevreuil <wchevreuil@apache.org>
…es list file (apache#5468) (apache#5491) Signed-off-by: Wellington Chevreuil <wchevreuil@apache.org> (cherry picked from commit fa4c896) Change-Id: I2e96f4b8bccef4ca9ae518dfca2283e63ec07102
Jira: https://issues.apache.org/jira/browse/HBASE-27794