Skip to content

Commit 6136446

Browse files
committed
Revert "Add row cache framework"
This reverts commit cc96b4c.
1 parent f7b5603 commit 6136446

File tree

15 files changed

+37
-709
lines changed

15 files changed

+37
-709
lines changed

hbase-client/src/main/java/org/apache/hadoop/hbase/client/TableDescriptor.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -316,11 +316,4 @@ default boolean matchReplicationScope(boolean enabled) {
316316
}
317317
return !enabled;
318318
}
319-
320-
/**
321-
* Checks whether row caching is enabled for this table. Note that row caching applies only at the
322-
* entire row level, not at the column family level.
323-
* @return {@code true} if row cache is enabled, otherwise {@code false}
324-
*/
325-
boolean isRowCacheEnabled();
326319
}

hbase-client/src/main/java/org/apache/hadoop/hbase/client/TableDescriptorBuilder.java

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -227,15 +227,6 @@ public class TableDescriptorBuilder {
227227
private final static Map<String, String> DEFAULT_VALUES = new HashMap<>();
228228
private final static Set<Bytes> RESERVED_KEYWORDS = new HashSet<>();
229229

230-
/**
231-
* Used by HBase Shell interface to access this metadata attribute which denotes if the row cache
232-
* is enabled.
233-
*/
234-
@InterfaceAudience.Private
235-
public static final String ROW_CACHE_ENABLED = "ROW_CACHE_ENABLED";
236-
private static final Bytes ROW_CACHE_ENABLED_KEY = new Bytes(Bytes.toBytes(ROW_CACHE_ENABLED));
237-
private static final boolean DEFAULT_ROW_CACHE_ENABLED = false;
238-
239230
static {
240231
DEFAULT_VALUES.put(MAX_FILESIZE, String.valueOf(HConstants.DEFAULT_MAX_FILE_SIZE));
241232
DEFAULT_VALUES.put(READONLY, String.valueOf(DEFAULT_READONLY));
@@ -245,7 +236,6 @@ public class TableDescriptorBuilder {
245236
DEFAULT_VALUES.put(PRIORITY, String.valueOf(DEFAULT_PRIORITY));
246237
// Setting ERASURE_CODING_POLICY to NULL so that it is not considered as metadata
247238
DEFAULT_VALUES.put(ERASURE_CODING_POLICY, String.valueOf(DEFAULT_ERASURE_CODING_POLICY));
248-
DEFAULT_VALUES.put(ROW_CACHE_ENABLED, String.valueOf(DEFAULT_ROW_CACHE_ENABLED));
249239
DEFAULT_VALUES.keySet().stream().map(s -> new Bytes(Bytes.toBytes(s)))
250240
.forEach(RESERVED_KEYWORDS::add);
251241
RESERVED_KEYWORDS.add(IS_META_KEY);
@@ -575,11 +565,6 @@ public TableDescriptor build() {
575565
return new ModifyableTableDescriptor(desc);
576566
}
577567

578-
public TableDescriptorBuilder setRowCacheEnabled(boolean rowCacheEnabled) {
579-
desc.setRowCacheEnabled(rowCacheEnabled);
580-
return this;
581-
}
582-
583568
private static final class ModifyableTableDescriptor
584569
implements TableDescriptor, Comparable<ModifyableTableDescriptor> {
585570

@@ -1525,15 +1510,6 @@ public Optional<String> getRegionServerGroup() {
15251510
return Optional.empty();
15261511
}
15271512
}
1528-
1529-
@Override
1530-
public boolean isRowCacheEnabled() {
1531-
return getOrDefault(ROW_CACHE_ENABLED_KEY, Boolean::valueOf, DEFAULT_ROW_CACHE_ENABLED);
1532-
}
1533-
1534-
private ModifyableTableDescriptor setRowCacheEnabled(boolean enabled) {
1535-
return setValue(ROW_CACHE_ENABLED_KEY, Boolean.toString(enabled));
1536-
}
15371513
}
15381514

15391515
/**

hbase-common/src/main/java/org/apache/hadoop/hbase/HConstants.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,12 +1017,6 @@ public enum OperationStatusCode {
10171017

10181018
public static final float HFILE_BLOCK_CACHE_SIZE_DEFAULT = 0.4f;
10191019

1020-
/**
1021-
* Configuration key for the size of the row cache
1022-
*/
1023-
public static final String ROW_CACHE_SIZE_KEY = "row.cache.size";
1024-
public static final float ROW_CACHE_SIZE_DEFAULT = 0.0f;
1025-
10261020
/**
10271021
* Configuration key for the memory size of the block cache
10281022
*/

hbase-server/src/main/java/org/apache/hadoop/hbase/io/util/MemorySizeUtil.java

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -93,29 +93,25 @@ public static void validateRegionServerHeapMemoryAllocation(Configuration conf)
9393
}
9494
float memStoreFraction = getGlobalMemStoreHeapPercent(conf, false);
9595
float blockCacheFraction = getBlockCacheHeapPercent(conf);
96-
float rowCacheFraction =
97-
conf.getFloat(HConstants.ROW_CACHE_SIZE_KEY, HConstants.ROW_CACHE_SIZE_DEFAULT);
9896
float minFreeHeapFraction = getRegionServerMinFreeHeapFraction(conf);
9997

10098
int memStorePercent = (int) (memStoreFraction * 100);
10199
int blockCachePercent = (int) (blockCacheFraction * 100);
102-
int rowCachePercent = (int) (rowCacheFraction * 100);
103100
int minFreeHeapPercent = (int) (minFreeHeapFraction * 100);
104-
int usedPercent = memStorePercent + blockCachePercent + rowCachePercent;
101+
int usedPercent = memStorePercent + blockCachePercent;
105102
int maxAllowedUsed = 100 - minFreeHeapPercent;
106103

107104
if (usedPercent > maxAllowedUsed) {
108105
throw new RuntimeException(String.format(
109106
"RegionServer heap memory allocation is invalid: total memory usage exceeds 100%% "
110-
+ "(memStore + blockCache + rowCache + requiredFreeHeap). "
111-
+ "Check the following configuration values:" + "%n - %s = %.2f" + "%n - %s = %s"
112-
+ "%n - %s = %s" + "%n - %s = %s" + "%n - %s = %s",
107+
+ "(memStore + blockCache + requiredFreeHeap). "
108+
+ "Check the following configuration values:%n" + " - %s = %.2f%n" + " - %s = %s%n"
109+
+ " - %s = %s%n" + " - %s = %s",
113110
MEMSTORE_SIZE_KEY, memStoreFraction, HConstants.HFILE_BLOCK_CACHE_MEMORY_SIZE_KEY,
114111
conf.get(HConstants.HFILE_BLOCK_CACHE_MEMORY_SIZE_KEY),
115112
HConstants.HFILE_BLOCK_CACHE_SIZE_KEY, conf.get(HConstants.HFILE_BLOCK_CACHE_SIZE_KEY),
116113
HBASE_REGION_SERVER_FREE_HEAP_MIN_MEMORY_SIZE_KEY,
117-
conf.get(HBASE_REGION_SERVER_FREE_HEAP_MIN_MEMORY_SIZE_KEY), HConstants.ROW_CACHE_SIZE_KEY,
118-
conf.get(HConstants.ROW_CACHE_SIZE_KEY)));
114+
conf.get(HBASE_REGION_SERVER_FREE_HEAP_MIN_MEMORY_SIZE_KEY)));
119115
}
120116
}
121117

