Skip to content

Commit

Permalink
HBASE-24381 The Size metrics in Master Webui is wrong if the size is 0 (
Browse files Browse the repository at this point in the history
apache#1723)

(cherry picked from commit 414322e)

Change-Id: I52656019f3f56c774dee91c80672a1093c48b51a
  • Loading branch information
ZhaoBQ authored and infraio committed May 18, 2020
1 parent 3d869c5 commit 6ba8378
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

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);
}
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);
}
</%java>
<tr>
<td><& serverNameLink; serverName=serverName; &></td>
Expand All @@ -195,11 +195,11 @@ for (ServerName serverName: serverNames) {
<td><% memStoreSizeMBStr %></td>
</tr>
<%java>
} else {
} else {
</%java>
<& emptyStat; serverName=serverName; &>
<%java>
}
}
}
</%java>
</tbody>
Expand Down Expand Up @@ -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>
Expand All @@ -325,11 +325,11 @@ if (sl != null) {
<td><% totalStaticBloomSizeKBStr %></td>
</tr>
<%java>
} else {
</%java>
} else {
</%java>
<& emptyStat; serverName=serverName; &>
<%java>
}
}
}
</%java>
</tbody>
Expand Down
15 changes: 7 additions & 8 deletions hbase-server/src/main/resources/hbase-webapps/master/rsgroup.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 6ba8378

Please sign in to comment.