HBASE-4227 Modify the webUI so that default values of column families are not shown

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1159515 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2011-08-19 06:26:14 +00:00
parent 4c797e7ba9
commit 95c39ae2ab
5 changed files with 128 additions and 2 deletions

View File

@ -381,6 +381,8 @@ Release 0.91.0 - Unreleased
call contents
HBASE-4190 Coprocessors: pull up some cp constants from cp package to
o.a.h.h.HConstants (Mingjie Lai)
HBASE-4227 Modify the webUI so that default values of column families are
not shown (Nileema Shingte)
TASKS
HBASE-3559 Move report of split to master OFF the heartbeat channel

View File

@ -158,11 +158,11 @@ org.apache.hadoop.hbase.HTableDescriptor;
<%if (frags != null) %>
<td align="center"><% frags.get(htDesc.getNameAsString()) != null ? frags.get(htDesc.getNameAsString()).intValue() + "%" : "n/a" %></td>
</%if>
<td><% htDesc.toString() %></td>
<td><% htDesc.toStringCustomizedValues() %></td>
</tr>
</%for>
<p> <% tables.length %> table(s) in set.</p>
<p> <% tables.length %> table(s) in set. [<a href=tablesDetailed.jsp>Details</a>]</p>
</table>
</%if>
</%def>

View File

@ -135,6 +135,18 @@ public class HColumnDescriptor implements WritableComparable<HColumnDescriptor>
*/
public static final int DEFAULT_REPLICATION_SCOPE = HConstants.REPLICATION_SCOPE_LOCAL;
private final static Map<String, String> DEFAULT_VALUES = new HashMap<String, String>();
static {
DEFAULT_VALUES.put(BLOOMFILTER, DEFAULT_BLOOMFILTER);
DEFAULT_VALUES.put(REPLICATION_SCOPE, String.valueOf(DEFAULT_REPLICATION_SCOPE));
DEFAULT_VALUES.put(HConstants.VERSIONS, String.valueOf(DEFAULT_VERSIONS));
DEFAULT_VALUES.put(COMPRESSION, DEFAULT_COMPRESSION);
DEFAULT_VALUES.put(TTL, String.valueOf(DEFAULT_TTL));
DEFAULT_VALUES.put(BLOCKSIZE, String.valueOf(DEFAULT_BLOCKSIZE));
DEFAULT_VALUES.put(HConstants.IN_MEMORY, String.valueOf(DEFAULT_IN_MEMORY));
DEFAULT_VALUES.put(BLOCKCACHE, String.valueOf(DEFAULT_BLOCKCACHE));
}
// Column family name
private byte [] name;
@ -574,6 +586,32 @@ public class HColumnDescriptor implements WritableComparable<HColumnDescriptor>
return s.toString();
}
/**
* @return Column family descriptor with only the customized attributes.
*/
public String toStringCustomizedValues() {
StringBuilder s = new StringBuilder();
s.append('{');
s.append(HConstants.NAME);
s.append(" => '");
s.append(Bytes.toString(name));
s.append("'");
for (Map.Entry<ImmutableBytesWritable, ImmutableBytesWritable> e:
values.entrySet()) {
String key = Bytes.toString(e.getKey().get());
String value = Bytes.toString(e.getValue().get());
if(DEFAULT_VALUES.get(key) == null || !DEFAULT_VALUES.get(key).equalsIgnoreCase(value)) {
s.append(", ");
s.append(key);
s.append(" => '");
s.append(value);
s.append("'");
}
}
s.append('}');
return s.toString();
}
/**
* @see java.lang.Object#equals(java.lang.Object)
*/

View File

@ -517,6 +517,52 @@ public class HTableDescriptor implements WritableComparable<HTableDescriptor> {
return s.toString();
}
/**
* @return Name of this table and then a map of all of the column family
* descriptors (with only the non-default column family attributes)
*/
public String toStringCustomizedValues() {
StringBuilder s = new StringBuilder();
s.append('{');
s.append(HConstants.NAME);
s.append(" => '");
s.append(Bytes.toString(name));
s.append("'");
for (Map.Entry<ImmutableBytesWritable, ImmutableBytesWritable> e:
values.entrySet()) {
String key = Bytes.toString(e.getKey().get());
String value = Bytes.toString(e.getValue().get());
if (key == null) {
continue;
}
String upperCase = key.toUpperCase();
if (upperCase.equals(IS_ROOT) || upperCase.equals(IS_META)) {
// Skip. Don't bother printing out read-only values if false.
if (value.toLowerCase().equals(Boolean.FALSE.toString())) {
continue;
}
}
s.append(", ");
s.append(Bytes.toString(e.getKey().get()));
s.append(" => '");
s.append(Bytes.toString(e.getValue().get()));
s.append("'");
}
s.append(", ");
s.append(FAMILIES);
s.append(" => [");
int size = families.values().size();
int i = 0;
for(HColumnDescriptor hcd : families.values()) {
s.append(hcd.toStringCustomizedValues());
i++;
if( i != size)
s.append(", ");
}
s.append("]}");
return s.toString();
}
/**
* @see java.lang.Object#equals(java.lang.Object)
*/

View File

@ -0,0 +1,40 @@
<%@ page contentType="text/html;charset=UTF-8"
import="java.util.*"
import="org.apache.hadoop.util.StringUtils"
import="org.apache.hadoop.conf.Configuration"
import="org.apache.hadoop.hbase.master.HMaster"
import="org.apache.hadoop.hbase.client.HBaseAdmin"
import="org.apache.hadoop.hbase.HTableDescriptor" %><%
HMaster master = (HMaster)getServletContext().getAttribute(HMaster.MASTER);
Configuration conf = master.getConfiguration();
%>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
<title>HBase Master: <%= master.getServerName()%>%></title>
<link rel="stylesheet" type="text/css" href="/static/hbase.css" />
</head>
<body>
<h2>User Tables</h2>
<% HTableDescriptor[] tables = new HBaseAdmin(conf).listTables();
if(tables != null && tables.length > 0) { %>
<table>
<tr>
<th>Table</th>
<th>Description</th>
</tr>
<% for(HTableDescriptor htDesc : tables ) { %>
<tr>
<td><%= htDesc.getNameAsString() %></td>
<td><%= htDesc.toString() %></td>
</tr>
<% } %>
<p> <%= tables.length %> table(s) in set.</p>
</table>
<% } %>
</body>
</html>