HBASE-24381 The Size metrics in Master Webui is wrong if the size is 0 (#1723)

This commit is contained in:
Baiqiang Zhao 2020-05-18 09:14:36 +08:00 committed by GitHub
parent 15627bb722
commit 61efb6d5ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 78 additions and 79 deletions

View File

@ -171,10 +171,10 @@ if (master.getServerManager() != null) {
</tr>
<%java>
final String ZEROMB = "0 MB";
String usedHeapStr = ZEROMB;
String maxHeapStr = ZEROMB;
String memstoreSizeStr = ZEROMB;
for (RSGroupInfo rsGroupInfo: rsGroupInfos) {
String usedHeapStr = ZEROMB;
String maxHeapStr = ZEROMB;
String memstoreSizeStr = ZEROMB;
String rsGroupName = rsGroupInfo.getName();
long usedHeap = 0;
long maxHeap = 0;
@ -275,11 +275,11 @@ if (master.getServerManager() != null) {
<%java>
final String ZEROKB = "0 KB";
final String ZEROMB = "0 MB";
String uncompressedStorefileSizeStr = ZEROMB;
String storefileSizeStr = ZEROMB;
String indexSizeStr = ZEROKB;
String bloomSizeStr = ZEROKB;
for (RSGroupInfo rsGroupInfo: rsGroupInfos) {
String uncompressedStorefileSizeStr = ZEROMB;
String storefileSizeStr = ZEROMB;
String indexSizeStr = ZEROKB;
String bloomSizeStr = ZEROKB;
String rsGroupName = rsGroupInfo.getName();
int numStores = 0;
long numStorefiles = 0;

View File

@ -162,31 +162,31 @@ Arrays.sort(serverNames);
<tbody>
<%java>
final String ZEROMB = "0 MB";
String usedHeapStr = ZEROMB;
String maxHeapStr = ZEROMB;
String memStoreSizeMBStr = ZEROMB;
for (ServerName serverName: serverNames) {
ServerMetrics sl = master.getServerManager().getLoad(serverName);
if (sl != null) {
long memStoreSizeMB = 0;
for (RegionMetrics rl : sl.getRegionMetrics().values()) {
memStoreSizeMB += rl.getMemStoreSize().get(Size.Unit.MEGABYTE);
}
if (memStoreSizeMB > 0) {
memStoreSizeMBStr = TraditionalBinaryPrefix.long2String(memStoreSizeMB
* TraditionalBinaryPrefix.MEGA.value, "B", 1);
}
String usedHeapStr = ZEROMB;
String maxHeapStr = ZEROMB;
String memStoreSizeMBStr = ZEROMB;
ServerMetrics sl = master.getServerManager().getLoad(serverName);
if (sl != null) {
long memStoreSizeMB = 0;
for (RegionMetrics rl : sl.getRegionMetrics().values()) {
memStoreSizeMB += rl.getMemStoreSize().get(Size.Unit.MEGABYTE);
}
if (memStoreSizeMB > 0) {
memStoreSizeMBStr = TraditionalBinaryPrefix.long2String(memStoreSizeMB
* TraditionalBinaryPrefix.MEGA.value, "B", 1);
}
double usedHeapSizeMB = sl.getUsedHeapSize().get(Size.Unit.MEGABYTE);
if (usedHeapSizeMB > 0) {
usedHeapStr = TraditionalBinaryPrefix.long2String((long) usedHeapSizeMB
* TraditionalBinaryPrefix.MEGA.value, "B", 1);
}
double maxHeapSizeMB = sl.getMaxHeapSize().get(Size.Unit.MEGABYTE);
if (maxHeapSizeMB > 0) {
maxHeapStr = TraditionalBinaryPrefix.long2String((long) maxHeapSizeMB
* TraditionalBinaryPrefix.MEGA.value, "B", 1);
}
double usedHeapSizeMB = sl.getUsedHeapSize().get(Size.Unit.MEGABYTE);
if (usedHeapSizeMB > 0) {
usedHeapStr = TraditionalBinaryPrefix.long2String((long) usedHeapSizeMB
* TraditionalBinaryPrefix.MEGA.value, "B", 1);
}
double maxHeapSizeMB = sl.getMaxHeapSize().get(Size.Unit.MEGABYTE);
if (maxHeapSizeMB > 0) {
maxHeapStr = TraditionalBinaryPrefix.long2String((long) maxHeapSizeMB
* TraditionalBinaryPrefix.MEGA.value, "B", 1);
}
</%java>
<tr>
<td><& serverNameLink; serverName=serverName; &></td>
@ -195,11 +195,11 @@ for (ServerName serverName: serverNames) {
<td><% memStoreSizeMBStr %></td>
</tr>
<%java>
} else {
} else {
</%java>
<& emptyStat; serverName=serverName; &>
<%java>
}
}
}
</%java>
</tbody>
@ -276,44 +276,44 @@ if (sl != null) {
<%java>
final String ZEROKB = "0 KB";
final String ZEROMB = "0 MB";
String storeUncompressedSizeMBStr = ZEROMB;
String storeFileSizeMBStr = ZEROMB;
String totalStaticIndexSizeKBStr = ZEROKB;
String totalStaticBloomSizeKBStr = ZEROKB;
for (ServerName serverName: serverNames) {
ServerMetrics sl = master.getServerManager().getLoad(serverName);
if (sl != null) {
long storeCount = 0;
long storeFileCount = 0;
long storeUncompressedSizeMB = 0;
long storeFileSizeMB = 0;
long totalStaticIndexSizeKB = 0;
long totalStaticBloomSizeKB = 0;
for (RegionMetrics rl : sl.getRegionMetrics().values()) {
storeCount += rl.getStoreCount();
storeFileCount += rl.getStoreFileCount();
storeUncompressedSizeMB += rl.getUncompressedStoreFileSize().get(Size.Unit.MEGABYTE);
storeFileSizeMB += rl.getStoreFileSize().get(Size.Unit.MEGABYTE);
totalStaticIndexSizeKB += rl.getStoreFileUncompressedDataIndexSize().get(Size.Unit.KILOBYTE);
totalStaticBloomSizeKB += rl.getBloomFilterSize().get(Size.Unit.KILOBYTE);
}
if (storeUncompressedSizeMB > 0) {
storeUncompressedSizeMBStr = TraditionalBinaryPrefix.
long2String(storeUncompressedSizeMB * TraditionalBinaryPrefix.MEGA.value, "B", 1);
}
if (storeFileSizeMB > 0) {
storeFileSizeMBStr = TraditionalBinaryPrefix.
long2String(storeFileSizeMB * TraditionalBinaryPrefix.MEGA.value, "B", 1);
}
if (totalStaticIndexSizeKB > 0) {
totalStaticIndexSizeKBStr = TraditionalBinaryPrefix.
long2String(totalStaticIndexSizeKB * TraditionalBinaryPrefix.KILO.value, "B", 1);
}
if (totalStaticBloomSizeKB > 0) {
totalStaticBloomSizeKBStr = TraditionalBinaryPrefix.
long2String(totalStaticBloomSizeKB * TraditionalBinaryPrefix.KILO.value, "B", 1);
}
String storeUncompressedSizeMBStr = ZEROMB;
String storeFileSizeMBStr = ZEROMB;
String totalStaticIndexSizeKBStr = ZEROKB;
String totalStaticBloomSizeKBStr = ZEROKB;
ServerMetrics sl = master.getServerManager().getLoad(serverName);
if (sl != null) {
long storeCount = 0;
long storeFileCount = 0;
long storeUncompressedSizeMB = 0;
long storeFileSizeMB = 0;
long totalStaticIndexSizeKB = 0;
long totalStaticBloomSizeKB = 0;
for (RegionMetrics rl : sl.getRegionMetrics().values()) {
storeCount += rl.getStoreCount();
storeFileCount += rl.getStoreFileCount();
storeUncompressedSizeMB += rl.getUncompressedStoreFileSize().get(Size.Unit.MEGABYTE);
storeFileSizeMB += rl.getStoreFileSize().get(Size.Unit.MEGABYTE);
totalStaticIndexSizeKB += rl.getStoreFileUncompressedDataIndexSize().get(Size.Unit.KILOBYTE);
totalStaticBloomSizeKB += rl.getBloomFilterSize().get(Size.Unit.KILOBYTE);
}
if (storeUncompressedSizeMB > 0) {
storeUncompressedSizeMBStr = TraditionalBinaryPrefix.
long2String(storeUncompressedSizeMB * TraditionalBinaryPrefix.MEGA.value, "B", 1);
}
if (storeFileSizeMB > 0) {
storeFileSizeMBStr = TraditionalBinaryPrefix.
long2String(storeFileSizeMB * TraditionalBinaryPrefix.MEGA.value, "B", 1);
}
if (totalStaticIndexSizeKB > 0) {
totalStaticIndexSizeKBStr = TraditionalBinaryPrefix.
long2String(totalStaticIndexSizeKB * TraditionalBinaryPrefix.KILO.value, "B", 1);
}
if (totalStaticBloomSizeKB > 0) {
totalStaticBloomSizeKBStr = TraditionalBinaryPrefix.
long2String(totalStaticBloomSizeKB * TraditionalBinaryPrefix.KILO.value, "B", 1);
}
</%java>
<tr>
<td><& serverNameLink; serverName=serverName; &></td>
@ -325,11 +325,11 @@ if (sl != null) {
<td><% totalStaticBloomSizeKBStr %></td>
</tr>
<%java>
} else {
</%java>
} else {
</%java>
<& emptyStat; serverName=serverName; &>
<%java>
}
}
}
</%java>
</tbody>

View File

@ -213,11 +213,10 @@
<th>Memstore Size</th>
</tr>
<%
String usedHeapSizeMBStr = ZEROMB;
String maxHeapSizeMBStr = ZEROMB;
String memStoreSizeMBStr = ZEROMB;
for (Address server: rsGroupServers) {
String usedHeapSizeMBStr = ZEROMB;
String maxHeapSizeMBStr = ZEROMB;
String memStoreSizeMBStr = ZEROMB;
ServerName serverName = serverMaping.get(server);
ServerMetrics sl = onlineServers.get(server);
if (sl != null && serverName != null) {
@ -309,11 +308,11 @@
<th>Bloom Size</th>
</tr>
<%
String storeUncompressedSizeMBStr = ZEROMB;
String storeFileSizeMBStr = ZEROMB;
String totalStaticIndexSizeKBStr = ZEROKB;
String totalStaticBloomSizeKBStr = ZEROKB;
for (Address server: rsGroupServers) {
String storeUncompressedSizeMBStr = ZEROMB;
String storeFileSizeMBStr = ZEROMB;
String totalStaticIndexSizeKBStr = ZEROKB;
String totalStaticBloomSizeKBStr = ZEROKB;
ServerName serverName = serverMaping.get(server);
ServerMetrics sl = onlineServers.get(server);
if (sl != null && serverName != null) {