@@ -317,15 +313,4 @@ public static long getBucketCacheSize(final Configuration conf) {
317313
}
318314
return (long) (bucketCacheSize * 1024 * 1024);
319315
}
320-
321-
public static long getRowCacheSize(Configuration conf) {
322-
long max = -1L;
323-
final MemoryUsage usage = safeGetHeapMemoryUsage();
324-
if (usage != null) {
325-
max = usage.getMax();
326-
}
327-
float globalRowCachePercent =
328-
conf.getFloat(HConstants.ROW_CACHE_SIZE_KEY, HConstants.ROW_CACHE_SIZE_DEFAULT);
329-
return ((long) (max * globalRowCachePercent));
330-
}
331316
}

hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
import java.util.concurrent.TimeUnit;
6666
import java.util.concurrent.atomic.AtomicBoolean;
6767
import java.util.concurrent.atomic.AtomicInteger;
68-
import java.util.concurrent.atomic.AtomicLong;
6968
import java.util.concurrent.atomic.LongAdder;
7069
import java.util.concurrent.locks.Lock;
7170
import java.util.concurrent.locks.ReadWriteLock;
@@ -434,11 +433,6 @@ public MetricsTableRequests getMetricsTableRequests() {
434433
*/
435434
private long openSeqNum = HConstants.NO_SEQNUM;
436435

437-
/**
438-
* Basically the same as openSeqNum, but it is updated when bulk load is done.
439-
*/
440-
private final AtomicLong rowCacheSeqNum = new AtomicLong(HConstants.NO_SEQNUM);
441-
442436
/**
443437
* The default setting for whether to enable on-demand CF loading for scan requests to this
444438
* region. Requests can override it.
@@ -7887,7 +7881,6 @@ private HRegion openHRegion(final CancelableProgressable reporter) throws IOExce
78877881
LOG.debug("checking classloading for " + this.getRegionInfo().getEncodedName());
78887882
TableDescriptorChecker.checkClassLoading(cConfig, htableDescriptor);
78897883
this.openSeqNum = initialize(reporter);
7890-
this.rowCacheSeqNum.set(this.openSeqNum);
78917884
this.mvcc.advanceTo(openSeqNum);
78927885
// The openSeqNum must be increased every time when a region is assigned, as we rely on it to
78937886
// determine whether a region has been successfully reopened. So here we always write open
@@ -8716,17 +8709,6 @@ public long getOpenSeqNum() {
87168709
return this.openSeqNum;
87178710
}
87188711

8719-
public long getRowCacheSeqNum() {
8720-
return this.rowCacheSeqNum.get();
8721-
}
8722-
8723-
/**
8724-
* This is used to invalidate the row cache of the bulk-loaded region.
8725-
*/
8726-
public void increaseRowCacheSeqNum() {
8727-
this.rowCacheSeqNum.incrementAndGet();
8728-
}
8729-
87308712
@Override
87318713
public Map<byte[], Long> getMaxStoreSeqId() {
87328714
return this.maxSeqIdInStores;

hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java

Lines changed: 32 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -354,11 +354,6 @@ public class RSRpcServices extends HBaseRpcServicesBase<HRegionServer>
354354
public static final String REGIONSERVER_BOOTSTRAP_NODES_SERVICE_CONFIG =
355355
"hbase.regionserver.bootstrap.nodes.executorService";
356356

357-
/**
358-
* The row cache service
359-
*/
360-
private final RowCacheService rowCacheService = new RowCacheService(getConfiguration());
361-
362357
/**
363358
* An Rpc callback for closing a RegionScanner.
364359
*/
@@ -673,7 +668,7 @@ private CheckAndMutateResult checkAndMutate(HRegion region, List<ClientProtos.Ac
673668
result = region.getCoprocessorHost().preCheckAndMutate(checkAndMutate);
674669
}
675670
if (result == null) {
676-
result = rowCacheService.checkAndMutate(region, checkAndMutate, nonceGroup, nonce);
671+
result = region.checkAndMutate(checkAndMutate, nonceGroup, nonce);
677672
if (region.getCoprocessorHost() != null) {
678673
result = region.getCoprocessorHost().postCheckAndMutate(checkAndMutate, result);
679674
}
@@ -1025,8 +1020,7 @@ private void doBatchOp(final RegionActionResult.Builder builder, final HRegion r
10251020
Arrays.sort(mArray, (v1, v2) -> Row.COMPARATOR.compare(v1, v2));
10261021
}
10271022

1028-
OperationStatus[] codes =
1029-
rowCacheService.batchMutate(region, mArray, atomic, nonceGroup, nonce);
1023+
OperationStatus[] codes = region.batchMutate(mArray, atomic, nonceGroup, nonce);
10301024

10311025
// When atomic is true, it indicates that the mutateRow API or the batch API with
10321026
// RowMutations is called. In this case, we need to merge the results of the
@@ -2342,11 +2336,6 @@ public UpdateFavoredNodesResponse updateFavoredNodes(RpcController controller,
23422336
@Override
23432337
public BulkLoadHFileResponse bulkLoadHFile(final RpcController controller,
23442338
final BulkLoadHFileRequest request) throws ServiceException {
2345-
return rowCacheService.bulkLoadHFile(this, request);
2346-
}
2347-
2348-
BulkLoadHFileResponse bulkLoadHFileInternal(final BulkLoadHFileRequest request)
2349-
throws ServiceException {
23502339
long start = EnvironmentEdgeManager.currentTime();
23512340
List<String> clusterIds = new ArrayList<>(request.getClusterIdsList());
23522341
if (clusterIds.contains(this.server.getClusterId())) {
@@ -2603,7 +2592,8 @@ private Result get(Get get, HRegion region, RegionScannersCloseCallBack closeCal
26032592
RegionScannerImpl scanner = null;
26042593
long blockBytesScannedBefore = context.getBlockBytesScanned();
26052594
try {
2606-
scanner = rowCacheService.getScanner(region, scan, results);
2595+
scanner = region.getScanner(scan);
2596+
scanner.next(results);
26072597
} finally {
26082598
if (scanner != null) {
26092599
if (closeCallBack == null) {
@@ -3012,10 +3002,33 @@ public MutateResponse mutate(final RpcController rpcc, final MutateRequest reque
30123002
builder.setMetrics(ProtobufUtil.toQueryMetrics(result.getMetrics()));
30133003
}
30143004
} else {
3015-
Result r = rowCacheService.mutate(this, region, mutation, quota, cellScanner, nonceGroup,
3016-
spaceQuotaEnforcement, context);
3017-
if (r == Result.EMPTY_RESULT) {
3018-
builder.setProcessed(true);
3005+
Result r = null;
3006+
Boolean processed = null;
3007+
MutationType type = mutation.getMutateType();
3008+
switch (type) {
3009+
case APPEND:
3010+
// TODO: this doesn't actually check anything.
3011+
r = append(region, quota, mutation, cellScanner, nonceGroup, spaceQuotaEnforcement,
3012+
context);
3013+
break;
3014+
case INCREMENT:
3015+
// TODO: this doesn't actually check anything.
3016+
r = increment(region, quota, mutation, cellScanner, nonceGroup, spaceQuotaEnforcement,
3017+
context);
3018+
break;
3019+
case PUT:
3020+
put(region, quota, mutation, cellScanner, spaceQuotaEnforcement);
3021+
processed = Boolean.TRUE;
3022+
break;
3023+
case DELETE:
3024+
delete(region, quota, mutation, cellScanner, spaceQuotaEnforcement);
3025+
processed = Boolean.TRUE;
3026+
break;
3027+
default:
3028+
throw new DoNotRetryIOException("Unsupported mutate type: " + type.name());
3029+
}
3030+
if (processed != null) {
3031+
builder.setProcessed(processed);
30193032
}
30203033
boolean clientCellBlockSupported = isClientCellBlockSupport(context);
30213034
addResult(builder, r, controller, clientCellBlockSupported);
@@ -3034,29 +3047,6 @@ public MutateResponse mutate(final RpcController rpcc, final MutateRequest reque
30343047
}
30353048
}
30363049

3037-
Result mutateInternal(MutationProto mutation, HRegion region, OperationQuota quota,
3038-
CellScanner cellScanner, long nonceGroup, ActivePolicyEnforcement spaceQuotaEnforcement,
3039-
RpcCallContext context) throws IOException {
3040-
MutationType type = mutation.getMutateType();
3041-
return switch (type) {
3042-
case APPEND ->
3043-
// TODO: this doesn't actually check anything.
3044-
append(region, quota, mutation, cellScanner, nonceGroup, spaceQuotaEnforcement, context);
3045-
case INCREMENT ->
3046-
// TODO: this doesn't actually check anything.
3047-
increment(region, quota, mutation, cellScanner, nonceGroup, spaceQuotaEnforcement,
3048-
context);
3049-
case PUT -> {
3050-
put(region, quota, mutation, cellScanner, spaceQuotaEnforcement);
3051-
yield Result.EMPTY_RESULT;
3052-
}
3053-
case DELETE -> {
3054-
delete(region, quota, mutation, cellScanner, spaceQuotaEnforcement);
3055-
yield Result.EMPTY_RESULT;
3056-
}
3057-
};
3058-
}
3059-
30603050
private void put(HRegion region, OperationQuota quota, MutationProto mutation,
30613051
CellScanner cellScanner, ActivePolicyEnforcement spaceQuota) throws IOException {
30623052
long before = EnvironmentEdgeManager.currentTime();
@@ -3105,7 +3095,7 @@ private CheckAndMutateResult checkAndMutate(HRegion region, OperationQuota quota
31053095
result = region.getCoprocessorHost().preCheckAndMutate(checkAndMutate);
31063096
}
31073097
if (result == null) {
3108-
result = rowCacheService.checkAndMutate(region, checkAndMutate, nonceGroup, nonce);
3098+
result = region.checkAndMutate(checkAndMutate, nonceGroup, nonce);
31093099
if (region.getCoprocessorHost() != null) {
31103100
result = region.getCoprocessorHost().postCheckAndMutate(checkAndMutate, result);
31113101
}
@@ -4089,9 +4079,4 @@ RegionScannerContext checkQuotaAndGetRegionScannerContext(ScanRequest request,
40894079
Pair<String, RegionScannerHolder> pair = newRegionScanner(request, region, builder);
40904080
return new RegionScannerContext(pair.getFirst(), pair.getSecond(), quota);
40914081
}
4092-
4093-
// For testing only
4094-
public RowCacheService getRowCacheService() {
4095-
return rowCacheService;
4096-
}
40974082
}

0 commit comments

Comments
 (0)