hbase.coprocessor.region.classes
diff --git a/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/AssignmentManagerStatusTmpl.jamon b/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/AssignmentManagerStatusTmpl.jamon
index 08ed672376d..f6ea46455d5 100644
--- a/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/AssignmentManagerStatusTmpl.jamon
+++ b/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/AssignmentManagerStatusTmpl.jamon
@@ -85,7 +85,9 @@ if (toRemove > 0) {
<%else>
%if>
- <% entry.getKey() %> | <% entry.getValue().toDescriptiveString() %> |
+ <% entry.getKey() %> |
+ <% HRegionInfo.getDescriptiveNameFromRegionStateForDisplay(
+ entry.getValue(), conf) %> |
<% (currentTime - entry.getValue().getStamp()) %> |
%for>
Total number of Regions in Transition for more than <% ritThreshold %> milliseconds | <% numOfRITOverThreshold %> | |
diff --git a/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/RegionListTmpl.jamon b/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/RegionListTmpl.jamon
index 8606b4e89b7..7c4f1f134b9 100644
--- a/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/RegionListTmpl.jamon
+++ b/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/RegionListTmpl.jamon
@@ -93,9 +93,12 @@
<%for HRegionInfo r: onlineRegions %>
- <% r.getRegionNameAsString() %> |
- <% Bytes.toStringBinary(r.getStartKey()) %> |
- <% Bytes.toStringBinary(r.getEndKey()) %> |
+ <% HRegionInfo.getRegionNameAsStringForDisplay(r,
+ regionServer.getConfiguration()) %> |
+ <% Bytes.toStringBinary(HRegionInfo.getStartKeyForDisplay(r,
+ regionServer.getConfiguration())) %> |
+ <% Bytes.toStringBinary(HRegionInfo.getEndKeyForDisplay(r,
+ regionServer.getConfiguration())) %> |
<% r.getReplicaId() %> |
%for>
@@ -119,7 +122,8 @@
<%java>
RegionLoad load = regionServer.createRegionLoad(r.getEncodedName());
%java>
- <% r.getRegionNameAsString() %> |
+ <% HRegionInfo.getRegionNameAsStringForDisplay(r,
+ regionServer.getConfiguration()) %> |
<%if load != null %>
<% load.getReadRequestsCount() %> |
<% load.getWriteRequestsCount() %> |
@@ -151,7 +155,8 @@
<%java>
RegionLoad load = regionServer.createRegionLoad(r.getEncodedName());
%java>
- <% r.getRegionNameAsString() %> |
+ <% HRegionInfo.getRegionNameAsStringForDisplay(r,
+ regionServer.getConfiguration()) %> |
<%if load != null %>
<% load.getStores() %> |
<% load.getStorefiles() %> |
@@ -189,7 +194,8 @@
((float) load.getCurrentCompactedKVs() / load.getTotalCompactingKVs())) + "%";
}
%java>
- <% r.getRegionNameAsString() %> |
+ <% HRegionInfo.getRegionNameAsStringForDisplay(r,
+ regionServer.getConfiguration()) %> |
<%if load != null %>
<% load.getTotalCompactingKVs() %> |
<% load.getCurrentCompactedKVs() %> |
@@ -216,7 +222,8 @@
<%java>
RegionLoad load = regionServer.createRegionLoad(r.getEncodedName());
%java>
- <% r.getRegionNameAsString() %> |
+ <% HRegionInfo.getRegionNameAsStringForDisplay(r,
+ regionServer.getConfiguration()) %> |
<%if load != null %>
<% load.getMemstoreSizeMB() %>m |
%if>
diff --git a/hbase-server/src/main/resources/hbase-webapps/master/table.jsp b/hbase-server/src/main/resources/hbase-webapps/master/table.jsp
index 4fa029944ab..31072262e0c 100644
--- a/hbase-server/src/main/resources/hbase-webapps/master/table.jsp
+++ b/hbase-server/src/main/resources/hbase-webapps/master/table.jsp
@@ -283,7 +283,8 @@
}
%>
- <%= escapeXml(Bytes.toStringBinary(regionInfo.getRegionName())) %> |
+ <%= escapeXml(Bytes.toStringBinary(HRegionInfo.getRegionNameForDisplay(regionInfo,
+ conf))) %> |
<%
if (addr != null) {
String url = "//" + addr.getHostname() + ":" + master.getRegionServerInfoPort(addr) + "/";
@@ -298,8 +299,10 @@
<%
}
%>
- <%= escapeXml(Bytes.toStringBinary(regionInfo.getStartKey())) %> |
- <%= escapeXml(Bytes.toStringBinary(regionInfo.getEndKey())) %> |
+ <%= escapeXml(Bytes.toStringBinary(HRegionInfo.getStartKeyForDisplay(regionInfo,
+ conf))) %> |
+ <%= escapeXml(Bytes.toStringBinary(HRegionInfo.getEndKeyForDisplay(regionInfo,
+ conf))) %> |
<%= req%> |
<%
if (withReplica) {
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionInfo.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionInfo.java
index db4e5cf6984..a9aa456d617 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionInfo.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionInfo.java
@@ -26,6 +26,7 @@ import static org.junit.Assert.fail;
import java.io.IOException;
+import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.HBaseTestingUtility;
@@ -34,10 +35,12 @@ import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.SmallTests;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.exceptions.DeserializationException;
+import org.apache.hadoop.hbase.master.RegionState;
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos;
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionInfo;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.MD5Hash;
+import org.junit.Assert;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -254,6 +257,71 @@ public class TestHRegionInfo {
assertEquals(expectedHri, convertedHri);
}
+ @Test
+ public void testRegionDetailsForDisplay() throws IOException {
+ byte[] startKey = new byte[] {0x01, 0x01, 0x02, 0x03};
+ byte[] endKey = new byte[] {0x01, 0x01, 0x02, 0x04};
+ Configuration conf = new Configuration();
+ conf.setBoolean("hbase.display.keys", false);
+ HRegionInfo h = new HRegionInfo(TableName.valueOf("foo"), startKey, endKey);
+ checkEquality(h, conf);
+ // check HRIs with non-default replicaId
+ h = new HRegionInfo(TableName.valueOf("foo"), startKey, endKey, false,
+ System.currentTimeMillis(), 1);
+ checkEquality(h, conf);
+ Assert.assertArrayEquals(HRegionInfo.HIDDEN_END_KEY,
+ HRegionInfo.getEndKeyForDisplay(h, conf));
+ Assert.assertArrayEquals(HRegionInfo.HIDDEN_START_KEY,
+ HRegionInfo.getStartKeyForDisplay(h, conf));
+ RegionState state = new RegionState(h, RegionState.State.OPEN);
+ String descriptiveNameForDisplay =
+ HRegionInfo.getDescriptiveNameFromRegionStateForDisplay(state, conf);
+ checkDescriptiveNameEquality(descriptiveNameForDisplay,state.toDescriptiveString(), startKey);
+
+ conf.setBoolean("hbase.display.keys", true);
+ Assert.assertArrayEquals(endKey, HRegionInfo.getEndKeyForDisplay(h, conf));
+ Assert.assertArrayEquals(startKey, HRegionInfo.getStartKeyForDisplay(h, conf));
+ Assert.assertEquals(state.toDescriptiveString(),
+ HRegionInfo.getDescriptiveNameFromRegionStateForDisplay(state, conf));
+ }
+
+ private void checkDescriptiveNameEquality(String descriptiveNameForDisplay, String origDesc,
+ byte[] startKey) {
+ // except for the "hidden-start-key" substring everything else should exactly match
+ String firstPart = descriptiveNameForDisplay.substring(0,
+ descriptiveNameForDisplay.indexOf(new String(HRegionInfo.HIDDEN_START_KEY)));
+ String secondPart = descriptiveNameForDisplay.substring(
+ descriptiveNameForDisplay.indexOf(new String(HRegionInfo.HIDDEN_START_KEY)) +
+ HRegionInfo.HIDDEN_START_KEY.length);
+ String firstPartOrig = origDesc.substring(0,
+ origDesc.indexOf(Bytes.toStringBinary(startKey)));
+ String secondPartOrig = origDesc.substring(
+ origDesc.indexOf(Bytes.toStringBinary(startKey)) +
+ Bytes.toStringBinary(startKey).length());
+ assert(firstPart.equals(firstPartOrig));
+ assert(secondPart.equals(secondPartOrig));
+ }
+
+ private void checkEquality(HRegionInfo h, Configuration conf) throws IOException {
+ byte[] modifiedRegionName = HRegionInfo.getRegionNameForDisplay(h, conf);
+ byte[][] modifiedRegionNameParts = HRegionInfo.parseRegionName(modifiedRegionName);
+ byte[][] regionNameParts = HRegionInfo.parseRegionName(h.getRegionName());
+
+ //same number of parts
+ assert(modifiedRegionNameParts.length == regionNameParts.length);
+
+ for (int i = 0; i < regionNameParts.length; i++) {
+ // all parts should match except for [1] where in the modified one,
+ // we should have "hidden_start_key"
+ if (i != 1) {
+ Assert.assertArrayEquals(regionNameParts[i], modifiedRegionNameParts[i]);
+ } else {
+ Assert.assertNotEquals(regionNameParts[i][0], modifiedRegionNameParts[i][0]);
+ Assert.assertArrayEquals(modifiedRegionNameParts[1],
+ HRegionInfo.getStartKeyForDisplay(h, conf));
+ }
+ }
+ }
}