HBASE-24586 Add table level locality in table.jsp
Closes #1926 Signed-off-by: Viraj Jasani <vjasani@apache.org>
This commit is contained in:
parent
6c9534c804
commit
b2321b3583
|
@ -166,4 +166,20 @@ public interface RegionMetrics {
|
||||||
* @return the data locality for ssd of region in the regionserver
|
* @return the data locality for ssd of region in the regionserver
|
||||||
*/
|
*/
|
||||||
float getDataLocalityForSsd();
|
float getDataLocalityForSsd();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the data at local weight of this region in the regionserver
|
||||||
|
*/
|
||||||
|
long getBlocksLocalWeight();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Different from blocksLocalWeight,this metric's numerator only include the data stored on ssd
|
||||||
|
* @return the data at local with ssd weight of this region in the regionserver
|
||||||
|
*/
|
||||||
|
long getBlocksLocalWithSsdWeight();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the block total weight of this region
|
||||||
|
*/
|
||||||
|
long getBlocksTotalWeight();
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,11 @@ public final class RegionMetricsBuilder {
|
||||||
.setDataLocality(regionLoadPB.hasDataLocality() ? regionLoadPB.getDataLocality() : 0.0f)
|
.setDataLocality(regionLoadPB.hasDataLocality() ? regionLoadPB.getDataLocality() : 0.0f)
|
||||||
.setDataLocalityForSsd(regionLoadPB.hasDataLocalityForSsd() ?
|
.setDataLocalityForSsd(regionLoadPB.hasDataLocalityForSsd() ?
|
||||||
regionLoadPB.getDataLocalityForSsd() : 0.0f)
|
regionLoadPB.getDataLocalityForSsd() : 0.0f)
|
||||||
|
.setBlocksLocalWeight(regionLoadPB.hasBlocksLocalWeight() ?
|
||||||
|
regionLoadPB.getBlocksLocalWeight() : 0)
|
||||||
|
.setBlocksLocalWithSsdWeight(regionLoadPB.hasBlocksLocalWithSsdWeight() ?
|
||||||
|
regionLoadPB.getBlocksLocalWithSsdWeight() : 0)
|
||||||
|
.setBlocksTotalWeight(regionLoadPB.getBlocksTotalWeight())
|
||||||
.setFilteredReadRequestCount(regionLoadPB.getFilteredReadRequestsCount())
|
.setFilteredReadRequestCount(regionLoadPB.getFilteredReadRequestsCount())
|
||||||
.setStoreFileUncompressedDataIndexSize(new Size(regionLoadPB.getTotalStaticIndexSizeKB(),
|
.setStoreFileUncompressedDataIndexSize(new Size(regionLoadPB.getTotalStaticIndexSizeKB(),
|
||||||
Size.Unit.KILOBYTE))
|
Size.Unit.KILOBYTE))
|
||||||
|
@ -151,6 +156,9 @@ public final class RegionMetricsBuilder {
|
||||||
private float dataLocality;
|
private float dataLocality;
|
||||||
private long lastMajorCompactionTimestamp;
|
private long lastMajorCompactionTimestamp;
|
||||||
private float dataLocalityForSsd;
|
private float dataLocalityForSsd;
|
||||||
|
private long blocksLocalWeight;
|
||||||
|
private long blocksLocalWithSsdWeight;
|
||||||
|
private long blocksTotalWeight;
|
||||||
private RegionMetricsBuilder(byte[] name) {
|
private RegionMetricsBuilder(byte[] name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
@ -243,7 +251,18 @@ public final class RegionMetricsBuilder {
|
||||||
this.dataLocalityForSsd = value;
|
this.dataLocalityForSsd = value;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
public RegionMetricsBuilder setBlocksLocalWeight(long value) {
|
||||||
|
this.blocksLocalWeight = value;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public RegionMetricsBuilder setBlocksLocalWithSsdWeight(long value) {
|
||||||
|
this.blocksLocalWithSsdWeight = value;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public RegionMetricsBuilder setBlocksTotalWeight(long value) {
|
||||||
|
this.blocksTotalWeight = value;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
public RegionMetrics build() {
|
public RegionMetrics build() {
|
||||||
return new RegionMetricsImpl(name,
|
return new RegionMetricsImpl(name,
|
||||||
storeCount,
|
storeCount,
|
||||||
|
@ -267,7 +286,10 @@ public final class RegionMetricsBuilder {
|
||||||
storeSequenceIds,
|
storeSequenceIds,
|
||||||
dataLocality,
|
dataLocality,
|
||||||
lastMajorCompactionTimestamp,
|
lastMajorCompactionTimestamp,
|
||||||
dataLocalityForSsd);
|
dataLocalityForSsd,
|
||||||
|
blocksLocalWeight,
|
||||||
|
blocksLocalWithSsdWeight,
|
||||||
|
blocksTotalWeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class RegionMetricsImpl implements RegionMetrics {
|
private static class RegionMetricsImpl implements RegionMetrics {
|
||||||
|
@ -294,6 +316,9 @@ public final class RegionMetricsBuilder {
|
||||||
private final float dataLocality;
|
private final float dataLocality;
|
||||||
private final long lastMajorCompactionTimestamp;
|
private final long lastMajorCompactionTimestamp;
|
||||||
private final float dataLocalityForSsd;
|
private final float dataLocalityForSsd;
|
||||||
|
private final long blocksLocalWeight;
|
||||||
|
private final long blocksLocalWithSsdWeight;
|
||||||
|
private final long blocksTotalWeight;
|
||||||
RegionMetricsImpl(byte[] name,
|
RegionMetricsImpl(byte[] name,
|
||||||
int storeCount,
|
int storeCount,
|
||||||
int storeFileCount,
|
int storeFileCount,
|
||||||
|
@ -316,7 +341,10 @@ public final class RegionMetricsBuilder {
|
||||||
Map<byte[], Long> storeSequenceIds,
|
Map<byte[], Long> storeSequenceIds,
|
||||||
float dataLocality,
|
float dataLocality,
|
||||||
long lastMajorCompactionTimestamp,
|
long lastMajorCompactionTimestamp,
|
||||||
float dataLocalityForSsd) {
|
float dataLocalityForSsd,
|
||||||
|
long blocksLocalWeight,
|
||||||
|
long blocksLocalWithSsdWeight,
|
||||||
|
long blocksTotalWeight) {
|
||||||
this.name = Preconditions.checkNotNull(name);
|
this.name = Preconditions.checkNotNull(name);
|
||||||
this.storeCount = storeCount;
|
this.storeCount = storeCount;
|
||||||
this.storeFileCount = storeFileCount;
|
this.storeFileCount = storeFileCount;
|
||||||
|
@ -340,6 +368,9 @@ public final class RegionMetricsBuilder {
|
||||||
this.dataLocality = dataLocality;
|
this.dataLocality = dataLocality;
|
||||||
this.lastMajorCompactionTimestamp = lastMajorCompactionTimestamp;
|
this.lastMajorCompactionTimestamp = lastMajorCompactionTimestamp;
|
||||||
this.dataLocalityForSsd = dataLocalityForSsd;
|
this.dataLocalityForSsd = dataLocalityForSsd;
|
||||||
|
this.blocksLocalWeight = blocksLocalWeight;
|
||||||
|
this.blocksLocalWithSsdWeight = blocksLocalWithSsdWeight;
|
||||||
|
this.blocksTotalWeight = blocksTotalWeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -457,6 +488,21 @@ public final class RegionMetricsBuilder {
|
||||||
return dataLocalityForSsd;
|
return dataLocalityForSsd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getBlocksLocalWeight() {
|
||||||
|
return blocksLocalWeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getBlocksLocalWithSsdWeight() {
|
||||||
|
return blocksLocalWithSsdWeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getBlocksTotalWeight() {
|
||||||
|
return blocksTotalWeight;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder sb = Strings.appendKeyValue(new StringBuilder(), "storeCount",
|
StringBuilder sb = Strings.appendKeyValue(new StringBuilder(), "storeCount",
|
||||||
|
@ -510,6 +556,12 @@ public final class RegionMetricsBuilder {
|
||||||
this.getDataLocality());
|
this.getDataLocality());
|
||||||
Strings.appendKeyValue(sb, "dataLocalityForSsd",
|
Strings.appendKeyValue(sb, "dataLocalityForSsd",
|
||||||
this.getDataLocalityForSsd());
|
this.getDataLocalityForSsd());
|
||||||
|
Strings.appendKeyValue(sb, "blocksLocalWeight",
|
||||||
|
blocksLocalWeight);
|
||||||
|
Strings.appendKeyValue(sb, "blocksLocalWithSsdWeight",
|
||||||
|
blocksLocalWithSsdWeight);
|
||||||
|
Strings.appendKeyValue(sb, "blocksTotalWeight",
|
||||||
|
blocksTotalWeight);
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,6 +158,15 @@ message RegionLoad {
|
||||||
|
|
||||||
/** The current data locality for ssd for region in the regionserver */
|
/** The current data locality for ssd for region in the regionserver */
|
||||||
optional float data_locality_for_ssd = 23;
|
optional float data_locality_for_ssd = 23;
|
||||||
|
|
||||||
|
/** The current blocks local weight for region in the regionserver */
|
||||||
|
optional uint64 blocks_local_weight = 24;
|
||||||
|
|
||||||
|
/** The current blocks local weight with ssd for region in the regionserver */
|
||||||
|
optional uint64 blocks_local_with_ssd_weight = 25;
|
||||||
|
|
||||||
|
/** The current blocks total weight for region in the regionserver */
|
||||||
|
optional uint64 blocks_total_weight = 26;
|
||||||
}
|
}
|
||||||
|
|
||||||
message UserLoad {
|
message UserLoad {
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class HDFSBlocksDistribution {
|
||||||
*/
|
*/
|
||||||
public static class HostAndWeight {
|
public static class HostAndWeight {
|
||||||
|
|
||||||
private String host;
|
private final String host;
|
||||||
private long weight;
|
private long weight;
|
||||||
private long weightForSsd;
|
private long weightForSsd;
|
||||||
|
|
||||||
|
@ -228,7 +228,7 @@ public class HDFSBlocksDistribution {
|
||||||
* Implementations 'visit' hostAndWeight.
|
* Implementations 'visit' hostAndWeight.
|
||||||
*/
|
*/
|
||||||
public interface Visitor {
|
public interface Visitor {
|
||||||
float visit(final HostAndWeight hostAndWeight);
|
long visit(final HostAndWeight hostAndWeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -236,8 +236,12 @@ public class HDFSBlocksDistribution {
|
||||||
* @return the locality index of the given host
|
* @return the locality index of the given host
|
||||||
*/
|
*/
|
||||||
public float getBlockLocalityIndex(String host) {
|
public float getBlockLocalityIndex(String host) {
|
||||||
return getBlockLocalityIndexInternal(host,
|
if (uniqueBlocksTotalWeight == 0) {
|
||||||
e -> (float) e.weight / (float) uniqueBlocksTotalWeight);
|
return 0.0f;
|
||||||
|
} else {
|
||||||
|
return (float) getBlocksLocalityWeightInternal(host, HostAndWeight::getWeight)
|
||||||
|
/ (float) uniqueBlocksTotalWeight;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -245,16 +249,36 @@ public class HDFSBlocksDistribution {
|
||||||
* @return the locality index with ssd of the given host
|
* @return the locality index with ssd of the given host
|
||||||
*/
|
*/
|
||||||
public float getBlockLocalityIndexForSsd(String host) {
|
public float getBlockLocalityIndexForSsd(String host) {
|
||||||
return getBlockLocalityIndexInternal(host,
|
if (uniqueBlocksTotalWeight == 0) {
|
||||||
e -> (float) e.weightForSsd / (float) uniqueBlocksTotalWeight);
|
return 0.0f;
|
||||||
|
} else {
|
||||||
|
return (float) getBlocksLocalityWeightInternal(host, HostAndWeight::getWeightForSsd)
|
||||||
|
/ (float) uniqueBlocksTotalWeight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param host the host name
|
||||||
|
* @return the blocks local weight of the given host
|
||||||
|
*/
|
||||||
|
public long getBlocksLocalWeight(String host) {
|
||||||
|
return getBlocksLocalityWeightInternal(host, HostAndWeight::getWeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param host the host name
|
||||||
|
* @return the blocks local with ssd weight of the given host
|
||||||
|
*/
|
||||||
|
public long getBlocksLocalWithSsdWeight(String host) {
|
||||||
|
return getBlocksLocalityWeightInternal(host, HostAndWeight::getWeightForSsd);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param host the host name
|
* @param host the host name
|
||||||
* @return the locality index of the given host
|
* @return the locality index of the given host
|
||||||
*/
|
*/
|
||||||
private float getBlockLocalityIndexInternal(String host, Visitor visitor) {
|
private long getBlocksLocalityWeightInternal(String host, Visitor visitor) {
|
||||||
float localityIndex = 0;
|
long localityIndex = 0;
|
||||||
HostAndWeight hostAndWeight = this.hostAndWeights.get(host);
|
HostAndWeight hostAndWeight = this.hostAndWeights.get(host);
|
||||||
if (hostAndWeight != null && uniqueBlocksTotalWeight != 0) {
|
if (hostAndWeight != null && uniqueBlocksTotalWeight != 0) {
|
||||||
localityIndex = visitor.visit(hostAndWeight);
|
localityIndex = visitor.visit(hostAndWeight);
|
||||||
|
|
|
@ -1696,6 +1696,9 @@ public class HRegionServer extends Thread implements
|
||||||
HDFSBlocksDistribution hdfsBd = r.getHDFSBlocksDistribution();
|
HDFSBlocksDistribution hdfsBd = r.getHDFSBlocksDistribution();
|
||||||
float dataLocality = hdfsBd.getBlockLocalityIndex(serverName.getHostname());
|
float dataLocality = hdfsBd.getBlockLocalityIndex(serverName.getHostname());
|
||||||
float dataLocalityForSsd = hdfsBd.getBlockLocalityIndexForSsd(serverName.getHostname());
|
float dataLocalityForSsd = hdfsBd.getBlockLocalityIndexForSsd(serverName.getHostname());
|
||||||
|
long blocksTotalWeight = hdfsBd.getUniqueBlocksTotalWeight();
|
||||||
|
long blocksLocalWeight = hdfsBd.getBlocksLocalWeight(serverName.getHostname());
|
||||||
|
long blocksLocalWithSsdWeight = hdfsBd.getBlocksLocalWithSsdWeight(serverName.getHostname());
|
||||||
if (regionLoadBldr == null) {
|
if (regionLoadBldr == null) {
|
||||||
regionLoadBldr = RegionLoad.newBuilder();
|
regionLoadBldr = RegionLoad.newBuilder();
|
||||||
}
|
}
|
||||||
|
@ -1724,6 +1727,9 @@ public class HRegionServer extends Thread implements
|
||||||
.setCurrentCompactedKVs(currentCompactedKVs)
|
.setCurrentCompactedKVs(currentCompactedKVs)
|
||||||
.setDataLocality(dataLocality)
|
.setDataLocality(dataLocality)
|
||||||
.setDataLocalityForSsd(dataLocalityForSsd)
|
.setDataLocalityForSsd(dataLocalityForSsd)
|
||||||
|
.setBlocksLocalWeight(blocksLocalWeight)
|
||||||
|
.setBlocksLocalWithSsdWeight(blocksLocalWithSsdWeight)
|
||||||
|
.setBlocksTotalWeight(blocksTotalWeight)
|
||||||
.setLastMajorCompactionTs(r.getOldestHfileTs(true));
|
.setLastMajorCompactionTs(r.getOldestHfileTs(true));
|
||||||
r.setCompleteSequenceId(regionLoadBldr);
|
r.setCompleteSequenceId(regionLoadBldr);
|
||||||
|
|
||||||
|
|
|
@ -808,9 +808,14 @@
|
||||||
long totalMemSize = 0;
|
long totalMemSize = 0;
|
||||||
long totalCompactingCells = 0;
|
long totalCompactingCells = 0;
|
||||||
long totalCompactedCells = 0;
|
long totalCompactedCells = 0;
|
||||||
|
long totalBlocksTotalWeight = 0;
|
||||||
|
long totalBlocksLocalWeight = 0;
|
||||||
|
long totalBlocksLocalWithSsdWeight = 0;
|
||||||
String totalCompactionProgress = "";
|
String totalCompactionProgress = "";
|
||||||
String totalMemSizeStr = ZEROMB;
|
String totalMemSizeStr = ZEROMB;
|
||||||
String totalSizeStr = ZEROMB;
|
String totalSizeStr = ZEROMB;
|
||||||
|
String totalLocality = "";
|
||||||
|
String totalLocalityForSsd = "";
|
||||||
Map<ServerName, Integer> regDistribution = new TreeMap<>();
|
Map<ServerName, Integer> regDistribution = new TreeMap<>();
|
||||||
Map<ServerName, Integer> primaryRegDistribution = new TreeMap<>();
|
Map<ServerName, Integer> primaryRegDistribution = new TreeMap<>();
|
||||||
List<HRegionLocation> regions = r.getAllRegionLocations();
|
List<HRegionLocation> regions = r.getAllRegionLocations();
|
||||||
|
@ -835,6 +840,9 @@
|
||||||
totalStoreFileSizeMB += regionMetrics.getStoreFileSize().get(Size.Unit.MEGABYTE);
|
totalStoreFileSizeMB += regionMetrics.getStoreFileSize().get(Size.Unit.MEGABYTE);
|
||||||
totalCompactingCells += regionMetrics.getCompactingCellCount();
|
totalCompactingCells += regionMetrics.getCompactingCellCount();
|
||||||
totalCompactedCells += regionMetrics.getCompactedCellCount();
|
totalCompactedCells += regionMetrics.getCompactedCellCount();
|
||||||
|
totalBlocksTotalWeight += regionMetrics.getBlocksTotalWeight();
|
||||||
|
totalBlocksLocalWeight += regionMetrics.getBlocksLocalWeight();
|
||||||
|
totalBlocksLocalWithSsdWeight += regionMetrics.getBlocksLocalWithSsdWeight();
|
||||||
} else {
|
} else {
|
||||||
RegionMetrics load0 = getEmptyRegionMetrics(regionInfo);
|
RegionMetrics load0 = getEmptyRegionMetrics(regionInfo);
|
||||||
regionsToLoad.put(regionInfo, load0);
|
regionsToLoad.put(regionInfo, load0);
|
||||||
|
@ -858,7 +866,12 @@
|
||||||
totalCompactionProgress = String.format("%.2f", 100 *
|
totalCompactionProgress = String.format("%.2f", 100 *
|
||||||
((float) totalCompactedCells / totalCompactingCells)) + "%";
|
((float) totalCompactedCells / totalCompactingCells)) + "%";
|
||||||
}
|
}
|
||||||
|
if (totalBlocksTotalWeight > 0) {
|
||||||
|
totalLocality = String.format("%.1f",
|
||||||
|
((float) totalBlocksLocalWeight / totalBlocksTotalWeight));
|
||||||
|
totalLocalityForSsd = String.format("%.1f",
|
||||||
|
((float) totalBlocksLocalWithSsdWeight / totalBlocksTotalWeight));
|
||||||
|
}
|
||||||
if(regions != null && regions.size() > 0) { %>
|
if(regions != null && regions.size() > 0) { %>
|
||||||
<h2>Table Regions</h2>
|
<h2>Table Regions</h2>
|
||||||
<div class="tabbable">
|
<div class="tabbable">
|
||||||
|
@ -963,8 +976,8 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th>Name(<%= String.format("%,1d", regions.size())%>)</th>
|
<th>Name(<%= String.format("%,1d", regions.size())%>)</th>
|
||||||
<th>Region Server</th>
|
<th>Region Server</th>
|
||||||
<th>Locality</th>
|
<th>Locality<br>(<%= totalLocality %>)</th>
|
||||||
<th>LocalityForSsd</th>
|
<th>LocalityForSsd<br>(<%= totalLocalityForSsd %>)</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|
|
@ -497,6 +497,21 @@ public class TestRegionsRecoveryChore {
|
||||||
public float getDataLocalityForSsd() {
|
public float getDataLocalityForSsd() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getBlocksLocalWeight() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getBlocksLocalWithSsdWeight() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getBlocksTotalWeight() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
return regionMetrics;
|
return regionMetrics;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue