Skip to content

Commit ede7391

Browse files
committed
Use new REST api for tables page
1 parent bf61fac commit ede7391

File tree

3 files changed

+124
-107
lines changed

3 files changed

+124
-107
lines changed

server/monitor/src/main/java/org/apache/accumulo/monitor/view/WebViews.java

+4-7
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
package org.apache.accumulo.monitor.view;
2020

2121
import static org.apache.accumulo.monitor.util.ParameterValidator.ALPHA_NUM_REGEX_BLANK_OK;
22-
import static org.apache.accumulo.monitor.util.ParameterValidator.ALPHA_NUM_REGEX_TABLE_ID;
2322
import static org.apache.accumulo.monitor.util.ParameterValidator.HOSTNAME_PORT_REGEX;
2423

2524
import java.io.IOException;
@@ -43,7 +42,6 @@
4342
import org.apache.accumulo.core.client.TableNotFoundException;
4443
import org.apache.accumulo.core.conf.AccumuloConfiguration;
4544
import org.apache.accumulo.core.conf.Property;
46-
import org.apache.accumulo.core.data.TableId;
4745
import org.apache.accumulo.monitor.Monitor;
4846
import org.glassfish.jersey.server.mvc.Template;
4947
import org.slf4j.Logger;
@@ -285,19 +283,18 @@ public Map<String,Object> getTables() {
285283
@GET
286284
@Path("tables/{tableID}")
287285
@Template(name = "/default.ftl")
288-
public Map<String,Object> getTables(
289-
@PathParam("tableID") @NotNull @Pattern(regexp = ALPHA_NUM_REGEX_TABLE_ID) String tableID)
286+
public Map<String,Object> getTables(@PathParam("tableID") @NotNull String tableID)
290287
throws TableNotFoundException {
291-
292-
String tableName = monitor.getContext().getTableName(TableId.of(tableID));
288+
// TODO: switched to use tablename as param. switch back to tableID
289+
// String tableName = monitor.getContext().getTableName(TableId.of(tableID));
293290

294291
Map<String,Object> model = getModel();
295292
model.put("title", "Table Status");
296293

297294
model.put("template", "table.ftl");
298295
model.put("js", "table.js");
299296
model.put("tableID", tableID);
300-
model.put("table", tableName);
297+
model.put("table", tableID);
301298

302299
return model;
303300
}

server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/table.js

+85-87
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"use strict";
2020

2121
var tableServersTable;
22+
var tabletsTable;
2223

2324
/**
2425
* Makes the REST calls, generates the tables with the new information
@@ -34,136 +35,133 @@ function refresh() {
3435
refreshTable();
3536
}
3637

37-
function getQueuedAndRunning(data) {
38-
return `${data.running}(${data.queued})`;
39-
}
40-
4138
/**
42-
* Initialize the table
43-
*
44-
* @param {String} tableID the accumulo table ID
39+
* Makes the REST call to fetch tablet details and render them.
4540
*/
46-
function initTableServerTable(tableID) {
41+
function initTabletsTable(tableID) {
42+
var tabletsUrl = '/rest-v2/tables/' + tableID + '/tablets';
43+
console.debug('Fetching tablets info from: ' + tabletsUrl);
4744

48-
const url = '/rest/tables/' + tableID;
49-
console.debug('REST url used to fetch data for table.js DataTable: ' + url);
50-
51-
tableServersTable = $('#participatingTServers').DataTable({
45+
tabletsTable = $('#tabletsList').DataTable({
5246
"ajax": {
53-
"url": url,
54-
"dataSrc": "servers"
47+
"url": tabletsUrl,
48+
"dataSrc": ""
5549
},
56-
"stateSave": true,
57-
"columnDefs": [{
58-
"targets": "big-num",
59-
"render": function (data, type) {
60-
if (type === 'display') {
61-
data = bigNumberForQuantity(data);
62-
}
63-
return data;
64-
}
65-
},
66-
{
67-
"targets": "duration",
68-
"render": function (data, type) {
69-
if (type === 'display') {
70-
data = timeDuration(data);
71-
}
72-
return data;
73-
}
50+
"columns": [{
51+
"data": "tabletId",
52+
"title": "Tablet ID"
7453
},
7554
{
76-
"targets": "percent",
77-
"render": function (data, type) {
78-
if (type === 'display') {
79-
data = Math.round(data * 100) + '%';
80-
}
81-
return data;
82-
}
55+
"data": "estimatedSize",
56+
"title": "Estimated Size"
8357
},
84-
// ensure these 3 columns are sorted by the 2 numeric values that comprise the combined string
85-
// instead of sorting them lexicographically by the string itself.
86-
// Specifically: 'targets' column will use the values in the 'orderData' columns
87-
88-
// scan column will be sorted by number of running, then by number of queued
8958
{
90-
"targets": [7],
91-
"type": "numeric",
92-
"orderData": [13, 14]
59+
"data": "estimatedEntries",
60+
"title": "Estimated Entries"
9361
},
94-
// minor compaction column will be sorted by number of running, then by number of queued
9562
{
96-
"targets": [8],
97-
"type": "numeric",
98-
"orderData": [15, 16]
99-
},
100-
],
101-
"columns": [{
102-
"data": "hostname",
103-
"type": "html",
104-
"render": function (data, type, row) {
105-
if (type === 'display') {
106-
data = `<a href="/tservers?s=${row.id}">${data}</a>`;
107-
}
108-
return data;
109-
}
63+
"data": "tabletAvailability",
64+
"title": "Availability"
11065
},
11166
{
112-
"data": "tablets"
67+
"data": "numFiles",
68+
"title": "Files"
11369
},
11470
{
115-
"data": "lastContact"
71+
"data": "numWalLogs",
72+
"title": "WALs"
11673
},
11774
{
118-
"data": "entries"
75+
"data": "location",
76+
"title": "Location"
77+
}
78+
],
79+
"stateSave": true
80+
});
81+
}
82+
83+
/**
84+
* Initialize the table
85+
*
86+
* @param {String} tableID the accumulo table ID
87+
*/
88+
function initTableServerTable(tableID) {
89+
const url = '/rest-v2/tables/' + tableID;
90+
console.debug('REST url used to fetch summary data: ' + url);
91+
92+
tableServersTable = $('#participatingTServers').DataTable({
93+
"ajax": {
94+
"url": url,
95+
"dataSrc": function (json) {
96+
// Convert the JSON object into an array for DataTables consumption.
97+
return [json];
98+
}
99+
},
100+
"columns": [{
101+
"data": "totalEntries",
102+
"title": "Entry Count"
119103
},
120104
{
121-
"data": "ingest"
105+
"data": "totalSizeOnDisk",
106+
"title": "Size on disk"
122107
},
123108
{
124-
"data": "query"
109+
"data": "totalFiles",
110+
"title": "File Count"
125111
},
126112
{
127-
"data": "holdtime"
113+
"data": "totalWals",
114+
"title": "WAL Count"
128115
},
129116
{
130-
"data": function (row) {
131-
return getQueuedAndRunning(row.compactions.scans);
132-
}
117+
"data": "totalTablets",
118+
"title": "Total Tablet Count"
133119
},
134120
{
135-
"data": function (row) {
136-
return getQueuedAndRunning(row.compactions.minor);
137-
}
121+
"data": "availableAlways",
122+
"title": "Always Hosted Count"
138123
},
139124
{
140-
"data": "indexCacheHitRate"
125+
"data": "availableOnDemand",
126+
"title": "On Demand Count"
141127
},
142128
{
143-
"data": "dataCacheHitRate"
129+
"data": "availableNever",
130+
"title": "Never Hosted Count"
144131
},
145132
{
146-
"data": "osload"
133+
"data": "totalAssignedTablets",
134+
"title": "Assigned Count"
147135
},
148136
{
149-
"data": "scansRunning",
150-
"visible": false
137+
"data": "totalAssignedToDeadServerTablets",
138+
"title": "AssignedToDeadServerTablets"
151139
},
152140
{
153-
"data": "scansQueued",
154-
"visible": false
141+
"data": "totalHostedTablets",
142+
"title": "HostedTablets"
155143
},
156144
{
157-
"data": "minorRunning",
158-
"visible": false
145+
"data": "totalSuspendedTablets",
146+
"title": "SuspendedTablets"
159147
},
160148
{
161-
"data": "minorQueued",
162-
"visible": false
149+
"data": "totalUnassignedTablets",
150+
"title": "UnassignedTablets"
163151
}
164-
]
152+
],
153+
"stateSave": true,
154+
"columnDefs": [{
155+
"targets": "big-num",
156+
"render": function (data, type) {
157+
if (type === 'display') {
158+
data = bigNumberForQuantity(data);
159+
}
160+
return data;
161+
}
162+
}]
165163
});
166164

167165
refreshTable();
168-
166+
initTabletsTable(tableID);
169167
}

server/monitor/src/main/resources/org/apache/accumulo/monitor/templates/table.ftl

+35-13
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* Creates participating Tservers initial table, passes the tableID from the template
2424
*/
2525
$(function () {
26-
initTableServerTable('${tableID}');
26+
initTableServerTable('${table}');
2727
});
2828
</script>
2929
<div class="row">
@@ -37,21 +37,43 @@
3737
<caption><span class="table-caption">${table}</span></caption>
3838
<thead>
3939
<tr>
40-
<th>Server&nbsp;</th>
41-
<th class="big-num">Hosted<br />Tablets&nbsp;</th>
42-
<th class="duration">Last&nbsp;Contact&nbsp;</th>
43-
<th class="big-num" title="Key/value pairs over each instance, table or tablet.">Entries&nbsp;</th>
44-
<th class="big-num" title="The number of Key/Value pairs inserted. (Note that deletes are considered inserted)">Ingest&nbsp;</th>
45-
<th class="big-num" title="The number of key/value pairs returned to clients. (Not the number of scans)">Query&nbsp;</th>
46-
<th class="duration" title="The amount of time live ingest operations (mutations, batch writes) have been waiting for the tserver to free up memory.">Hold&nbsp;Time&nbsp;</th>
47-
<th title="Information about the scans threads. Shows how many threads are running and, in parentheses, how much work is queued for the threads.">Scans&nbsp;</th>
48-
<th title="The action of flushing memory to disk. Multiple tablets can be compacted simultaneously, but sometimes they must wait for resources to be available. The number of tablets waiting for compaction is in parentheses.">Minor&nbsp;Compactions&nbsp;</th>
49-
<th class="percent" title="The recent index cache hit rate.">Index Cache<br />Hit Rate&nbsp;</th>
50-
<th class="percent" title="The recent data cache hit rate.">Data Cache<br />Hit Rate&nbsp;</th>
51-
<th class="big-num" title="The Unix one minute load average. The average number of processes in the run queue over a one minute interval.">OS&nbsp;Load&nbsp;</th>
40+
<th>Entry Count</th>
41+
<th>Size on disk</th>
42+
<th>File Count</th>
43+
<th>WAL Count</th>
44+
<th>Total Tablet Count</th>
45+
<th>Always Hosted Count</th>
46+
<th>On Demand Count</th>
47+
<th>Never Hosted Count</th>
48+
<th>Assigned Count</th>
49+
<th>Assigned To Dead Server Tablets</th>
50+
<th>Hosted Tablets</th>
51+
<th>Suspended Tablets</th>
52+
<th>Unassigned Tablets</th>
5253
</tr>
5354
</thead>
5455
<tbody></tbody>
5556
</table>
5657
</div>
5758
</div>
59+
<br><br>
60+
<!-- Section for tablets details DataTable -->
61+
<div class="row">
62+
<div class="col-xs-12">
63+
<caption><span class="table-caption">Tablet Details</span></caption>
64+
<table id="tabletsList" class="table caption-top table-bordered table-striped table-condensed">
65+
<thead>
66+
<tr>
67+
<th>Tablet ID</th>
68+
<th>Estimated Size</th>
69+
<th>Estimated Entries</th>
70+
<th>Availability</th>
71+
<th>Files</th>
72+
<th>WALs</th>
73+
<th>Location</th>
74+
</tr>
75+
</thead>
76+
<tbody></tbody>
77+
</table>
78+
</div>
79+
</div>

0 commit comments

Comments
 (0)