Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,13 @@ public long getLastMajorCompactionTs() {
return metrics.getLastMajorCompactionTimestamp();
}

/**
* @return the reference count for the stores of this region
*/
public int getStoreRefCount() {
return metrics.getStoreRefCount();
}

/**
* @see java.lang.Object#toString()
*/
Expand All @@ -371,6 +378,7 @@ public String toString() {
StringBuilder sb = Strings.appendKeyValue(new StringBuilder(), "numberOfStores",
this.getStores());
Strings.appendKeyValue(sb, "numberOfStorefiles", this.getStorefiles());
Strings.appendKeyValue(sb, "storeRefCount", this.getStoreRefCount());
Strings.appendKeyValue(sb, "storefileUncompressedSizeMB",
this.getStoreUncompressedSizeMB());
Strings.appendKeyValue(sb, "lastMajorCompactionTimestamp",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,8 @@ default String getNameAsString() {
*/
long getLastMajorCompactionTimestamp();

/**
* @return the reference count for the stores of this region
*/
int getStoreRefCount();
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public static RegionMetrics toRegionMetrics(ClusterStatusProtos.RegionLoad regio
Size.Unit.KILOBYTE))
.setStoreCount(regionLoadPB.getStores())
.setStoreFileCount(regionLoadPB.getStorefiles())
.setStoreRefCount(regionLoadPB.getStoreRefCount())
.setStoreFileSize(new Size(regionLoadPB.getStorefileSizeMB(), Size.Unit.MEGABYTE))
.setStoreSequenceIds(regionLoadPB.getStoreCompleteSequenceIdList().stream()
.collect(Collectors.toMap(
Expand Down Expand Up @@ -111,6 +112,7 @@ public static ClusterStatusProtos.RegionLoad toRegionLoad(RegionMetrics regionMe
.get(Size.Unit.KILOBYTE))
.setStores(regionMetrics.getStoreCount())
.setStorefiles(regionMetrics.getStoreCount())
.setStoreRefCount(regionMetrics.getStoreRefCount())
.setStorefileSizeMB((int) regionMetrics.getStoreFileSize().get(Size.Unit.MEGABYTE))
.addAllStoreCompleteSequenceId(toStoreSequenceId(regionMetrics.getStoreSequenceId()))
.setStoreUncompressedSizeMB(
Expand All @@ -125,6 +127,7 @@ public static RegionMetricsBuilder newBuilder(byte[] name) {
private final byte[] name;
private int storeCount;
private int storeFileCount;
private int storeRefCount;
private long compactingCellCount;
private long compactedCellCount;
private Size storeFileSize = Size.ZERO;
Expand Down Expand Up @@ -154,6 +157,10 @@ public RegionMetricsBuilder setStoreFileCount(int value) {
this.storeFileCount = value;
return this;
}
public RegionMetricsBuilder setStoreRefCount(int value) {
this.storeRefCount = value;
return this;
}
public RegionMetricsBuilder setCompactingCellCount(long value) {
this.compactingCellCount = value;
return this;
Expand Down Expand Up @@ -227,6 +234,7 @@ public RegionMetrics build() {
return new RegionMetricsImpl(name,
storeCount,
storeFileCount,
storeRefCount,
compactingCellCount,
compactedCellCount,
storeFileSize,
Expand All @@ -250,6 +258,7 @@ private static class RegionMetricsImpl implements RegionMetrics {
private final byte[] name;
private final int storeCount;
private final int storeFileCount;
private final int storeRefCount;
private final long compactingCellCount;
private final long compactedCellCount;
private final Size storeFileSize;
Expand All @@ -270,6 +279,7 @@ private static class RegionMetricsImpl implements RegionMetrics {
RegionMetricsImpl(byte[] name,
int storeCount,
int storeFileCount,
int storeRefCount,
final long compactingCellCount,
long compactedCellCount,
Size storeFileSize,
Expand All @@ -290,6 +300,7 @@ private static class RegionMetricsImpl implements RegionMetrics {
this.name = Preconditions.checkNotNull(name);
this.storeCount = storeCount;
this.storeFileCount = storeFileCount;
this.storeRefCount = storeRefCount;
this.compactingCellCount = compactingCellCount;
this.compactedCellCount = compactedCellCount;
this.storeFileSize = Preconditions.checkNotNull(storeFileSize);
Expand Down Expand Up @@ -324,6 +335,11 @@ public int getStoreFileCount() {
return storeFileCount;
}

@Override
public int getStoreRefCount() {
return storeRefCount;
}

@Override
public Size getStoreFileSize() {
return storeFileSize;
Expand Down Expand Up @@ -415,6 +431,8 @@ public String toString() {
this.getStoreCount());
Strings.appendKeyValue(sb, "storeFileCount",
this.getStoreFileCount());
Strings.appendKeyValue(sb, "storeRefCount",
this.getStoreRefCount());
Strings.appendKeyValue(sb, "uncompressedStoreFileSize",
this.getUncompressedStoreFileSize());
Strings.appendKeyValue(sb, "lastMajorCompactionTimestamp",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ public interface MetricsRegionServerSource extends BaseSource, JvmPauseMonitorSo
String WALFILE_SIZE_DESC = "Size of all WAL Files";
String STOREFILE_COUNT = "storeFileCount";
String STOREFILE_COUNT_DESC = "Number of Store Files";
String STORE_REF_COUNT = "storeRefCount";
String STORE_REF_COUNT_DESC = "Store reference count";
String MEMSTORE_SIZE = "memStoreSize";
String MEMSTORE_SIZE_DESC = "Size of the memstore";
String STOREFILE_SIZE = "storeFileSize";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,9 @@ public interface MetricsRegionWrapper {
* Get the replica id of this region.
*/
int getReplicaId();

/**
* @return the number of references active on the store
*/
long getStoreRefCount();
}
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ void snapshot(MetricsRecordBuilder mrb, boolean ignored) {
regionNamePrefix + MetricsRegionServerSource.STOREFILE_COUNT,
MetricsRegionServerSource.STOREFILE_COUNT_DESC),
this.regionWrapper.getNumStoreFiles());
mrb.addGauge(Interns.info(
regionNamePrefix + MetricsRegionServerSource.STORE_REF_COUNT,
MetricsRegionServerSource.STORE_REF_COUNT),
this.regionWrapper.getStoreRefCount());
mrb.addGauge(Interns.info(
regionNamePrefix + MetricsRegionServerSource.MEMSTORE_SIZE,
MetricsRegionServerSource.MEMSTORE_SIZE_DESC),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ public long getNumStoreFiles() {
return 0;
}

@Override
public long getStoreRefCount() {
return 0;
}

@Override
public long getMemStoreSize() {
return 0;
Expand Down
3 changes: 3 additions & 0 deletions hbase-protocol-shaded/src/main/protobuf/ClusterStatus.proto
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ message RegionLoad {

/** the current total coprocessor requests made to region */
optional uint64 cp_requests_count = 20;

/** the number of references active on the store */
optional int32 store_ref_count = 21 [default = 0];
}

/* Server-level protobufs */
Expand Down
3 changes: 3 additions & 0 deletions hbase-protocol/src/main/protobuf/ClusterStatus.proto
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ message RegionLoad {

/** the current total coprocessor requests made to region */
optional uint64 cp_requests_count = 20;

/** the number of references active on the store */
optional int32 store_ref_count = 21 [default = 0];
}

/* Server-level protobufs */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2776,4 +2776,10 @@ void reportArchivedFilesForQuota(List<? extends StoreFile> archivedFiles, List<L
public int getCurrentParallelPutCount() {
return currentParallelPutCount.get();
}

public int getStoreRefCount() {
return this.storeEngine.getStoreFileManager().getStorefiles().stream()
.filter(sf -> sf.getReader() != null).filter(HStoreFile::isHFile)
.mapToInt(HStoreFile::getRefCount).sum();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class MetricsRegionWrapperImpl implements MetricsRegionWrapper, Closeable
private ScheduledExecutorService executor;
private Runnable runnable;
private long numStoreFiles;
private long storeRefCount;
private long memstoreSize;
private long storeFileSize;
private long maxStoreFileAge;
Expand Down Expand Up @@ -119,6 +120,11 @@ public long getStoreFileSize() {
return storeFileSize;
}

@Override
public long getStoreRefCount() {
return storeRefCount;
}

@Override
public long getReadRequestCount() {
return this.region.getReadRequestsCount();
Expand Down Expand Up @@ -226,6 +232,7 @@ public class HRegionMetricsWrapperRunnable implements Runnable {
@Override
public void run() {
long tempNumStoreFiles = 0;
int tempStoreRefCount = 0;
long tempMemstoreSize = 0;
long tempStoreFileSize = 0;
long tempMaxStoreFileAge = 0;
Expand All @@ -237,8 +244,9 @@ public void run() {
long avgAgeNumerator = 0;
long numHFiles = 0;
if (region.stores != null) {
for (Store store : region.stores.values()) {
for (HStore store : region.stores.values()) {
tempNumStoreFiles += store.getStorefilesCount();
tempStoreRefCount += store.getStoreRefCount();
tempMemstoreSize += store.getMemStoreSize().getDataSize();
tempStoreFileSize += store.getStorefilesSize();
OptionalLong storeMaxStoreFileAge = store.getMaxStoreFileAge();
Expand All @@ -265,6 +273,7 @@ public void run() {
}

numStoreFiles = tempNumStoreFiles;
storeRefCount = tempStoreRefCount;
memstoreSize = tempMemstoreSize;
storeFileSize = tempStoreFileSize;
maxStoreFileAge = tempMaxStoreFileAge;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ public long getNumStoreFiles() {
return 102;
}

@Override
public long getStoreRefCount() {
return 0;
}

@Override
public long getMemStoreSize() {
return 103;
Expand Down