virajjasani commented on a change in pull request #673: HBASE-23093 : Avoid
Optional Anti-Pattern where possible
URL: https://github.com/apache/hbase/pull/673#discussion_r333526010
##########
File path:
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapperImpl.java
##########
@@ -152,14 +151,15 @@ public MetricsRegionServerWrapperImpl(final
HRegionServer regionServer) {
}
private void initBlockCache() {
- this.blockCache = this.regionServer.getBlockCache();
- this.cacheStats = this.blockCache.map(BlockCache::getStats);
- if (this.cacheStats.isPresent()) {
- if (this.cacheStats.get() instanceof
CombinedBlockCache.CombinedCacheStats) {
- l1Stats = Optional
- .of(((CombinedBlockCache.CombinedCacheStats)
this.cacheStats.get()).getLruCacheStats());
- l2Stats = Optional.of(((CombinedBlockCache.CombinedCacheStats)
this.cacheStats.get())
- .getBucketCacheStats());
+ this.blockCache = this.regionServer.getBlockCache().isPresent() ?
+ this.regionServer.getBlockCache().get() : null;
+ this.cacheStats = this.blockCache != null ? this.blockCache.getStats() :
null;
Review comment:
Thanks @Apache9 for the review. For blockCache and mobFileCache, did
orElse() as per your suggestion. Here, since we are doing blockCache null
check, orElse() might not work
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services