HBASE-17532 Replaced explicit type with diamond operator
[hbase.git] / hbase-server / src / main / resources / hbase-webapps / master / table.jsp
blob0f8a289d8d1bf38f037711e959b7e421ba7b8a9b
1 <%--
2 /**
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 --%>
20 <%@page import="org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionSpecifier.RegionSpecifierType"%>
21 <%@ page contentType="text/html;charset=UTF-8"
22 import="static org.apache.commons.lang.StringEscapeUtils.escapeXml"
23 import="org.apache.hadoop.hbase.shaded.com.google.protobuf.ByteString"
24 import="java.net.URLEncoder"
25 import="java.util.ArrayList"
26 import="java.util.TreeMap"
27 import="java.util.List"
28 import="java.util.LinkedHashMap"
29 import="java.util.Map"
30 import="java.util.Set"
31 import="java.util.Collection"
32 import="java.util.Collections"
33 import="java.util.Comparator"
34 import="org.apache.commons.lang.StringEscapeUtils"
35 import="org.apache.hadoop.conf.Configuration"
36 import="org.apache.hadoop.util.StringUtils"
37 import="org.apache.hadoop.hbase.HRegionInfo"
38 import="org.apache.hadoop.hbase.HRegionLocation"
39 import="org.apache.hadoop.hbase.ServerName"
40 import="org.apache.hadoop.hbase.ServerLoad"
41 import="org.apache.hadoop.hbase.RegionLoad"
42 import="org.apache.hadoop.hbase.HConstants"
43 import="org.apache.hadoop.hbase.master.HMaster"
44 import="org.apache.hadoop.hbase.zookeeper.MetaTableLocator"
45 import="org.apache.hadoop.hbase.util.Bytes"
46 import="org.apache.hadoop.hbase.util.FSUtils"
47 import="org.apache.hadoop.hbase.shaded.protobuf.generated.ClusterStatusProtos"
48 import="org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos"
49 import="org.apache.hadoop.hbase.TableName"
50 import="org.apache.hadoop.hbase.HColumnDescriptor"
51 import="org.apache.hadoop.hbase.HBaseConfiguration"
52 import="org.apache.hadoop.hbase.TableNotFoundException"%>
53 <%@ page import="org.apache.hadoop.hbase.client.*" %>
54 <%!
55 /**
56 * @return An empty region load stamped with the passed in <code>hri</code>
57 * region name.
59 private RegionLoad getEmptyRegionLoad(final HRegionInfo hri) {
60 return new RegionLoad(ClusterStatusProtos.RegionLoad.newBuilder().
61 setRegionSpecifier(HBaseProtos.RegionSpecifier.newBuilder().
62 setType(HBaseProtos.RegionSpecifier.RegionSpecifierType.REGION_NAME).
63 setValue(ByteString.copyFrom(hri.getRegionName())).build()).build());
67 HMaster master = (HMaster)getServletContext().getAttribute(HMaster.MASTER);
68 Configuration conf = master.getConfiguration();
70 MetaTableLocator metaTableLocator = new MetaTableLocator();
71 String fqtn = request.getParameter("name");
72 final String escaped_fqtn = StringEscapeUtils.escapeHtml(fqtn);
73 String sortKey = request.getParameter("sort");
74 String reverse = request.getParameter("reverse");
75 final boolean reverseOrder = (reverse==null||!reverse.equals("false"));
76 String showWholeKey = request.getParameter("showwhole");
77 final boolean showWhole = (showWholeKey!=null && showWholeKey.equals("true"));
78 Table table;
79 String tableHeader;
80 boolean withReplica = false;
81 ServerName rl = metaTableLocator.getMetaRegionLocation(master.getZooKeeper());
82 boolean showFragmentation = conf.getBoolean("hbase.master.ui.fragmentation.enabled", false);
83 boolean readOnly = conf.getBoolean("hbase.master.ui.readonly", false);
84 int numMetaReplicas = conf.getInt(HConstants.META_REPLICAS_NUM,
85 HConstants.DEFAULT_META_REPLICA_NUM);
86 Map<String, Integer> frags = null;
87 if (showFragmentation) {
88 frags = FSUtils.getTableFragmentation(master);
90 String action = request.getParameter("action");
91 String key = request.getParameter("key");
92 String left = request.getParameter("left");
93 String right = request.getParameter("right");
94 long totalStoreFileSizeMB = 0;
96 final String numRegionsParam = request.getParameter("numRegions");
97 // By default, the page render up to 10000 regions to improve the page load time
98 int numRegionsToRender = 10000;
99 if (numRegionsParam != null) {
100 // either 'all' or a number
101 if (numRegionsParam.equals("all")) {
102 numRegionsToRender = -1;
103 } else {
104 try {
105 numRegionsToRender = Integer.parseInt(numRegionsParam);
106 } catch (NumberFormatException ex) {
107 // ignore
111 int numRegions = 0;
114 <!--[if IE]>
115 <!DOCTYPE html>
116 <![endif]-->
117 <?xml version="1.0" encoding="UTF-8" ?>
118 <html xmlns="http://www.w3.org/1999/xhtml">
119 <head>
120 <meta charset="utf-8">
121 <% if ( !readOnly && action != null ) { %>
122 <title>HBase Master: <%= StringEscapeUtils.escapeHtml(master.getServerName().toString()) %></title>
123 <% } else { %>
124 <title>Table: <%= escaped_fqtn %></title>
125 <% } %>
126 <meta name="viewport" content="width=device-width, initial-scale=1.0">
127 <meta name="description" content="">
128 <meta name="author" content="">
131 <link href="/static/css/bootstrap.min.css" rel="stylesheet">
132 <link href="/static/css/bootstrap-theme.min.css" rel="stylesheet">
133 <link href="/static/css/hbase.css" rel="stylesheet">
134 <% if ( ( !readOnly && action != null ) || fqtn == null ) { %>
135 <script type="text/javascript">
136 <!--
137 setTimeout("history.back()",5000);
139 </script>
140 <% } else { %>
141 <!--[if lt IE 9]>
142 <script src="/static/js/html5shiv.js"></script>
143 <![endif]-->
144 <% } %>
145 </head>
146 <body>
147 <div class="navbar navbar-fixed-top navbar-default">
148 <div class="container-fluid">
149 <div class="navbar-header">
150 <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
151 <span class="icon-bar"></span>
152 <span class="icon-bar"></span>
153 <span class="icon-bar"></span>
154 </button>
155 <a class="navbar-brand" href="/master-status"><img src="/static/hbase_logo_small.png" alt="HBase Logo"/></a>
156 </div>
157 <div class="collapse navbar-collapse">
158 <ul class="nav navbar-nav">
159 <li><a href="/master-status">Home</a></li>
160 <li><a href="/tablesDetailed.jsp">Table Details</a></li>
161 <li><a href="/procedures.jsp">Procedures</a></li>
162 <li><a href="/logs/">Local Logs</a></li>
163 <li><a href="/logLevel">Log Level</a></li>
164 <li><a href="/dump">Debug Dump</a></li>
165 <li><a href="/jmx">Metrics Dump</a></li>
166 <% if (HBaseConfiguration.isShowConfInServlet()) { %>
167 <li><a href="/conf">HBase Configuration</a></li>
168 <% } %>
169 </ul>
170 </div><!--/.nav-collapse -->
171 </div>
172 </div>
174 if ( fqtn != null ) {
175 try {
176 table = master.getConnection().getTable(TableName.valueOf(fqtn));
177 if (table.getTableDescriptor().getRegionReplication() > 1) {
178 tableHeader = "<h2>Table Regions</h2><table class=\"table table-striped\" style=\"table-layout: fixed; word-wrap: break-word;\"><tr><th>Name</th><th>Region Server</th><th>ReadRequests</th><th>WriteRequests</th><th>StorefileSize</th><th>Num.Storefiles</th><th>MemSize</th><th>Locality</th><th>Start Key</th><th>End Key</th><th>ReplicaID</th></tr>";
179 withReplica = true;
180 } else {
181 tableHeader = "<h2>Table Regions</h2><table class=\"table table-striped\" style=\"table-layout: fixed; word-wrap: break-word;\"><tr><th>Name</th><th>Region Server</th><th>ReadRequests</th><th>WriteRequests</th><th>StorefileSize</th><th>Num.Storefiles</th><th>MemSize</th><th>Locality</th><th>Start Key</th><th>End Key</th></tr>";
183 if ( !readOnly && action != null ) {
185 <div class="container-fluid content">
186 <div class="row inner_header">
187 <div class="page-header">
188 <h1>Table action request accepted</h1>
189 </div>
190 </div>
191 <p><hr><p>
193 try (Admin admin = master.getConnection().getAdmin()) {
194 if (action.equals("split")) {
195 if (key != null && key.length() > 0) {
196 admin.split(TableName.valueOf(fqtn), Bytes.toBytes(key));
197 } else {
198 admin.split(TableName.valueOf(fqtn));
201 %> Split request accepted. <%
202 } else if (action.equals("compact")) {
203 if (key != null && key.length() > 0) {
204 List<HRegionInfo> regions = admin.getTableRegions(TableName.valueOf(fqtn));
205 byte[] row = Bytes.toBytes(key);
207 for (HRegionInfo region : regions) {
208 if (region.containsRow(row)) {
209 admin.compactRegion(region.getRegionName());
212 } else {
213 admin.compact(TableName.valueOf(fqtn));
215 %> Compact request accepted. <%
216 } else if (action.equals("merge")) {
217 if (left != null && left.length() > 0 && right != null && right.length() > 0) {
218 admin.mergeRegions(Bytes.toBytesBinary(left), Bytes.toBytesBinary(right), false);
220 %> Merge request accepted. <%
224 <p>Go <a href="javascript:history.back()">Back</a>, or wait for the redirect.
225 </div>
227 } else {
229 <div class="container-fluid content">
230 <div class="row inner_header">
231 <div class="page-header">
232 <h1>Table <small><%= escaped_fqtn %></small></h1>
233 </div>
234 </div>
235 <div class="row">
237 if(fqtn.equals(TableName.META_TABLE_NAME.getNameAsString())) {
239 <%= tableHeader %>
241 // NOTE: Presumes meta with one or more replicas
242 for (int j = 0; j < numMetaReplicas; j++) {
243 HRegionInfo meta = RegionReplicaUtil.getRegionInfoForReplica(
244 HRegionInfo.FIRST_META_REGIONINFO, j);
245 ServerName metaLocation = metaTableLocator.waitMetaRegionLocation(master.getZooKeeper(), j, 1);
246 for (int i = 0; i < 1; i++) {
247 String url = "";
248 String readReq = "N/A";
249 String writeReq = "N/A";
250 String fileSize = "N/A";
251 String fileCount = "N/A";
252 String memSize = "N/A";
253 float locality = 0.0f;
255 if (metaLocation != null) {
256 ServerLoad sl = master.getServerManager().getLoad(metaLocation);
257 // The host name portion should be safe, but I don't know how we handle IDNs so err on the side of failing safely.
258 url = "//" + URLEncoder.encode(metaLocation.getHostname()) + ":" + master.getRegionServerInfoPort(metaLocation) + "/";
259 if (sl != null) {
260 Map<byte[], RegionLoad> map = sl.getRegionsLoad();
261 if (map.containsKey(meta.getRegionName())) {
262 RegionLoad load = map.get(meta.getRegionName());
263 readReq = String.format("%,1d", load.getReadRequestsCount());
264 writeReq = String.format("%,1d", load.getWriteRequestsCount());
265 fileSize = StringUtils.byteDesc(load.getStorefileSizeMB()*1024l*1024);
266 fileCount = String.format("%,1d", load.getStorefiles());
267 memSize = StringUtils.byteDesc(load.getMemStoreSizeMB()*1024l*1024);
268 locality = load.getDataLocality();
273 <tr>
274 <td><%= escapeXml(meta.getRegionNameAsString()) %></td>
275 <td><a href="<%= url %>"><%= StringEscapeUtils.escapeHtml(metaLocation.getHostname().toString()) + ":" + master.getRegionServerInfoPort(metaLocation) %></a></td>
276 <td><%= readReq%></td>
277 <td><%= writeReq%></td>
278 <td><%= fileSize%></td>
279 <td><%= fileCount%></td>
280 <td><%= memSize%></td>
281 <td><%= locality%></td>
282 <td><%= escapeXml(Bytes.toString(meta.getStartKey())) %></td>
283 <td><%= escapeXml(Bytes.toString(meta.getEndKey())) %></td>
284 </tr>
285 <% } %>
286 <%} %>
287 </table>
288 <%} else {
289 Admin admin = master.getConnection().getAdmin();
290 RegionLocator r = master.getClusterConnection().getRegionLocator(table.getName());
291 try { %>
292 <h2>Table Attributes</h2>
293 <table class="table table-striped">
294 <tr>
295 <th>Attribute Name</th>
296 <th>Value</th>
297 <th>Description</th>
298 </tr>
299 <tr>
300 <td>Enabled</td>
301 <td><%= admin.isTableEnabled(table.getName()) %></td>
302 <td>Is the table enabled</td>
303 </tr>
304 <tr>
305 <td>Compaction</td>
306 <td>
308 try {
309 CompactionState compactionState = admin.getCompactionState(table.getName());
311 <%= compactionState %>
313 } catch (Exception e) {
314 // Nothing really to do here
315 for(StackTraceElement element : e.getStackTrace()) {
316 %><%= StringEscapeUtils.escapeHtml(element.toString()) %><%
318 %> Unknown <%
321 </td>
322 <td>Is the table compacting</td>
323 </tr>
324 <% if (showFragmentation) { %>
325 <tr>
326 <td>Fragmentation</td>
327 <td><%= frags.get(fqtn) != null ? frags.get(fqtn).intValue() + "%" : "n/a" %></td>
328 <td>How fragmented is the table. After a major compaction it is 0%.</td>
329 </tr>
330 <% } %>
331 </table>
332 <h2>Table Schema</h2>
333 <table class="table table-striped">
334 <tr>
335 <th>Column Name</th>
336 <th></th>
337 </tr>
339 Collection<HColumnDescriptor> families = table.getTableDescriptor().getFamilies();
340 for (HColumnDescriptor family: families) {
342 <tr>
343 <td><%= StringEscapeUtils.escapeHtml(family.getNameAsString()) %></td>
344 <td>
345 <table class="table table-striped">
346 <tr>
347 <th>Property</th>
348 <th>Value</th>
349 </tr>
351 Map<Bytes, Bytes> familyValues = family.getValues();
352 for (Bytes familyKey: familyValues.keySet()) {
354 <tr>
355 <td>
356 <%= StringEscapeUtils.escapeHtml(familyKey.toString()) %>
357 </td>
358 <td>
359 <%= StringEscapeUtils.escapeHtml(familyValues.get(familyKey).toString()) %>
360 </td>
361 </tr>
362 <% } %>
363 </table>
364 </td>
365 </tr>
366 <% } %>
367 </table>
369 long totalReadReq = 0;
370 long totalWriteReq = 0;
371 long totalSize = 0;
372 long totalStoreFileCount = 0;
373 long totalMemSize = 0;
374 String urlRegionServer = null;
375 Map<ServerName, Integer> regDistribution = new TreeMap<>();
376 Map<ServerName, Integer> primaryRegDistribution = new TreeMap<>();
377 List<HRegionLocation> regions = r.getAllRegionLocations();
378 Map<HRegionInfo, RegionLoad> regionsToLoad = new LinkedHashMap<>();
379 Map<HRegionInfo, ServerName> regionsToServer = new LinkedHashMap<>();
380 for (HRegionLocation hriEntry : regions) {
381 HRegionInfo regionInfo = hriEntry.getRegionInfo();
382 ServerName addr = hriEntry.getServerName();
383 regionsToServer.put(regionInfo, addr);
385 if (addr != null) {
386 ServerLoad sl = master.getServerManager().getLoad(addr);
387 if (sl != null) {
388 Map<byte[], RegionLoad> map = sl.getRegionsLoad();
389 RegionLoad regionload = map.get(regionInfo.getRegionName());
390 regionsToLoad.put(regionInfo, regionload);
391 if(regionload != null) {
392 totalReadReq += regionload.getReadRequestsCount();
393 totalWriteReq += regionload.getWriteRequestsCount();
394 totalSize += regionload.getStorefileSizeMB();
395 totalStoreFileCount += regionload.getStorefiles();
396 totalMemSize += regionload.getMemStoreSizeMB();
397 totalStoreFileSizeMB += regionload.getStorefileSizeMB();
398 } else {
399 RegionLoad load0 = getEmptyRegionLoad(regionInfo);
400 regionsToLoad.put(regionInfo, load0);
402 } else{
403 RegionLoad load0 = getEmptyRegionLoad(regionInfo);
404 regionsToLoad.put(regionInfo, load0);
406 } else {
407 RegionLoad load0 = getEmptyRegionLoad(regionInfo);
408 regionsToLoad.put(regionInfo, load0);
412 if(regions != null && regions.size() > 0) { %>
413 <h2>Table Regions</h2>
414 Sort As
415 <select id="sel" style="margin-right: 10px">
416 <option value="regionName">RegionName</option>
417 <option value="readrequest">ReadRequest</option>
418 <option value="writerequest">WriteRequest</option>
419 <option value="size">StorefileSize</option>
420 <option value="filecount">Num.Storefiles</option>
421 <option value="memstore">MemstoreSize</option>
422 <option value="locality">Locality</option>
423 </select>
424 Ascending<input type="checkbox" id="ascending" value="Ascending" style="margin-right:10px">
425 ShowDetailName&Start/End Key<input type="checkbox" id="showWhole" style="margin-right:10px">
426 <input type="button" id="submit" value="Reorder" onClick="reloadAsSort()" style="font-size: 12pt; width: 5em; margin-bottom: 5px" class="btn">
429 <table class="table table-striped">
430 <tr>
431 <th>Name(<%= String.format("%,1d", regions.size())%>)</th>
432 <th>Region Server</th>
433 <th>ReadRequests<br>(<%= String.format("%,1d", totalReadReq)%>)</th>
434 <th>WriteRequests<br>(<%= String.format("%,1d", totalWriteReq)%>)</th>
435 <th>StorefileSize<br>(<%= StringUtils.byteDesc(totalSize*1024l*1024)%>)</th>
436 <th>Num.Storefiles<br>(<%= String.format("%,1d", totalStoreFileCount)%>)</th>
437 <th>MemSize<br>(<%= StringUtils.byteDesc(totalMemSize*1024l*1024)%>)</th>
438 <th>Locality</th>
439 <th>Start Key</th>
440 <th>End Key</th>
442 if (withReplica) {
444 <th>ReplicaID</th>
448 </tr>
451 List<Map.Entry<HRegionInfo, RegionLoad>> entryList = new ArrayList<>(regionsToLoad.entrySet());
452 if(sortKey != null) {
453 if (sortKey.equals("readrequest")) {
454 Collections.sort(entryList,
455 new Comparator<Map.Entry<HRegionInfo, RegionLoad>>() {
456 public int compare(
457 Map.Entry<HRegionInfo, RegionLoad> entry1,
458 Map.Entry<HRegionInfo, RegionLoad> entry2) {
459 if (entry1 == null || entry1.getValue() == null) {
460 return -1;
461 } else if (entry2 == null || entry2.getValue() == null) {
462 return 1;
464 int result = 0;
465 if (entry1.getValue().getReadRequestsCount() < entry2.getValue().getReadRequestsCount()) {
466 result = -1;
467 } else if (entry1.getValue().getReadRequestsCount() > entry2.getValue().getReadRequestsCount()) {
468 result = 1;
470 if (reverseOrder) {
471 result = -1 * result;
473 return result;
476 } else if (sortKey.equals("writerequest")) {
477 Collections.sort(entryList,
478 new Comparator<Map.Entry<HRegionInfo, RegionLoad>>() {
479 public int compare(
480 Map.Entry<HRegionInfo, RegionLoad> entry1,
481 Map.Entry<HRegionInfo, RegionLoad> entry2) {
482 if (entry1 == null || entry1.getValue() == null) {
483 return -1;
484 } else if (entry2 == null || entry2.getValue() == null) {
485 return 1;
487 int result = 0;
488 if (entry1.getValue().getWriteRequestsCount() < entry2.getValue()
489 .getWriteRequestsCount()) {
490 result = -1;
491 } else if (entry1.getValue().getWriteRequestsCount() > entry2.getValue()
492 .getWriteRequestsCount()) {
493 result = 1;
495 if (reverseOrder) {
496 result = -1 * result;
498 return result;
501 } else if (sortKey.equals("size")) {
502 Collections.sort(entryList,
503 new Comparator<Map.Entry<HRegionInfo, RegionLoad>>() {
504 public int compare(
505 Map.Entry<HRegionInfo, RegionLoad> entry1,
506 Map.Entry<HRegionInfo, RegionLoad> entry2) {
507 if (entry1 == null || entry1.getValue() == null) {
508 return -1;
509 } else if (entry2 == null || entry2.getValue() == null) {
510 return 1;
512 int result = 0;
513 if (entry1.getValue().getStorefileSizeMB() < entry2.getValue()
514 .getStorefileSizeMB()) {
515 result = -1;
516 } else if (entry1.getValue().getStorefileSizeMB() > entry2
517 .getValue().getStorefileSizeMB()) {
518 result = 1;
520 if (reverseOrder) {
521 result = -1 * result;
523 return result;
526 } else if (sortKey.equals("filecount")) {
527 Collections.sort(entryList,
528 new Comparator<Map.Entry<HRegionInfo, RegionLoad>>() {
529 public int compare(
530 Map.Entry<HRegionInfo, RegionLoad> entry1,
531 Map.Entry<HRegionInfo, RegionLoad> entry2) {
532 if (entry1 == null || entry1.getValue() == null) {
533 return -1;
534 } else if (entry2 == null || entry2.getValue() == null) {
535 return 1;
537 int result = 0;
538 if (entry1.getValue().getStorefiles() < entry2.getValue()
539 .getStorefiles()) {
540 result = -1;
541 } else if (entry1.getValue().getStorefiles() > entry2.getValue()
542 .getStorefiles()) {
543 result = 1;
545 if (reverseOrder) {
546 result = -1 * result;
548 return result;
551 } else if (sortKey.equals("memstore")) {
552 Collections.sort(entryList,
553 new Comparator<Map.Entry<HRegionInfo, RegionLoad>>() {
554 public int compare(
555 Map.Entry<HRegionInfo, RegionLoad> entry1,
556 Map.Entry<HRegionInfo, RegionLoad> entry2) {
557 if (entry1 == null || entry1.getValue()==null) {
558 return -1;
559 } else if (entry2 == null || entry2.getValue()==null) {
560 return 1;
562 int result = 0;
563 if (entry1.getValue().getMemStoreSizeMB() < entry2.getValue()
564 .getMemStoreSizeMB()) {
565 result = -1;
566 } else if (entry1.getValue().getMemStoreSizeMB() > entry2
567 .getValue().getMemStoreSizeMB()) {
568 result = 1;
570 if (reverseOrder) {
571 result = -1 * result;
573 return result;
576 } else if (sortKey.equals("locality")) {
577 Collections.sort(entryList,
578 new Comparator<Map.Entry<HRegionInfo, RegionLoad>>() {
579 public int compare(
580 Map.Entry<HRegionInfo, RegionLoad> entry1,
581 Map.Entry<HRegionInfo, RegionLoad> entry2) {
582 if (entry1 == null || entry1.getValue()==null) {
583 return -1;
584 } else if (entry2 == null || entry2.getValue()==null) {
585 return 1;
587 int result = 0;
588 if (entry1.getValue().getDataLocality() < entry2.getValue()
589 .getDataLocality()) {
590 result = -1;
591 } else if (entry1.getValue().getDataLocality() > entry2
592 .getValue().getDataLocality()) {
593 result = 1;
595 if (reverseOrder) {
596 result = -1 * result;
598 return result;
603 numRegions = regions.size();
604 int numRegionsRendered = 0;
605 // render all regions
606 if (numRegionsToRender < 0) {
607 numRegionsToRender = numRegions;
609 for (Map.Entry<HRegionInfo, RegionLoad> hriEntry : entryList) {
610 HRegionInfo regionInfo = hriEntry.getKey();
611 ServerName addr = regionsToServer.get(regionInfo);
612 RegionLoad load = hriEntry.getValue();
613 String readReq = "N/A";
614 String writeReq = "N/A";
615 String regionSize = "N/A";
616 String fileCount = "N/A";
617 String memSize = "N/A";
618 float locality = 0.0f;
619 if(load != null) {
620 readReq = String.format("%,1d", load.getReadRequestsCount());
621 writeReq = String.format("%,1d", load.getWriteRequestsCount());
622 regionSize = StringUtils.byteDesc(load.getStorefileSizeMB()*1024l*1024);
623 fileCount = String.format("%,1d", load.getStorefiles());
624 memSize = StringUtils.byteDesc(load.getMemStoreSizeMB()*1024l*1024);
625 locality = load.getDataLocality();
628 if (addr != null) {
629 ServerLoad sl = master.getServerManager().getLoad(addr);
630 // This port might be wrong if RS actually ended up using something else.
631 urlRegionServer =
632 "//" + URLEncoder.encode(addr.getHostname()) + ":" + master.getRegionServerInfoPort(addr) + "/";
633 if(sl != null) {
634 Integer i = regDistribution.get(addr);
635 if (null == i) i = Integer.valueOf(0);
636 regDistribution.put(addr, i + 1);
637 if (withReplica && RegionReplicaUtil.isDefaultReplica(regionInfo.getReplicaId())) {
638 i = primaryRegDistribution.get(addr);
639 if (null == i) i = Integer.valueOf(0);
640 primaryRegDistribution.put(addr, i+1);
644 if (numRegionsRendered < numRegionsToRender) {
645 numRegionsRendered++;
647 <tr>
648 <td><%= escapeXml(showWhole?Bytes.toStringBinary(regionInfo.getRegionName()):regionInfo.getEncodedName()) %></td>
650 if (urlRegionServer != null) {
652 <td>
653 <a href="<%= urlRegionServer %>"><%= StringEscapeUtils.escapeHtml(addr.getHostname().toString()) + ":" + master.getRegionServerInfoPort(addr) %></a>
654 </td>
656 } else {
658 <td class="undeployed-region">not deployed</td>
662 <td><%= readReq%></td>
663 <td><%= writeReq%></td>
664 <td><%= regionSize%></td>
665 <td><%= fileCount%></td>
666 <td><%= memSize%></td>
667 <td><%= locality%></td>
668 <td><%= escapeXml(showWhole?Bytes.toStringBinary(regionInfo.getStartKey()):"-")%></td>
669 <td><%= escapeXml(showWhole?Bytes.toStringBinary(regionInfo.getEndKey()):"-")%></td>
671 if (withReplica) {
673 <td><%= regionInfo.getReplicaId() %></td>
677 </tr>
678 <% } %>
679 <% } %>
680 </table>
681 <% if (numRegions > numRegionsRendered) {
682 String allRegionsUrl = "?name=" + URLEncoder.encode(fqtn,"UTF-8") + "&numRegions=all";
684 <p>This table has <b><%= numRegions %></b> regions in total, in order to improve the page load time,
685 only <b><%= numRegionsRendered %></b> regions are displayed here, <a href="<%= allRegionsUrl %>">click
686 here</a> to see all regions.</p>
687 <% } %>
688 <h2>Regions by Region Server</h2>
690 if (withReplica) {
692 <table class="table table-striped"><tr><th>Region Server</th><th>Region Count</th><th>Primary Region Count</th></tr>
694 } else {
696 <table class="table table-striped"><tr><th>Region Server</th><th>Region Count</th></tr>
701 for (Map.Entry<ServerName, Integer> rdEntry : regDistribution.entrySet()) {
702 ServerName addr = rdEntry.getKey();
703 String url = "//" + URLEncoder.encode(addr.getHostname()) + ":" + master.getRegionServerInfoPort(addr) + "/";
705 <tr>
706 <td><a href="<%= url %>"><%= StringEscapeUtils.escapeHtml(addr.getHostname().toString()) + ":" + master.getRegionServerInfoPort(addr) %></a></td>
707 <td><%= rdEntry.getValue()%></td>
709 if (withReplica) {
711 <td><%= primaryRegDistribution.get(addr)%></td>
715 </tr>
716 <% } %>
717 </table>
718 <% }
719 } catch(Exception ex) {
720 for(StackTraceElement element : ex.getStackTrace()) {
721 %><%= StringEscapeUtils.escapeHtml(element.toString()) %><%
723 } finally {
724 admin.close();
726 } // end else
729 <h2>Table Stats</h2>
730 <table class="table table-striped">
731 <tr>
732 <th>Name</th>
733 <th>Value</th>
734 <th>Description</th>
735 </tr>
736 <tr>
737 <td>Size</td>
738 <td><%= StringUtils.TraditionalBinaryPrefix.long2String(totalStoreFileSizeMB * 1024 * 1024, "B", 2)%></td>
739 <td>Total size of store files (in bytes)</td>
740 </tr>
741 </table>
743 <% if (!readOnly) { %>
744 <p><hr/></p>
745 Actions:
747 <center>
748 <table class="table" width="95%" >
749 <tr>
750 <form method="get">
751 <input type="hidden" name="action" value="compact">
752 <input type="hidden" name="name" value="<%= escaped_fqtn %>">
753 <td style="border-style: none; text-align: center">
754 <input style="font-size: 12pt; width: 10em" type="submit" value="Compact" class="btn"></td>
755 <td style="border-style: none" width="5%">&nbsp;</td>
756 <td style="border-style: none">Row Key (optional):<input type="text" name="key" size="40"></td>
757 <td style="border-style: none">This action will force a compaction of all
758 regions of the table, or, if a key is supplied, only the region containing the
759 given key.</td>
760 </form>
761 </tr>
762 <tr><td style="border-style: none" colspan="4">&nbsp;</td></tr>
763 <tr>
764 <form method="get">
765 <input type="hidden" name="action" value="split">
766 <input type="hidden" name="name" value="<%= escaped_fqtn %>">
767 <td style="border-style: none; text-align: center">
768 <input style="font-size: 12pt; width: 10em" type="submit" value="Split" class="btn"></td>
769 <td style="border-style: none" width="5%">&nbsp;</td>
770 <td style="border-style: none">Row Key (optional):<input type="text" name="key" size="40"></td>
771 <td style="border-style: none">This action will force a split of all eligible
772 regions of the table, or, if a key is supplied, only the region containing the
773 given key. An eligible region is one that does not contain any references to
774 other regions. Split requests for noneligible regions will be ignored.</td>
775 </form>
776 </tr>
777 <tr>
778 <form method="get">
779 <input type="hidden" name="action" value="merge">
780 <input type="hidden" name="name" value="<%= escaped_fqtn %>">
781 <td style="border-style: none; text-align: center">
782 <input style="font-size: 12pt; width: 10em" type="submit" value="Merge" class="btn"></td>
783 <td style="border-style: none" width="5%">&nbsp;</td>
784 <td style="border-style: none">Region Key (Required):<input type="text" name="left" size="40">
785 Region Key (Required) :<input type="text" name="right" size="40"></td>
786 <td style="border-style: none">This action will merge two
787 regions of the table, Merge requests for noneligible regions will be ignored.</td>
788 </form>
789 </tr>
790 </table>
791 </center>
792 </p>
793 <% } %>
794 </div>
795 </div>
796 <% }
797 } catch(TableNotFoundException e) { %>
798 <div class="container-fluid content">
799 <div class="row inner_header">
800 <div class="page-header">
801 <h1>Table not found</h1>
802 </div>
803 </div>
804 <p><hr><p>
805 <p>Go <a href="javascript:history.back()">Back</a>
806 </div> <%
807 } catch(IllegalArgumentException e) { %>
808 <div class="container-fluid content">
809 <div class="row inner_header">
810 <div class="page-header">
811 <h1>Table qualifier must not be empty</h1>
812 </div>
813 </div>
814 <p><hr><p>
815 <p>Go <a href="javascript:history.back()">Back</a>
816 </div> <%
819 else { // handle the case for fqtn is null with error message + redirect
821 <div class="container-fluid content">
822 <div class="row inner_header">
823 <div class="page-header">
824 <h1>Table not ready</h1>
825 </div>
826 </div>
827 <p><hr><p>
828 <p>Go <a href="javascript:history.back()">Back</a>, or wait for the redirect.
829 </div>
830 <% } %>
831 <script src="/static/js/jquery.min.js" type="text/javascript"></script>
832 <script src="/static/js/bootstrap.min.js" type="text/javascript"></script>
834 </body>
835 </html>
837 <script>
838 var index=0;
839 var sortKeyValue='<%= StringEscapeUtils.escapeJavaScript(sortKey) %>';
840 if(sortKeyValue=="readrequest")index=1;
841 else if(sortKeyValue=="writerequest")index=2;
842 else if(sortKeyValue=="size")index=3;
843 else if(sortKeyValue=="filecount")index=4;
844 else if(sortKeyValue=="memstore")index=5;
845 else if(sortKeyValue=="locality")index=6;
846 document.getElementById("sel").selectedIndex=index;
848 <% // turned into a boolean when we pulled it out of the request. %>
849 var reverse='<%= reverseOrder %>';
850 if(reverse=='false')document.getElementById("ascending").checked=true;
852 <% // turned into a boolean when we pulled it out of the request. %>
853 var showWhole='<%= showWhole %>';
854 if(showWhole=='true')document.getElementById("showWhole").checked=true;
856 function reloadAsSort(){
857 var url="?name="+'<%= URLEncoder.encode(fqtn) %>';
858 if(document.getElementById("sel").selectedIndex>0){
859 url=url+"&sort="+document.getElementById("sel").value;
861 if(document.getElementById("ascending").checked){
862 url=url+"&reverse=false";
864 if(document.getElementById("showWhole").checked){
865 url=url+"&showwhole=true";
867 location.href=url;
869 </script>