HBASE-22459 Expose store reader reference count (#248)
This commit is contained in:
parent
89260f4f3e
commit
d06c3af980
|
@ -358,6 +358,13 @@ public class RegionLoad implements RegionMetrics {
|
||||||
return metrics.getLastMajorCompactionTimestamp();
|
return metrics.getLastMajorCompactionTimestamp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the reference count for the stores of this region
|
||||||
|
*/
|
||||||
|
public int getStoreRefCount() {
|
||||||
|
return metrics.getStoreRefCount();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see java.lang.Object#toString()
|
* @see java.lang.Object#toString()
|
||||||
*/
|
*/
|
||||||
|
@ -366,6 +373,7 @@ public class RegionLoad implements RegionMetrics {
|
||||||
StringBuilder sb = Strings.appendKeyValue(new StringBuilder(), "numberOfStores",
|
StringBuilder sb = Strings.appendKeyValue(new StringBuilder(), "numberOfStores",
|
||||||
this.getStores());
|
this.getStores());
|
||||||
Strings.appendKeyValue(sb, "numberOfStorefiles", this.getStorefiles());
|
Strings.appendKeyValue(sb, "numberOfStorefiles", this.getStorefiles());
|
||||||
|
Strings.appendKeyValue(sb, "storeRefCount", this.getStoreRefCount());
|
||||||
Strings.appendKeyValue(sb, "storefileUncompressedSizeMB",
|
Strings.appendKeyValue(sb, "storefileUncompressedSizeMB",
|
||||||
this.getStoreUncompressedSizeMB());
|
this.getStoreUncompressedSizeMB());
|
||||||
Strings.appendKeyValue(sb, "lastMajorCompactionTimestamp",
|
Strings.appendKeyValue(sb, "lastMajorCompactionTimestamp",
|
||||||
|
|
|
@ -144,4 +144,8 @@ public interface RegionMetrics {
|
||||||
*/
|
*/
|
||||||
long getLastMajorCompactionTimestamp();
|
long getLastMajorCompactionTimestamp();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the reference count for the stores of this region
|
||||||
|
*/
|
||||||
|
int getStoreRefCount();
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,7 @@ public final class RegionMetricsBuilder {
|
||||||
Size.Unit.KILOBYTE))
|
Size.Unit.KILOBYTE))
|
||||||
.setStoreCount(regionLoadPB.getStores())
|
.setStoreCount(regionLoadPB.getStores())
|
||||||
.setStoreFileCount(regionLoadPB.getStorefiles())
|
.setStoreFileCount(regionLoadPB.getStorefiles())
|
||||||
|
.setStoreRefCount(regionLoadPB.getStoreRefCount())
|
||||||
.setStoreFileSize(new Size(regionLoadPB.getStorefileSizeMB(), Size.Unit.MEGABYTE))
|
.setStoreFileSize(new Size(regionLoadPB.getStorefileSizeMB(), Size.Unit.MEGABYTE))
|
||||||
.setStoreSequenceIds(regionLoadPB.getStoreCompleteSequenceIdList().stream()
|
.setStoreSequenceIds(regionLoadPB.getStoreCompleteSequenceIdList().stream()
|
||||||
.collect(Collectors.toMap(
|
.collect(Collectors.toMap(
|
||||||
|
@ -109,6 +110,7 @@ public final class RegionMetricsBuilder {
|
||||||
.get(Size.Unit.KILOBYTE))
|
.get(Size.Unit.KILOBYTE))
|
||||||
.setStores(regionMetrics.getStoreCount())
|
.setStores(regionMetrics.getStoreCount())
|
||||||
.setStorefiles(regionMetrics.getStoreCount())
|
.setStorefiles(regionMetrics.getStoreCount())
|
||||||
|
.setStoreRefCount(regionMetrics.getStoreRefCount())
|
||||||
.setStorefileSizeMB((int) regionMetrics.getStoreFileSize().get(Size.Unit.MEGABYTE))
|
.setStorefileSizeMB((int) regionMetrics.getStoreFileSize().get(Size.Unit.MEGABYTE))
|
||||||
.addAllStoreCompleteSequenceId(toStoreSequenceId(regionMetrics.getStoreSequenceId()))
|
.addAllStoreCompleteSequenceId(toStoreSequenceId(regionMetrics.getStoreSequenceId()))
|
||||||
.setStoreUncompressedSizeMB(
|
.setStoreUncompressedSizeMB(
|
||||||
|
@ -123,6 +125,7 @@ public final class RegionMetricsBuilder {
|
||||||
private final byte[] name;
|
private final byte[] name;
|
||||||
private int storeCount;
|
private int storeCount;
|
||||||
private int storeFileCount;
|
private int storeFileCount;
|
||||||
|
private int storeRefCount;
|
||||||
private long compactingCellCount;
|
private long compactingCellCount;
|
||||||
private long compactedCellCount;
|
private long compactedCellCount;
|
||||||
private Size storeFileSize = Size.ZERO;
|
private Size storeFileSize = Size.ZERO;
|
||||||
|
@ -151,6 +154,10 @@ public final class RegionMetricsBuilder {
|
||||||
this.storeFileCount = value;
|
this.storeFileCount = value;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
public RegionMetricsBuilder setStoreRefCount(int value) {
|
||||||
|
this.storeRefCount = value;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
public RegionMetricsBuilder setCompactingCellCount(long value) {
|
public RegionMetricsBuilder setCompactingCellCount(long value) {
|
||||||
this.compactingCellCount = value;
|
this.compactingCellCount = value;
|
||||||
return this;
|
return this;
|
||||||
|
@ -220,6 +227,7 @@ public final class RegionMetricsBuilder {
|
||||||
return new RegionMetricsImpl(name,
|
return new RegionMetricsImpl(name,
|
||||||
storeCount,
|
storeCount,
|
||||||
storeFileCount,
|
storeFileCount,
|
||||||
|
storeRefCount,
|
||||||
compactingCellCount,
|
compactingCellCount,
|
||||||
compactedCellCount,
|
compactedCellCount,
|
||||||
storeFileSize,
|
storeFileSize,
|
||||||
|
@ -242,6 +250,7 @@ public final class RegionMetricsBuilder {
|
||||||
private final byte[] name;
|
private final byte[] name;
|
||||||
private final int storeCount;
|
private final int storeCount;
|
||||||
private final int storeFileCount;
|
private final int storeFileCount;
|
||||||
|
private final int storeRefCount;
|
||||||
private final long compactingCellCount;
|
private final long compactingCellCount;
|
||||||
private final long compactedCellCount;
|
private final long compactedCellCount;
|
||||||
private final Size storeFileSize;
|
private final Size storeFileSize;
|
||||||
|
@ -261,6 +270,7 @@ public final class RegionMetricsBuilder {
|
||||||
RegionMetricsImpl(byte[] name,
|
RegionMetricsImpl(byte[] name,
|
||||||
int storeCount,
|
int storeCount,
|
||||||
int storeFileCount,
|
int storeFileCount,
|
||||||
|
int storeRefCount,
|
||||||
final long compactingCellCount,
|
final long compactingCellCount,
|
||||||
long compactedCellCount,
|
long compactedCellCount,
|
||||||
Size storeFileSize,
|
Size storeFileSize,
|
||||||
|
@ -280,6 +290,7 @@ public final class RegionMetricsBuilder {
|
||||||
this.name = Preconditions.checkNotNull(name);
|
this.name = Preconditions.checkNotNull(name);
|
||||||
this.storeCount = storeCount;
|
this.storeCount = storeCount;
|
||||||
this.storeFileCount = storeFileCount;
|
this.storeFileCount = storeFileCount;
|
||||||
|
this.storeRefCount = storeRefCount;
|
||||||
this.compactingCellCount = compactingCellCount;
|
this.compactingCellCount = compactingCellCount;
|
||||||
this.compactedCellCount = compactedCellCount;
|
this.compactedCellCount = compactedCellCount;
|
||||||
this.storeFileSize = Preconditions.checkNotNull(storeFileSize);
|
this.storeFileSize = Preconditions.checkNotNull(storeFileSize);
|
||||||
|
@ -313,6 +324,11 @@ public final class RegionMetricsBuilder {
|
||||||
return storeFileCount;
|
return storeFileCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getStoreRefCount() {
|
||||||
|
return storeRefCount;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Size getStoreFileSize() {
|
public Size getStoreFileSize() {
|
||||||
return storeFileSize;
|
return storeFileSize;
|
||||||
|
@ -399,6 +415,8 @@ public final class RegionMetricsBuilder {
|
||||||
this.getStoreCount());
|
this.getStoreCount());
|
||||||
Strings.appendKeyValue(sb, "storeFileCount",
|
Strings.appendKeyValue(sb, "storeFileCount",
|
||||||
this.getStoreFileCount());
|
this.getStoreFileCount());
|
||||||
|
Strings.appendKeyValue(sb, "storeRefCount",
|
||||||
|
this.getStoreRefCount());
|
||||||
Strings.appendKeyValue(sb, "uncompressedStoreFileSize",
|
Strings.appendKeyValue(sb, "uncompressedStoreFileSize",
|
||||||
this.getUncompressedStoreFileSize());
|
this.getUncompressedStoreFileSize());
|
||||||
Strings.appendKeyValue(sb, "lastMajorCompactionTimestamp",
|
Strings.appendKeyValue(sb, "lastMajorCompactionTimestamp",
|
||||||
|
|
|
@ -231,6 +231,8 @@ public interface MetricsRegionServerSource extends BaseSource, JvmPauseMonitorSo
|
||||||
String WALFILE_SIZE_DESC = "Size of all WAL Files";
|
String WALFILE_SIZE_DESC = "Size of all WAL Files";
|
||||||
String STOREFILE_COUNT = "storeFileCount";
|
String STOREFILE_COUNT = "storeFileCount";
|
||||||
String STOREFILE_COUNT_DESC = "Number of Store Files";
|
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 = "memStoreSize";
|
||||||
String MEMSTORE_SIZE_DESC = "Size of the memstore";
|
String MEMSTORE_SIZE_DESC = "Size of the memstore";
|
||||||
String STOREFILE_SIZE = "storeFileSize";
|
String STOREFILE_SIZE = "storeFileSize";
|
||||||
|
|
|
@ -152,4 +152,9 @@ public interface MetricsRegionWrapper {
|
||||||
* Get the replica id of this region.
|
* Get the replica id of this region.
|
||||||
*/
|
*/
|
||||||
int getReplicaId();
|
int getReplicaId();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the number of references active on the store
|
||||||
|
*/
|
||||||
|
long getStoreRefCount();
|
||||||
}
|
}
|
||||||
|
|
|
@ -213,6 +213,10 @@ public class MetricsRegionSourceImpl implements MetricsRegionSource {
|
||||||
regionNamePrefix + MetricsRegionServerSource.STOREFILE_COUNT,
|
regionNamePrefix + MetricsRegionServerSource.STOREFILE_COUNT,
|
||||||
MetricsRegionServerSource.STOREFILE_COUNT_DESC),
|
MetricsRegionServerSource.STOREFILE_COUNT_DESC),
|
||||||
this.regionWrapper.getNumStoreFiles());
|
this.regionWrapper.getNumStoreFiles());
|
||||||
|
mrb.addGauge(Interns.info(
|
||||||
|
regionNamePrefix + MetricsRegionServerSource.STORE_REF_COUNT,
|
||||||
|
MetricsRegionServerSource.STORE_REF_COUNT),
|
||||||
|
this.regionWrapper.getStoreRefCount());
|
||||||
mrb.addGauge(Interns.info(
|
mrb.addGauge(Interns.info(
|
||||||
regionNamePrefix + MetricsRegionServerSource.MEMSTORE_SIZE,
|
regionNamePrefix + MetricsRegionServerSource.MEMSTORE_SIZE,
|
||||||
MetricsRegionServerSource.MEMSTORE_SIZE_DESC),
|
MetricsRegionServerSource.MEMSTORE_SIZE_DESC),
|
||||||
|
|
|
@ -94,6 +94,11 @@ public class TestMetricsRegionSourceImpl {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getStoreRefCount() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getMemStoreSize() {
|
public long getMemStoreSize() {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -143,6 +143,12 @@ message RegionLoad {
|
||||||
|
|
||||||
/** the current total filtered read requests made to region */
|
/** the current total filtered read requests made to region */
|
||||||
optional uint64 filtered_read_requests_count = 19;
|
optional uint64 filtered_read_requests_count = 19;
|
||||||
|
|
||||||
|
/** master defines cp_requests_count = 20, the current total coprocessor
|
||||||
|
requests made to region */
|
||||||
|
|
||||||
|
/** the number of references active on the store */
|
||||||
|
optional int32 store_ref_count = 21 [default = 0];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Server-level protobufs */
|
/* Server-level protobufs */
|
||||||
|
|
|
@ -139,6 +139,12 @@ message RegionLoad {
|
||||||
|
|
||||||
/** the current total filtered read requests made to region */
|
/** the current total filtered read requests made to region */
|
||||||
optional uint64 filtered_read_requests_count = 19;
|
optional uint64 filtered_read_requests_count = 19;
|
||||||
|
|
||||||
|
/** master defines cp_requests_count = 20, the current total coprocessor
|
||||||
|
requests made to region */
|
||||||
|
|
||||||
|
/** the number of references active on the store */
|
||||||
|
optional int32 store_ref_count = 21 [default = 0];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Server-level protobufs */
|
/* Server-level protobufs */
|
||||||
|
|
|
@ -2668,4 +2668,10 @@ public class HStore implements Store, HeapSize, StoreConfigInformation, Propagat
|
||||||
public int getCurrentParallelPutCount() {
|
public int getCurrentParallelPutCount() {
|
||||||
return currentParallelPutCount.get();
|
return currentParallelPutCount.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getStoreRefCount() {
|
||||||
|
return this.storeEngine.getStoreFileManager().getStorefiles().stream()
|
||||||
|
.filter(sf -> sf.getReader() != null).filter(HStoreFile::isHFile)
|
||||||
|
.mapToInt(HStoreFile::getRefCount).sum();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,7 @@ public class MetricsRegionWrapperImpl implements MetricsRegionWrapper, Closeable
|
||||||
private ScheduledExecutorService executor;
|
private ScheduledExecutorService executor;
|
||||||
private Runnable runnable;
|
private Runnable runnable;
|
||||||
private long numStoreFiles;
|
private long numStoreFiles;
|
||||||
|
private long storeRefCount;
|
||||||
private long memstoreSize;
|
private long memstoreSize;
|
||||||
private long storeFileSize;
|
private long storeFileSize;
|
||||||
private long maxStoreFileAge;
|
private long maxStoreFileAge;
|
||||||
|
@ -119,6 +120,11 @@ public class MetricsRegionWrapperImpl implements MetricsRegionWrapper, Closeable
|
||||||
return storeFileSize;
|
return storeFileSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getStoreRefCount() {
|
||||||
|
return storeRefCount;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getReadRequestCount() {
|
public long getReadRequestCount() {
|
||||||
return this.region.getReadRequestsCount();
|
return this.region.getReadRequestsCount();
|
||||||
|
@ -221,6 +227,7 @@ public class MetricsRegionWrapperImpl implements MetricsRegionWrapper, Closeable
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
long tempNumStoreFiles = 0;
|
long tempNumStoreFiles = 0;
|
||||||
|
int tempStoreRefCount = 0;
|
||||||
long tempMemstoreSize = 0;
|
long tempMemstoreSize = 0;
|
||||||
long tempStoreFileSize = 0;
|
long tempStoreFileSize = 0;
|
||||||
long tempMaxStoreFileAge = 0;
|
long tempMaxStoreFileAge = 0;
|
||||||
|
@ -232,8 +239,9 @@ public class MetricsRegionWrapperImpl implements MetricsRegionWrapper, Closeable
|
||||||
long avgAgeNumerator = 0;
|
long avgAgeNumerator = 0;
|
||||||
long numHFiles = 0;
|
long numHFiles = 0;
|
||||||
if (region.stores != null) {
|
if (region.stores != null) {
|
||||||
for (Store store : region.stores.values()) {
|
for (HStore store : region.stores.values()) {
|
||||||
tempNumStoreFiles += store.getStorefilesCount();
|
tempNumStoreFiles += store.getStorefilesCount();
|
||||||
|
tempStoreRefCount += store.getStoreRefCount();
|
||||||
tempMemstoreSize += store.getMemStoreSize().getDataSize();
|
tempMemstoreSize += store.getMemStoreSize().getDataSize();
|
||||||
tempStoreFileSize += store.getStorefilesSize();
|
tempStoreFileSize += store.getStorefilesSize();
|
||||||
OptionalLong storeMaxStoreFileAge = store.getMaxStoreFileAge();
|
OptionalLong storeMaxStoreFileAge = store.getMaxStoreFileAge();
|
||||||
|
@ -260,6 +268,7 @@ public class MetricsRegionWrapperImpl implements MetricsRegionWrapper, Closeable
|
||||||
}
|
}
|
||||||
|
|
||||||
numStoreFiles = tempNumStoreFiles;
|
numStoreFiles = tempNumStoreFiles;
|
||||||
|
storeRefCount = tempStoreRefCount;
|
||||||
memstoreSize = tempMemstoreSize;
|
memstoreSize = tempMemstoreSize;
|
||||||
storeFileSize = tempStoreFileSize;
|
storeFileSize = tempStoreFileSize;
|
||||||
maxStoreFileAge = tempMaxStoreFileAge;
|
maxStoreFileAge = tempMaxStoreFileAge;
|
||||||
|
|
|
@ -60,6 +60,11 @@ public class MetricsRegionWrapperStub implements MetricsRegionWrapper {
|
||||||
return 102;
|
return 102;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getStoreRefCount() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getMemStoreSize() {
|
public long getMemStoreSize() {
|
||||||
return 103;
|
return 103;
|
||||||
|
|
Loading…
Reference in New Issue