29
29
import =" java.util.Map"
30
30
import =" java.util.Objects"
31
31
import =" java.util.TreeMap"
32
+ import =" java.util.concurrent.TimeUnit"
32
33
import =" org.apache.commons.lang3.StringEscapeUtils"
33
34
import =" org.apache.hadoop.conf.Configuration"
34
35
import =" org.apache.hadoop.hbase.HTableDescriptor"
38
39
import =" org.apache.hadoop.hbase.ServerName"
39
40
import =" org.apache.hadoop.hbase.TableName"
40
41
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"
42
44
import =" org.apache.hadoop.hbase.client.CompactionState"
45
+ import =" org.apache.hadoop.hbase.client.ConnectionFactory"
43
46
import =" org.apache.hadoop.hbase.client.RegionInfo"
44
47
import =" org.apache.hadoop.hbase.client.RegionInfoBuilder"
45
48
import =" org.apache.hadoop.hbase.client.RegionLocator"
122
125
pageTitle = " Table: " + escaped_fqtn;
123
126
}
124
127
pageContext. setAttribute(" pageTitle" , pageTitle);
128
+ AsyncConnection connection = ConnectionFactory . createAsyncConnection(master. getConfiguration()). get();
129
+ AsyncAdmin admin = connection. getAdminBuilder(). setOperationTimeout(5 , TimeUnit . SECONDS ). build();
125
130
% >
126
131
127
132
<jsp:include page =" header.jsp" >
@@ -148,7 +153,6 @@ if (fqtn != null && master.isInitialized()) {
148
153
</div >
149
154
<p ><hr ><p >
150
155
<%
151
- try (Admin admin = master. getConnection(). getAdmin()) {
152
156
if (action. equals(" split" )) {
153
157
if (key != null && key. length() > 0 ) {
154
158
admin. split(TableName . valueOf(fqtn), Bytes . toBytes(key));
@@ -159,7 +163,7 @@ if (fqtn != null && master.isInitialized()) {
159
163
% > Split request accepted. <%
160
164
} else if (action. equals(" compact" )) {
161
165
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() ;
163
167
byte [] row = Bytes . toBytes(key);
164
168
165
169
for (RegionInfo region : regions) {
@@ -173,11 +177,10 @@ if (fqtn != null && master.isInitialized()) {
173
177
% > Compact request accepted. <%
174
178
} else if (action. equals(" merge" )) {
175
179
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 );
177
181
}
178
182
% > Merge request accepted. <%
179
183
}
180
- }
181
184
% >
182
185
<jsp:include page =" redirect.jsp" />
183
186
</div >
@@ -253,7 +256,6 @@ if (fqtn != null && master.isInitialized()) {
253
256
</tbody >
254
257
</table >
255
258
<% } else {
256
- Admin admin = master. getConnection(). getAdmin();
257
259
RegionStates states = master. getAssignmentManager(). getRegionStates();
258
260
Map<RegionState . State , List<RegionInfo > > regionStates = states. getRegionByStateOfTable(table. getName());
259
261
Map<String , RegionState . State > stateMap = new HashMap<> ();
@@ -273,15 +275,15 @@ if (fqtn != null && master.isInitialized()) {
273
275
</tr >
274
276
<tr >
275
277
<td >Enabled</td >
276
- <td ><%= admin. isTableEnabled(table. getName()) % > </td >
278
+ <td ><%= admin. isTableEnabled(table. getName()). get() % > </td >
277
279
<td >Is the table enabled</td >
278
280
</tr >
279
281
<tr >
280
282
<td >Compaction</td >
281
283
<td >
282
284
<%
283
285
try {
284
- CompactionState compactionState = admin. getCompactionState(table. getName());
286
+ CompactionState compactionState = admin. getCompactionState(table. getName()). get() ;
285
287
% >
286
288
<%= compactionState % >
287
289
<%
@@ -522,7 +524,7 @@ if (fqtn != null && master.isInitialized()) {
522
524
if (urlRegionServer != null ) {
523
525
% >
524
526
<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 >
526
528
</td >
527
529
<%
528
530
} else {
@@ -597,7 +599,7 @@ if (withReplica) {
597
599
% ><%= StringEscapeUtils . escapeHtml4(element. toString()) % ><%
598
600
}
599
601
} finally {
600
- admin . close();
602
+ connection . close();
601
603
}
602
604
} // end else
603
605
% >
0 commit comments