HBASE-24704 Make Table Schema easier to view with multiple families

Closes #2042

Signed-off-by: Viraj Jasani <vjasani@apache.org>
This commit is contained in:
Zheng Wang 2020-08-02 23:20:30 +05:30 committed by Viraj Jasani
parent 86ebbdd8a2
commit 492cf108a9
No known key found for this signature in database
GPG Key ID: B3D6C0B41C8ADFD5
1 changed files with 32 additions and 25 deletions

View File

@ -26,12 +26,13 @@
import="java.util.LinkedHashMap"
import="java.util.List"
import="java.util.Map"
import="java.util.Set"
import="java.util.HashSet"
import="java.util.Optional"
import="java.util.TreeMap"
import="java.util.concurrent.TimeUnit"
import="org.apache.commons.lang3.StringEscapeUtils"
import="org.apache.hadoop.conf.Configuration"
import="org.apache.hadoop.hbase.HColumnDescriptor"
import="org.apache.hadoop.hbase.HConstants"
import="org.apache.hadoop.hbase.HRegionLocation"
import="org.apache.hadoop.hbase.HTableDescriptor"
@ -51,6 +52,7 @@
import="org.apache.hadoop.hbase.client.RegionLocator"
import="org.apache.hadoop.hbase.client.RegionReplicaUtil"
import="org.apache.hadoop.hbase.client.Table"
import="org.apache.hadoop.hbase.client.ColumnFamilyDescriptor"
import="org.apache.hadoop.hbase.http.InfoServer"
import="org.apache.hadoop.hbase.master.HMaster"
import="org.apache.hadoop.hbase.master.RegionState"
@ -771,40 +773,45 @@
%>
</table>
<h2>Table Schema</h2>
<table class="table table-striped">
<%
ColumnFamilyDescriptor[] families = table.getDescriptor().getColumnFamilies();
Set<Bytes> familyKeySet = new HashSet<>();
for (ColumnFamilyDescriptor family: families) {
familyKeySet.addAll(family.getValues().keySet());
}
%>
<tr>
<th>Column Family Name</th>
<th></th>
</tr>
<%
Collection<HColumnDescriptor> families = new HTableDescriptor(table.getDescriptor()).getFamilies();
for (HColumnDescriptor family: families) {
%>
<tr>
<td><%= StringEscapeUtils.escapeHtml4(family.getNameAsString()) %></td>
<td>
<table class="table table-striped">
<tr>
<th>Property</th>
<th>Value</th>
</tr>
<th>Property \ Column Family Name</th>
<%
Map<Bytes, Bytes> familyValues = family.getValues();
for (Bytes familyKey: familyValues.keySet()) {
for (ColumnFamilyDescriptor family: families) {
%>
<th>
<%= StringEscapeUtils.escapeHtml4(family.getNameAsString()) %>
</th>
<% } %>
</tr>
<%
for (Bytes familyKey: familyKeySet) {
%>
<tr>
<td>
<%= StringEscapeUtils.escapeHtml4(familyKey.toString()) %>
</td>
<td>
<%= StringEscapeUtils.escapeHtml4(familyValues.get(familyKey).toString()) %>
</td>
<%
for (ColumnFamilyDescriptor family: families) {
String familyValue = "-";
if(family.getValues().containsKey(familyKey)){
familyValue = family.getValues().get(familyKey).toString();
}
%>
<td>
<%= StringEscapeUtils.escapeHtml4(familyValue) %>
</td>
<% } %>
</tr>
<% } %>
</table>
</td>
</tr>
<% } %>
</table>
<%
long totalReadReq = 0;