Skip to content

Commit ad1eafa

Browse files
committed
HBASE-22459 Expose store reader reference count
1 parent 8e47c8e commit ad1eafa

File tree

17 files changed

+98
-6
lines changed

17 files changed

+98
-6
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,13 @@ public long getLastMajorCompactionTs() {
363363
return metrics.getLastMajorCompactionTimestamp();
364364
}
365365

366+
/**
367+
* @return the reference count for the stores of this region
368+
*/
369+
public int getStoreRefCount() {
370+
return metrics.getStoreRefCount();
371+
}
372+
366373
/**
367374
* @see java.lang.Object#toString()
368375
*/
@@ -371,6 +378,7 @@ public String toString() {
371378
StringBuilder sb = Strings.appendKeyValue(new StringBuilder(), "numberOfStores",
372379
this.getStores());
373380
Strings.appendKeyValue(sb, "numberOfStorefiles", this.getStorefiles());
381+
Strings.appendKeyValue(sb, "storeRefCount", this.getStoreRefCount());
374382
Strings.appendKeyValue(sb, "storefileUncompressedSizeMB",
375383
this.getStoreUncompressedSizeMB());
376384
Strings.appendKeyValue(sb, "lastMajorCompactionTimestamp",

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,8 @@ default String getNameAsString() {
150150
*/
151151
long getLastMajorCompactionTimestamp();
152152

153+
/**
154+
* @return the reference count for the stores of this region
155+
*/
156+
int getStoreRefCount();
153157
}

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public static RegionMetrics toRegionMetrics(ClusterStatusProtos.RegionLoad regio
6565
Size.Unit.KILOBYTE))
6666
.setStoreCount(regionLoadPB.getStores())
6767
.setStoreFileCount(regionLoadPB.getStorefiles())
68+
.setStoreRefCount(regionLoadPB.getStoreRefCount())
6869
.setStoreFileSize(new Size(regionLoadPB.getStorefileSizeMB(), Size.Unit.MEGABYTE))
6970
.setStoreSequenceIds(regionLoadPB.getStoreCompleteSequenceIdList().stream()
7071
.collect(Collectors.toMap(
@@ -111,6 +112,7 @@ public static ClusterStatusProtos.RegionLoad toRegionLoad(RegionMetrics regionMe
111112
.get(Size.Unit.KILOBYTE))
112113
.setStores(regionMetrics.getStoreCount())
113114
.setStorefiles(regionMetrics.getStoreCount())
115+
.setStoreRefCount(regionMetrics.getStoreRefCount())
114116
.setStorefileSizeMB((int) regionMetrics.getStoreFileSize().get(Size.Unit.MEGABYTE))
115117
.addAllStoreCompleteSequenceId(toStoreSequenceId(regionMetrics.getStoreSequenceId()))
116118
.setStoreUncompressedSizeMB(
@@ -125,6 +127,7 @@ public static RegionMetricsBuilder newBuilder(byte[] name) {
125127
private final byte[] name;
126128
private int storeCount;
127129
private int storeFileCount;
130+
private int storeRefCount;
128131
private long compactingCellCount;
129132
private long compactedCellCount;
130133
private Size storeFileSize = Size.ZERO;
@@ -154,6 +157,10 @@ public RegionMetricsBuilder setStoreFileCount(int value) {
154157
this.storeFileCount = value;
155158
return this;
156159
}
160+
public RegionMetricsBuilder setStoreRefCount(int value) {
161+
this.storeRefCount = value;
162+
return this;
163+
}
157164
public RegionMetricsBuilder setCompactingCellCount(long value) {
158165
this.compactingCellCount = value;
159166
return this;
@@ -227,6 +234,7 @@ public RegionMetrics build() {
227234
return new RegionMetricsImpl(name,
228235
storeCount,
229236
storeFileCount,
237+
storeRefCount,
230238
compactingCellCount,
231239
compactedCellCount,
232240
storeFileSize,
@@ -250,6 +258,7 @@ private static class RegionMetricsImpl implements RegionMetrics {
250258
private final byte[] name;
251259
private final int storeCount;
252260
private final int storeFileCount;
261+
private final int storeRefCount;
253262
private final long compactingCellCount;
254263
private final long compactedCellCount;
255264
private final Size storeFileSize;
@@ -270,6 +279,7 @@ private static class RegionMetricsImpl implements RegionMetrics {
270279
RegionMetricsImpl(byte[] name,
271280
int storeCount,
272281
int storeFileCount,
282+
int storeRefCount,
273283
final long compactingCellCount,
274284
long compactedCellCount,
275285
Size storeFileSize,
@@ -290,6 +300,7 @@ private static class RegionMetricsImpl implements RegionMetrics {
290300
this.name = Preconditions.checkNotNull(name);
291301
this.storeCount = storeCount;
292302
this.storeFileCount = storeFileCount;
303+
this.storeRefCount = storeRefCount;
293304
this.compactingCellCount = compactingCellCount;
294305
this.compactedCellCount = compactedCellCount;
295306
this.storeFileSize = Preconditions.checkNotNull(storeFileSize);
@@ -324,6 +335,11 @@ public int getStoreFileCount() {
324335
return storeFileCount;
325336
}
326337

338+
@Override
339+
public int getStoreRefCount() {
340+
return storeRefCount;
341+
}
342+
327343
@Override
328344
public Size getStoreFileSize() {
329345
return storeFileSize;
@@ -415,6 +431,8 @@ public String toString() {
415431
this.getStoreCount());
416432
Strings.appendKeyValue(sb, "storeFileCount",
417433
this.getStoreFileCount());
434+
Strings.appendKeyValue(sb, "storeRefCount",
435+
this.getStoreRefCount());
418436
Strings.appendKeyValue(sb, "uncompressedStoreFileSize",
419437
this.getUncompressedStoreFileSize());
420438
Strings.appendKeyValue(sb, "lastMajorCompactionTimestamp",

hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSource.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,8 @@ public interface MetricsRegionServerSource extends BaseSource, JvmPauseMonitorSo
231231
String WALFILE_SIZE_DESC = "Size of all WAL Files";
232232
String STOREFILE_COUNT = "storeFileCount";
233233
String STOREFILE_COUNT_DESC = "Number of Store Files";
234+
String STORE_REF_COUNT = "storeRefCount";
235+
String STORE_REF_COUNT_DESC = "Store reference count";
234236
String MEMSTORE_SIZE = "memStoreSize";
235237
String MEMSTORE_SIZE_DESC = "Size of the memstore";
236238
String STOREFILE_SIZE = "storeFileSize";

hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionWrapper.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,4 +159,9 @@ public interface MetricsRegionWrapper {
159159
* Get the replica id of this region.
160160
*/
161161
int getReplicaId();
162+
163+
/**
164+
* @return the number of references active on the store
165+
*/
166+
long getStoreRefCount();
162167
}

hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionSourceImpl.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,10 @@ void snapshot(MetricsRecordBuilder mrb, boolean ignored) {
213213
regionNamePrefix + MetricsRegionServerSource.STOREFILE_COUNT,
214214
MetricsRegionServerSource.STOREFILE_COUNT_DESC),
215215
this.regionWrapper.getNumStoreFiles());
216+
mrb.addGauge(Interns.info(
217+
regionNamePrefix + MetricsRegionServerSource.STORE_REF_COUNT,
218+
MetricsRegionServerSource.STORE_REF_COUNT),
219+
this.regionWrapper.getStoreRefCount());
216220
mrb.addGauge(Interns.info(
217221
regionNamePrefix + MetricsRegionServerSource.MEMSTORE_SIZE,
218222
MetricsRegionServerSource.MEMSTORE_SIZE_DESC),

hbase-hadoop2-compat/src/test/java/org/apache/hadoop/hbase/regionserver/TestMetricsRegionSourceImpl.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ public long getNumStoreFiles() {
9494
return 0;
9595
}
9696

97+
@Override
98+
public long getStoreRefCount() {
99+
return 0;
100+
}
101+
97102
@Override
98103
public long getMemStoreSize() {
99104
return 0;

hbase-protocol-shaded/src/main/protobuf/ClusterStatus.proto

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ message RegionLoad {
146146

147147
/** the current total coprocessor requests made to region */
148148
optional uint64 cp_requests_count = 20;
149+
150+
/** the number of references active on the store */
151+
optional int32 store_ref_count = 21 [default = 0];
149152
}
150153

151154
/* Server-level protobufs */

hbase-protocol/src/main/protobuf/ClusterStatus.proto

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ message RegionLoad {
142142

143143
/** the current total coprocessor requests made to region */
144144
optional uint64 cp_requests_count = 20;
145+
146+
/** the number of references active on the store */
147+
optional int32 store_ref_count = 21 [default = 0];
145148
}
146149

147150
/* Server-level protobufs */

hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/StorageClusterStatusResource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public Response get(final @Context UriInfo uriInfo) {
8787
node.setRequests(load.getRequestCount());
8888
for (RegionMetrics region: load.getRegionMetrics().values()) {
8989
node.addRegion(region.getRegionName(), region.getStoreCount(),
90-
region.getStoreFileCount(),
90+
region.getStoreFileCount(), region.getStoreRefCount(),
9191
(int) region.getStoreFileSize().get(Size.Unit.MEGABYTE),
9292
(int) region.getMemStoreSize().get(Size.Unit.MEGABYTE),
9393
(long) region.getStoreFileIndexSize().get(Size.Unit.KILOBYTE),

0 commit comments

Comments
 (0)