Skip to content

Commit

Permalink
HBASE-22751 table.jsp fails if ugly regions in table
Browse files Browse the repository at this point in the history
  • Loading branch information
saintstack authored and petersomogyi committed Jul 30, 2019
1 parent bf36bdf commit efead31
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions hbase-server/src/main/resources/hbase-webapps/master/table.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import="java.util.List"
import="java.util.Map"
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"
Expand All @@ -35,8 +36,10 @@
import="org.apache.hadoop.hbase.ServerName"
import="org.apache.hadoop.hbase.TableName"
import="org.apache.hadoop.hbase.TableNotFoundException"
import="org.apache.hadoop.hbase.client.Admin"
import="org.apache.hadoop.hbase.client.AsyncAdmin"
import="org.apache.hadoop.hbase.client.AsyncConnection"
import="org.apache.hadoop.hbase.client.CompactionState"
import="org.apache.hadoop.hbase.client.ConnectionFactory"
import="org.apache.hadoop.hbase.client.RegionInfo"
import="org.apache.hadoop.hbase.client.RegionInfoBuilder"
import="org.apache.hadoop.hbase.client.RegionLocator"
Expand Down Expand Up @@ -119,6 +122,8 @@
pageTitle = "Table: " + escaped_fqtn;
}
pageContext.setAttribute("pageTitle", pageTitle);
AsyncConnection connection = ConnectionFactory.createAsyncConnection(master.getConfiguration()).get();
AsyncAdmin admin = connection.getAdminBuilder().setOperationTimeout(5, TimeUnit.SECONDS).build();
%>

<jsp:include page="header.jsp">
Expand All @@ -145,7 +150,6 @@ if (fqtn != null && master.isInitialized()) {
</div>
<p><hr><p>
<%
try (Admin admin = master.getConnection().getAdmin()) {
if (action.equals("split")) {
if (key != null && key.length() > 0) {
admin.split(TableName.valueOf(fqtn), Bytes.toBytes(key));
Expand All @@ -156,7 +160,7 @@ if (fqtn != null && master.isInitialized()) {
%> Split request accepted. <%
} else if (action.equals("compact")) {
if (key != null && key.length() > 0) {
List<RegionInfo> regions = admin.getRegions(TableName.valueOf(fqtn));
List<RegionInfo> regions = admin.getRegions(TableName.valueOf(fqtn)).get();
byte[] row = Bytes.toBytes(key);
for (RegionInfo region : regions) {
Expand All @@ -174,7 +178,6 @@ if (fqtn != null && master.isInitialized()) {
}
%> Merge request accepted. <%
}
}
%>
<jsp:include page="redirect.jsp" />
</div>
Expand Down Expand Up @@ -250,8 +253,7 @@ if (fqtn != null && master.isInitialized()) {
</tbody>
</table>
<%} else {
Admin admin = master.getConnection().getAdmin();
RegionLocator r = master.getClusterConnection().getRegionLocator(table.getName());
RegionLocator r = master.getConnection().getRegionLocator(table.getName());
try { %>
<h2>Table Attributes</h2>
<table class="table table-striped">
Expand All @@ -262,15 +264,15 @@ if (fqtn != null && master.isInitialized()) {
</tr>
<tr>
<td>Enabled</td>
<td><%= admin.isTableEnabled(table.getName()) %></td>
<td><%= admin.isTableEnabled(table.getName()).get() %></td>
<td>Is the table enabled</td>
</tr>
<tr>
<td>Compaction</td>
<td>
<%
try {
CompactionState compactionState = admin.getCompactionState(table.getName());
CompactionState compactionState = admin.getCompactionState(table.getName()).get();
%>
<%= compactionState %>
<%
Expand Down Expand Up @@ -504,7 +506,7 @@ if (fqtn != null && master.isInitialized()) {
if (urlRegionServer != null) {
%>
<td>
<a href="<%= urlRegionServer %>"><%= StringEscapeUtils.escapeHtml4(addr.getHostname().toString()) + ":" + master.getRegionServerInfoPort(addr) %></a>
<a href="<%= urlRegionServer %>"><%= addr == null? "-": StringEscapeUtils.escapeHtml4(addr.getHostname().toString()) + ":" + master.getRegionServerInfoPort(addr) %></a>
</td>
<%
} else {
Expand Down Expand Up @@ -578,7 +580,7 @@ if (withReplica) {
%><%= StringEscapeUtils.escapeHtml4(element.toString()) %><%
}
} finally {
admin.close();
connection.close();
}
} // end else
%>
Expand Down

0 comments on commit efead31

Please sign in to comment.