hbase-webapps.master.rsgroup.jsp Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hbase-server Show documentation
Show all versions of hbase-server Show documentation
Server functionality for HBase
<%--
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
--%>
<%@ page contentType="text/html;charset=UTF-8"
import="java.util.ArrayList"
import="java.util.Collections"
import="java.util.Date"
import="java.util.List"
import="java.util.Map"
import="java.util.regex.Pattern"
import="java.util.stream.Stream"
import="java.util.stream.Collectors"
import="org.apache.hadoop.hbase.HTableDescriptor"
import="org.apache.hadoop.hbase.RSGroupTableAccessor"
import="org.apache.hadoop.hbase.ServerName"
import="org.apache.hadoop.hbase.TableName"
import="org.apache.hadoop.hbase.client.Admin"
import="org.apache.hadoop.hbase.client.RegionInfo"
import="org.apache.hadoop.hbase.client.TableState"
import="org.apache.hadoop.hbase.client.TableDescriptor"
import="org.apache.hadoop.hbase.master.HMaster"
import="org.apache.hadoop.hbase.master.RegionState"
import="org.apache.hadoop.hbase.net.Address"
import="org.apache.hadoop.hbase.rsgroup.RSGroupInfo"
import="org.apache.hadoop.hbase.util.Bytes"
import="org.apache.hadoop.hbase.util.VersionInfo"
import="org.apache.hadoop.util.StringUtils.TraditionalBinaryPrefix"%>
<%@ page import="org.apache.hadoop.hbase.ServerMetrics" %>
<%@ page import="org.apache.hadoop.hbase.Size" %>
<%@ page import="org.apache.hadoop.hbase.RegionMetrics" %>
<%
String rsGroupName = request.getParameter("name");
pageContext.setAttribute("pageTitle", "RSGroup: " + rsGroupName);
%>
<%
HMaster master = (HMaster)getServletContext().getAttribute(HMaster.MASTER);
RSGroupInfo rsGroupInfo = null;
final String ZEROKB = "0 KB";
final String ZEROMB = "0 MB";
if (!RSGroupTableAccessor.isRSGroupsEnabled(master.getConnection())) {
%>
RSGroups are not enabled
<%
} else if (rsGroupName == null || rsGroupName.isEmpty() ||
(rsGroupInfo = RSGroupTableAccessor.getRSGroupInfo(
master.getConnection(), Bytes.toBytes(rsGroupName))) == null) {
%>
RSGroup: <%= rsGroupName %> does not exist
<%
} else {
List rsGroupServers = new ArrayList<>();
List rsGroupTables = new ArrayList<>();
rsGroupServers.addAll(rsGroupInfo.getServers());
rsGroupTables.addAll(rsGroupInfo.getTables());
Collections.sort(rsGroupServers);
rsGroupTables.sort((o1, o2) -> {
int compare = Bytes.compareTo(o1.getNamespace(), o2.getNamespace());
if (compare != 0)
return compare;
compare = Bytes.compareTo(o1.getQualifier(), o2.getQualifier());
if (compare != 0)
return compare;
return 0;
});
Map onlineServers = Collections.emptyMap();
Map serverMaping = Collections.emptyMap();
if (master.getServerManager() != null) {
onlineServers = master.getServerManager().getOnlineServers().entrySet().stream()
.collect(Collectors.toMap(p -> p.getKey().getAddress(), Map.Entry::getValue));
serverMaping =
master.getServerManager().getOnlineServers().entrySet().stream()
.collect(Collectors.toMap(p -> p.getKey().getAddress(), Map.Entry::getKey));
}
%>
RSGroup: <%= rsGroupName %>
Region Servers
<% if (rsGroupServers != null && rsGroupServers.size() > 0) { %>
ServerName
Start time
Last contact
Version
Requests Per Second
Num. Regions
<% int totalRegions = 0;
int totalRequestsPerSecond = 0;
int inconsistentNodeNum = 0;
String masterVersion = VersionInfo.getVersion();
for (Address server: rsGroupServers) {
ServerName serverName = serverMaping.get(server);
if (serverName != null) {
ServerMetrics sl = onlineServers.get(server);
String version = master.getRegionServerVersion(serverName);
if (!masterVersion.equals(version)) {
inconsistentNodeNum ++;
}
double requestsPerSecond = 0.0;
int numRegionsOnline = 0;
long lastContact = 0;
if (sl != null) {
requestsPerSecond = sl.getRequestCountPerSecond();
numRegionsOnline = sl.getRegionMetrics().size();
totalRegions += sl.getRegionMetrics().size();
totalRequestsPerSecond += sl.getRequestCountPerSecond();
lastContact = (System.currentTimeMillis() - sl.getReportTimestamp())/1000;
}
long startcode = serverName.getStartcode();
int infoPort = master.getRegionServerInfoPort(serverName);
String url = "//" + serverName.getHostname() + ":" + infoPort + "/rs-status";%>
<%= serverName.getServerName() %>
<%= new Date(startcode) %>
<%= lastContact %>
<%= version %>
<%= String.format("%.0f", requestsPerSecond) %>
<%= numRegionsOnline %>
<% } else { %>
<%= server %>
<%= "Dead" %>
<% } %>
<% } %>
Total:<%= rsGroupServers.size() %>
<%if (inconsistentNodeNum > 0) { %>
<%= inconsistentNodeNum %> nodes with inconsistent version
<%} else { %>
<%} %>
<%= totalRequestsPerSecond %>
<%= totalRegions %>
ServerName
Used Heap
Max Heap
Memstore Size
<%
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) {
double usedHeapSizeMB = sl.getUsedHeapSize().get(Size.Unit.MEGABYTE);
double maxHeapSizeMB = sl.getMaxHeapSize().get(Size.Unit.MEGABYTE);
double memStoreSizeMB = sl.getRegionMetrics().values()
.stream().mapToDouble(rm -> rm.getMemStoreSize().get(Size.Unit.MEGABYTE))
.sum();
int infoPort = master.getRegionServerInfoPort(serverName);
String url = "//" + serverName.getHostname() + ":" + infoPort + "/rs-status";
if (memStoreSizeMB > 0) {
memStoreSizeMBStr = TraditionalBinaryPrefix.long2String(
(long) memStoreSizeMB * TraditionalBinaryPrefix.MEGA.value, "B", 1);
}
if (usedHeapSizeMB > 0) {
usedHeapSizeMBStr = TraditionalBinaryPrefix.long2String(
(long) usedHeapSizeMB * TraditionalBinaryPrefix.MEGA.value, "B", 1);
}
if (maxHeapSizeMB > 0) {
maxHeapSizeMBStr = TraditionalBinaryPrefix.long2String(
(long) maxHeapSizeMB * TraditionalBinaryPrefix.MEGA.value, "B", 1);
}
%>
<%= serverName.getServerName() %>
<%= usedHeapSizeMBStr %>
<%= maxHeapSizeMBStr %>
<%= memStoreSizeMBStr %>
<% } else { %>
<%= server %>
<% }
} %>
ServerName
Request Per Second
Read Request Count
Write Request Count
<% for (Address server: rsGroupServers) {
ServerName serverName = serverMaping.get(server);
ServerMetrics sl = onlineServers.get(server);
if (sl != null && serverName != null) {
int infoPort = master.getRegionServerInfoPort(serverName);
long readRequestCount = 0;
long writeRequestCount = 0;
for (RegionMetrics rm : sl.getRegionMetrics().values()) {
readRequestCount += rm.getReadRequestCount();
writeRequestCount += rm.getWriteRequestCount();
}
String url = "//" + serverName.getHostname() + ":" + infoPort + "/rs-status";
%>
<%= serverName.getServerName() %>
<%= sl.getRequestCountPerSecond() %>
<%= readRequestCount %>
<%= writeRequestCount %>
<% } else { %>
<%= server %>
<% }
} %>
ServerName
Num. Stores
Num. Storefiles
Storefile Size Uncompressed
Storefile Size
Index Size
Bloom Size
<%
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) {
long storeCount = 0;
long storeFileCount = 0;
double storeUncompressedSizeMB = 0;
double storeFileSizeMB = 0;
double totalStaticIndexSizeKB = 0;
double totalStaticBloomSizeKB = 0;
for (RegionMetrics rm : sl.getRegionMetrics().values()) {
storeCount += rm.getStoreCount();
storeFileCount += rm.getStoreFileCount();
storeUncompressedSizeMB += rm.getUncompressedStoreFileSize().get(Size.Unit.MEGABYTE);
storeFileSizeMB += rm.getStoreFileSize().get(Size.Unit.MEGABYTE);
totalStaticIndexSizeKB += rm.getStoreFileUncompressedDataIndexSize().get(Size.Unit.KILOBYTE);
totalStaticBloomSizeKB += rm.getBloomFilterSize().get(Size.Unit.KILOBYTE);
}
int infoPort = master.getRegionServerInfoPort(serverName);
String url = "//" + serverName.getHostname() + ":" + infoPort + "/rs-status";
if (storeUncompressedSizeMB > 0) {
storeUncompressedSizeMBStr = TraditionalBinaryPrefix.long2String(
(long) storeUncompressedSizeMB * TraditionalBinaryPrefix.MEGA.value, "B", 1);
}
if (storeFileSizeMB > 0) {
storeFileSizeMBStr = TraditionalBinaryPrefix.long2String(
(long) storeFileSizeMB * TraditionalBinaryPrefix.MEGA.value, "B", 1);
}
if (totalStaticIndexSizeKB > 0) {
totalStaticIndexSizeKBStr = TraditionalBinaryPrefix.long2String(
(long) totalStaticIndexSizeKB * TraditionalBinaryPrefix.KILO.value, "B", 1);
}
if (totalStaticBloomSizeKB > 0) {
totalStaticBloomSizeKBStr = TraditionalBinaryPrefix.long2String(
(long) totalStaticBloomSizeKB * TraditionalBinaryPrefix.KILO.value, "B", 1);
}
%>
<%= serverName.getServerName() %>
<%= storeCount %>
<%= storeFileCount %>
<%= storeUncompressedSizeMBStr %>
<%= storeFileSizeMBStr %>
<%= totalStaticIndexSizeKBStr %>
<%= totalStaticBloomSizeKBStr %>
<% } else { %>
<%= server %>
<% }
} %>
ServerName
Num. Compacting KVs
Num. Compacted KVs
Remaining KVs
Compaction Progress
<% for (Address server: rsGroupServers) {
ServerName serverName = serverMaping.get(server);
ServerMetrics sl = onlineServers.get(server);
if (sl != null && serverName != null) {
long totalCompactingCells = 0;
long currentCompactedCells = 0;
for (RegionMetrics rm : sl.getRegionMetrics().values()) {
totalCompactingCells += rm.getCompactingCellCount();
currentCompactedCells += rm.getCompactedCellCount();
}
String percentDone = "";
if (totalCompactingCells > 0) {
percentDone = String.format("%.2f", 100 *
((float) currentCompactedCells / totalCompactingCells)) + "%";
}
int infoPort = master.getRegionServerInfoPort(serverName);
String url = "//" + serverName.getHostname() + ":" + infoPort + "/rs-status";
%>
<%= serverName.getServerName() %>
<%= totalCompactingCells %>
<%= currentCompactedCells %>
<%= totalCompactingCells - currentCompactedCells %>
<%= percentDone %>
<% } else { %>
<%= server %>
<% }
} %>
<% } else { %>
No Region Servers
<% } %>
Tables
<% if (rsGroupTables != null && rsGroupTables.size() > 0) {
HTableDescriptor[] tables = null;
try (Admin admin = master.getConnection().getAdmin()) {
tables = master.isInitialized() ? admin.listTables((Pattern)null, true) : null;
}
Map tableDescriptors
= Stream.of(tables).collect(Collectors.toMap(TableDescriptor::getTableName, p -> p));
%>
Namespace
Table
Stats
Online Regions
Offline Regions
Failed Regions
Split Regions
Other Regions
Description
<% for(TableName tableName : rsGroupTables) {
HTableDescriptor htDesc = tableDescriptors.get(tableName);
if(htDesc == null) {
%>
<%= tableName.getNamespaceAsString() %>
<%= tableName.getQualifierAsString() %>
<%= "DELETED" %>
<% } else { %>
<%= tableName.getNamespaceAsString() %>
<%= tableName.getQualifierAsString() %>
<% TableState tableState = master.getTableStateManager().getTableState(tableName);
if(tableState.isDisabledOrDisabling()) {
%>
<%= tableState.getState().name() %>
<% } else { %>
<%= tableState.getState().name() %>
<% } %>
<% Map> tableRegions =
master.getAssignmentManager().getRegionStates().getRegionByStateOfTable(tableName);
int openRegionsCount = tableRegions.get(RegionState.State.OPEN).size();
int offlineRegionsCount = tableRegions.get(RegionState.State.OFFLINE).size();
int splitRegionsCount = tableRegions.get(RegionState.State.SPLIT).size();
int failedRegionsCount = tableRegions.get(RegionState.State.FAILED_OPEN).size()
+ tableRegions.get(RegionState.State.FAILED_CLOSE).size();
int otherRegionsCount = 0;
for (List list: tableRegions.values()) {
otherRegionsCount += list.size();
}
// now subtract known states
otherRegionsCount = otherRegionsCount - openRegionsCount
- failedRegionsCount - offlineRegionsCount
- splitRegionsCount;
%>
<%= openRegionsCount %>
<%= offlineRegionsCount %>
<%= failedRegionsCount %>
<%= splitRegionsCount %>
<%= otherRegionsCount %>
<%= htDesc.toStringCustomizedValues() %>
<% }
} %>
<%= rsGroupTables.size() %> table(s) in set.
<% } else { %>
No Tables
<% } %>
<% } %>