-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-29669 Implement basic row cache #7901
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
base: HBASE-29585
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -69,6 +69,7 @@ class MetricsRegionServerWrapperImpl implements MetricsRegionServerWrapper { | |
| private BlockCache l2Cache = null; | ||
| private MobFileCache mobFileCache; | ||
| private CacheStats cacheStats; | ||
| private final RowCache rowCache; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. better move to L71 under |
||
| private CacheStats l1Stats = null; | ||
| private CacheStats l2Stats = null; | ||
| private volatile long numWALFiles = 0; | ||
|
|
@@ -99,6 +100,8 @@ public MetricsRegionServerWrapperImpl(final HRegionServer regionServer) { | |
| this.regionServer = regionServer; | ||
| initBlockCache(); | ||
| initMobFileCache(); | ||
| RSRpcServices rsRpcServices = this.regionServer.getRSRpcServices(); | ||
| this.rowCache = rsRpcServices == null ? null : rsRpcServices.getServer().getRowCache(); | ||
|
Comment on lines
+103
to
+104
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. better to use a method |
||
| this.excludeDatanodeManager = this.regionServer.getWalFactory().getExcludeDatanodeManager(); | ||
|
|
||
| this.period = regionServer.getConfiguration().getLong(HConstants.REGIONSERVER_METRICS_PERIOD, | ||
|
|
@@ -1194,6 +1197,31 @@ public long getTrailerHitCount() { | |
| return this.cacheStats != null ? this.cacheStats.getTrailerHitCount() : 0L; | ||
| } | ||
|
|
||
| @Override | ||
| public long getRowCacheHitCount() { | ||
| return this.rowCache != null ? this.rowCache.getHitCount() : 0L; | ||
| } | ||
|
|
||
| @Override | ||
| public long getRowCacheMissCount() { | ||
| return this.rowCache != null ? this.rowCache.getMissCount() : 0L; | ||
| } | ||
|
|
||
| @Override | ||
| public long getRowCacheSize() { | ||
| return this.rowCache != null ? this.rowCache.getSize() : 0L; | ||
| } | ||
|
|
||
| @Override | ||
| public long getRowCacheCount() { | ||
| return this.rowCache != null ? this.rowCache.getCount() : 0L; | ||
| } | ||
|
|
||
| @Override | ||
| public long getRowCacheEvictedRowCount() { | ||
| return this.rowCache != null ? this.rowCache.getEvictedRowCount() : 0L; | ||
| } | ||
|
|
||
| @Override | ||
| public long getByteBuffAllocatorHeapAllocationBytes() { | ||
| return ByteBuffAllocator.getHeapAllocationBytes(allocator, ByteBuffAllocator.HEAP); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -668,7 +668,7 @@ private CheckAndMutateResult checkAndMutate(HRegion region, List<ClientProtos.Ac | |
| result = region.getCoprocessorHost().preCheckAndMutate(checkAndMutate); | ||
| } | ||
| if (result == null) { | ||
| result = region.checkAndMutate(checkAndMutate, nonceGroup, nonce); | ||
| result = region.checkAndMutate(mutations, checkAndMutate, nonceGroup, nonce); | ||
| if (region.getCoprocessorHost() != null) { | ||
| result = region.getCoprocessorHost().postCheckAndMutate(checkAndMutate, result); | ||
| } | ||
|
|
@@ -2347,8 +2347,21 @@ public BulkLoadHFileResponse bulkLoadHFile(final RpcController controller, | |
| return bulkLoadHFileInternal(request); | ||
| } | ||
|
|
||
| // TODO: implement row cache logic for bulk load | ||
| return bulkLoadHFileInternal(request); | ||
| RowCache rowCache = region.getRegionServerServices().getRowCache(); | ||
|
|
||
| // Since bulkload modifies the store files, the row cache should be disabled until the bulkload | ||
| // is finished. | ||
| rowCache.createRegionLevelBarrier(region); | ||
| try { | ||
| // We do not invalidate the entire row cache directly, as it contains a large number of | ||
| // entries and takes a long time. Instead, we increment rowCacheSeqNum, which is used when | ||
| // constructing a RowCacheKey, thereby making the existing row cache entries stale. | ||
| rowCache.increaseRowCacheSeqNum(region); | ||
| return bulkLoadHFileInternal(request); | ||
| } finally { | ||
| // The row cache for the region has been enabled again | ||
| rowCache.removeTableLevelBarrier(region); | ||
|
Comment on lines
+2362
to
+2363
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
| } | ||
| } | ||
|
|
||
| BulkLoadHFileResponse bulkLoadHFileInternal(final BulkLoadHFileRequest request) | ||
|
|
@@ -2609,7 +2622,7 @@ private Result get(Get get, HRegion region, RegionScannersCloseCallBack closeCal | |
| RegionScannerImpl scanner = null; | ||
| long blockBytesScannedBefore = context.getBlockBytesScanned(); | ||
| try { | ||
| scanner = region.getScannerWithResults(get, scan, results); | ||
| scanner = region.getScannerWithResults(get, scan, results, context); | ||
| } finally { | ||
| if (scanner != null) { | ||
| if (closeCallBack == null) { | ||
|
|
||
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.
For testing only, we could use
@RestrictedApiannotation?