diff --git a/CHANGES.txt b/CHANGES.txt index 04780033dc4..30df733b497 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -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 diff --git a/src/main/jamon/org/apache/hbase/tmpl/master/MasterStatusTmpl.jamon b/src/main/jamon/org/apache/hbase/tmpl/master/MasterStatusTmpl.jamon index 861d235f7e7..a8e20b3da59 100644 --- a/src/main/jamon/org/apache/hbase/tmpl/master/MasterStatusTmpl.jamon +++ b/src/main/jamon/org/apache/hbase/tmpl/master/MasterStatusTmpl.jamon @@ -158,11 +158,11 @@ org.apache.hadoop.hbase.HTableDescriptor; <%if (frags != null) %> <% frags.get(htDesc.getNameAsString()) != null ? frags.get(htDesc.getNameAsString()).intValue() + "%" : "n/a" %> - <% htDesc.toString() %> + <% htDesc.toStringCustomizedValues() %> -

<% tables.length %> table(s) in set.

+

<% tables.length %> table(s) in set. [Details]

diff --git a/src/main/java/org/apache/hadoop/hbase/HColumnDescriptor.java b/src/main/java/org/apache/hadoop/hbase/HColumnDescriptor.java index 72cef061a20..33476dbaeac 100644 --- a/src/main/java/org/apache/hadoop/hbase/HColumnDescriptor.java +++ b/src/main/java/org/apache/hadoop/hbase/HColumnDescriptor.java @@ -135,6 +135,18 @@ public class HColumnDescriptor implements WritableComparable */ public static final int DEFAULT_REPLICATION_SCOPE = HConstants.REPLICATION_SCOPE_LOCAL; + private final static Map DEFAULT_VALUES = new HashMap(); + 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 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 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) */ diff --git a/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java b/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java index 00bcb85cc8b..26af9795635 100644 --- a/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java +++ b/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java @@ -517,6 +517,52 @@ public class HTableDescriptor implements WritableComparable { 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 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) */ diff --git a/src/main/resources/hbase-webapps/master/tablesDetailed.jsp b/src/main/resources/hbase-webapps/master/tablesDetailed.jsp new file mode 100644 index 00000000000..0d55bb210c1 --- /dev/null +++ b/src/main/resources/hbase-webapps/master/tablesDetailed.jsp @@ -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(); +%> + + + + +HBase Master: <%= master.getServerName()%>%> + + + + +

User Tables

+<% HTableDescriptor[] tables = new HBaseAdmin(conf).listTables(); + if(tables != null && tables.length > 0) { %> + + + + + +<% for(HTableDescriptor htDesc : tables ) { %> + + + + +<% } %> + +

<%= tables.length %> table(s) in set.

+
TableDescription
<%= htDesc.getNameAsString() %><%= htDesc.toString() %>
+<% } %> + +