Skip to content

Commit f68cda3

Browse files
committed
HBASE-22751 table.jsp fails if ugly regions in table
1 parent 11f30de commit f68cda3

File tree

1 file changed

+12
-10
lines changed
  • hbase-server/src/main/resources/hbase-webapps/master

1 file changed

+12
-10
lines changed

hbase-server/src/main/resources/hbase-webapps/master/table.jsp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import="java.util.Map"
3030
import="java.util.Objects"
3131
import="java.util.TreeMap"
32+
import=" java.util.concurrent.TimeUnit"
3233
import="org.apache.commons.lang3.StringEscapeUtils"
3334
import="org.apache.hadoop.conf.Configuration"
3435
import="org.apache.hadoop.hbase.HTableDescriptor"
@@ -38,8 +39,10 @@
3839
import="org.apache.hadoop.hbase.ServerName"
3940
import="org.apache.hadoop.hbase.TableName"
4041
import="org.apache.hadoop.hbase.TableNotFoundException"
41-
import="org.apache.hadoop.hbase.client.Admin"
42+
import="org.apache.hadoop.hbase.client.AsyncAdmin"
43+
import="org.apache.hadoop.hbase.client.AsyncConnection"
4244
import="org.apache.hadoop.hbase.client.CompactionState"
45+
import="org.apache.hadoop.hbase.client.ConnectionFactory"
4346
import="org.apache.hadoop.hbase.client.RegionInfo"
4447
import="org.apache.hadoop.hbase.client.RegionInfoBuilder"
4548
import="org.apache.hadoop.hbase.client.RegionLocator"
@@ -122,6 +125,8 @@
122125
pageTitle = "Table: " + escaped_fqtn;
123126
}
124127
pageContext.setAttribute("pageTitle", pageTitle);
128+
AsyncConnection connection = ConnectionFactory.createAsyncConnection(master.getConfiguration()).get();
129+
AsyncAdmin admin = connection.getAdminBuilder().setOperationTimeout(5, TimeUnit.SECONDS).build();
125130
%>
126131

127132
<jsp:include page="header.jsp">
@@ -148,7 +153,6 @@ if (fqtn != null && master.isInitialized()) {
148153
</div>
149154
<p><hr><p>
150155
<%
151-
try (Admin admin = master.getConnection().getAdmin()) {
152156
if (action.equals("split")) {
153157
if (key != null && key.length() > 0) {
154158
admin.split(TableName.valueOf(fqtn), Bytes.toBytes(key));
@@ -159,7 +163,7 @@ if (fqtn != null && master.isInitialized()) {
159163
%> Split request accepted. <%
160164
} else if (action.equals("compact")) {
161165
if (key != null && key.length() > 0) {
162-
List<RegionInfo> regions = admin.getRegions(TableName.valueOf(fqtn));
166+
List<RegionInfo> regions = admin.getRegions(TableName.valueOf(fqtn)).get();
163167
byte[] row = Bytes.toBytes(key);
164168
165169
for (RegionInfo region : regions) {
@@ -173,11 +177,10 @@ if (fqtn != null && master.isInitialized()) {
173177
%> Compact request accepted. <%
174178
} else if (action.equals("merge")) {
175179
if (left != null && left.length() > 0 && right != null && right.length() > 0) {
176-
admin.mergeRegionsAsync(Bytes.toBytesBinary(left), Bytes.toBytesBinary(right), false);
180+
admin.mergeRegions(Bytes.toBytesBinary(left), Bytes.toBytesBinary(right), false);
177181
}
178182
%> Merge request accepted. <%
179183
}
180-
}
181184
%>
182185
<jsp:include page="redirect.jsp" />
183186
</div>
@@ -253,7 +256,6 @@ if (fqtn != null && master.isInitialized()) {
253256
</tbody>
254257
</table>
255258
<%} else {
256-
Admin admin = master.getConnection().getAdmin();
257259
RegionStates states = master.getAssignmentManager().getRegionStates();
258260
Map<RegionState.State, List<RegionInfo>> regionStates = states.getRegionByStateOfTable(table.getName());
259261
Map<String, RegionState.State> stateMap = new HashMap<>();
@@ -273,15 +275,15 @@ if (fqtn != null && master.isInitialized()) {
273275
</tr>
274276
<tr>
275277
<td>Enabled</td>
276-
<td><%= admin.isTableEnabled(table.getName()) %></td>
278+
<td><%= admin.isTableEnabled(table.getName()).get() %></td>
277279
<td>Is the table enabled</td>
278280
</tr>
279281
<tr>
280282
<td>Compaction</td>
281283
<td>
282284
<%
283285
try {
284-
CompactionState compactionState = admin.getCompactionState(table.getName());
286+
CompactionState compactionState = admin.getCompactionState(table.getName()).get();
285287
%>
286288
<%= compactionState %>
287289
<%
@@ -522,7 +524,7 @@ if (fqtn != null && master.isInitialized()) {
522524
if (urlRegionServer != null) {
523525
%>
524526
<td>
525-
<a href="<%= urlRegionServer %>"><%= StringEscapeUtils.escapeHtml4(addr.getHostname().toString()) + ":" + master.getRegionServerInfoPort(addr) %></a>
527+
<a href="<%= urlRegionServer %>"><%= addr == null? "-": StringEscapeUtils.escapeHtml4(addr.getHostname().toString()) + ":" + master.getRegionServerInfoPort(addr) %></a>
526528
</td>
527529
<%
528530
} else {
@@ -597,7 +599,7 @@ if (withReplica) {
597599
%><%= StringEscapeUtils.escapeHtml4(element.toString()) %><%
598600
}
599601
} finally {
600-
admin.close();
602+
connection.close();
601603
}
602604
} // end else
603605
%>

0 commit comments

Comments
 (0)