Skip to content

Commit 2e0311a

Browse files
committed
Use tableId as key for data used in table page
1 parent 9bf9f29 commit 2e0311a

File tree

7 files changed

+68
-51
lines changed

7 files changed

+68
-51
lines changed

server/monitor/src/main/java/org/apache/accumulo/monitor/next/Endpoints.java

+14-11
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import org.apache.accumulo.core.client.admin.TabletInformation;
4545
import org.apache.accumulo.core.client.admin.servers.ServerId;
4646
import org.apache.accumulo.core.compaction.thrift.TExternalCompaction;
47+
import org.apache.accumulo.core.data.TableId;
4748
import org.apache.accumulo.core.metrics.flatbuffers.FMetric;
4849
import org.apache.accumulo.core.process.thrift.MetricResponse;
4950
import org.apache.accumulo.monitor.Monitor;
@@ -313,31 +314,33 @@ public List<TExternalCompaction> getCompactions(@PathParam("group") String resou
313314
@GET
314315
@Path("tables")
315316
@Produces(MediaType.APPLICATION_JSON)
316-
@Description("Returns a map of table name to table details")
317-
public Map<String,TableSummary> getTables() {
317+
@Description("Returns a map of TableId to table details")
318+
public Map<TableId,TableSummary> getTables() {
318319
return monitor.getInformationFetcher().getSummary().getTables();
319320
}
320321

321322
@GET
322-
@Path("tables/{name}")
323+
@Path("tables/{tableId}")
323324
@Produces(MediaType.APPLICATION_JSON)
324-
@Description("Returns table details for the supplied table name")
325-
public TableSummary getTable(@PathParam("name") String tableName) {
326-
TableSummary ts = monitor.getInformationFetcher().getSummary().getTables().get(tableName);
325+
@Description("Returns table details for the supplied TableId")
326+
public TableSummary getTable(@PathParam("tableId") String tableId) {
327+
TableSummary ts =
328+
monitor.getInformationFetcher().getSummary().getTables().get(TableId.of(tableId));
327329
if (ts == null) {
328-
throw new NotFoundException(tableName + " not found");
330+
throw new NotFoundException(tableId + " not found");
329331
}
330332
return ts;
331333
}
332334

333335
@GET
334-
@Path("tables/{name}/tablets")
336+
@Path("tables/{tableId}/tablets")
335337
@Produces(MediaType.APPLICATION_JSON)
336338
@Description("Returns tablet details for the supplied table name")
337-
public List<TabletInformation> getTablets(@PathParam("name") String tableName) {
338-
List<TabletInformation> ti = monitor.getInformationFetcher().getSummary().getTablets(tableName);
339+
public List<TabletInformation> getTablets(@PathParam("tableId") String tableId) {
340+
List<TabletInformation> ti =
341+
monitor.getInformationFetcher().getSummary().getTablets(TableId.of(tableId));
339342
if (ti == null) {
340-
throw new NotFoundException(tableName + " not found");
343+
throw new NotFoundException(tableId + " not found");
341344
}
342345
return ti;
343346
}

server/monitor/src/main/java/org/apache/accumulo/monitor/next/InformationFetcher.java

+15-13
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import org.apache.accumulo.core.compaction.thrift.TExternalCompactionList;
4444
import org.apache.accumulo.core.conf.Property;
4545
import org.apache.accumulo.core.data.Range;
46+
import org.apache.accumulo.core.data.TableId;
4647
import org.apache.accumulo.core.process.thrift.MetricResponse;
4748
import org.apache.accumulo.core.process.thrift.ServerProcessService.Client;
4849
import org.apache.accumulo.core.rpc.ThriftUtil;
@@ -139,27 +140,28 @@ public void run() {
139140

140141
private class TableInformationFetcher implements Runnable {
141142
private final ServerContext ctx;
142-
private final String table;
143+
private final TableId tableId;
143144
private final SystemInformation summary;
144145

145-
private TableInformationFetcher(ServerContext ctx, String tableName,
146-
SystemInformation summary) {
146+
private TableInformationFetcher(ServerContext ctx, TableId tableId, SystemInformation summary) {
147147
this.ctx = ctx;
148-
this.table = tableName;
148+
this.tableId = tableId;
149149
this.summary = summary;
150150
}
151151

152152
@Override
153153
public void run() {
154-
try (Stream<TabletInformation> tablets =
155-
this.ctx.tableOperations().getTabletInformation(table, new Range())) {
156-
tablets.forEach(t -> summary.processTabletInformation(table, t));
154+
try {
155+
final String tableName = ctx.getTableName(tableId);
156+
try (Stream<TabletInformation> tablets =
157+
this.ctx.tableOperations().getTabletInformation(tableName, new Range())) {
158+
tablets.forEach(t -> summary.processTabletInformation(tableId, tableName, t));
159+
}
157160
} catch (TableNotFoundException e) {
158-
LOG.warn(
159-
"TableNotFoundException thrown while trying to gather information for table: " + table,
160-
e);
161+
LOG.warn("TableNotFoundException thrown while trying to gather information for TableId: {}",
162+
tableId, e);
161163
} catch (Exception e) {
162-
LOG.warn("Interrupted while trying to gather information for table: {}", table, e);
164+
LOG.warn("Interrupted while trying to gather information for TableId: {}", tableId, e);
163165
}
164166
}
165167
}
@@ -292,8 +294,8 @@ public void run() {
292294
futures.add(this.pool.submit(new CompactionListFetcher(summary)));
293295

294296
// Fetch Tablet / Tablet information from the metadata table
295-
for (String tName : this.ctx.tableOperations().list()) {
296-
futures.add(this.pool.submit(new TableInformationFetcher(this.ctx, tName, summary)));
297+
for (TableId tableId : this.ctx.getTableNameToIdMap().values()) {
298+
futures.add(this.pool.submit(new TableInformationFetcher(this.ctx, tableId, summary)));
297299
}
298300

299301
long monitorFetchTimeout =

server/monitor/src/main/java/org/apache/accumulo/monitor/next/SystemInformation.java

+18-8
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import org.apache.accumulo.core.client.admin.servers.ServerId;
4141
import org.apache.accumulo.core.compaction.thrift.TExternalCompaction;
4242
import org.apache.accumulo.core.compaction.thrift.TExternalCompactionList;
43+
import org.apache.accumulo.core.data.TableId;
4344
import org.apache.accumulo.core.data.TabletId;
4445
import org.apache.accumulo.core.dataImpl.KeyExtent;
4546
import org.apache.accumulo.core.dataImpl.TabletIdImpl;
@@ -154,6 +155,11 @@ public static class TableSummary {
154155
private final AtomicLong totalHostedTablets = new AtomicLong();
155156
private final AtomicLong totalSuspendedTablets = new AtomicLong();
156157
private final AtomicLong totalUnassignedTablets = new AtomicLong();
158+
private String tableName;
159+
160+
public TableSummary(String tableName) {
161+
this.tableName = tableName;
162+
}
157163

158164
public long getTotalEntries() {
159165
return totalEntries.get();
@@ -207,6 +213,10 @@ public long getTotalUnassignedTablets() {
207213
return totalUnassignedTablets.get();
208214
}
209215

216+
public String getTableName() {
217+
return tableName;
218+
}
219+
210220
public void addTablet(TabletInformation info) {
211221
totalEntries.addAndGet(info.getEstimatedEntries());
212222
totalSizeOnDisk.addAndGet(info.getEstimatedSize());
@@ -327,8 +337,8 @@ public Set<String> getNotRespondedHosts() {
327337
new AtomicReference<>();
328338

329339
// Table Information
330-
private final Map<String,TableSummary> tables = new ConcurrentHashMap<>();
331-
private final Map<String,List<TabletInformation>> tablets = new ConcurrentHashMap<>();
340+
private final Map<TableId,TableSummary> tables = new ConcurrentHashMap<>();
341+
private final Map<TableId,List<TabletInformation>> tablets = new ConcurrentHashMap<>();
332342

333343
// Deployment Overview
334344
private final Map<String,Map<String,ProcessSummary>> deployment = new ConcurrentHashMap<>();
@@ -460,11 +470,11 @@ public void processExternalCompactionList(Map<String,TExternalCompactionList> ru
460470
oldestCompactions.set(running);
461471
}
462472

463-
public void processTabletInformation(String tableName, TabletInformation info) {
473+
public void processTabletInformation(TableId tableId, String tableName, TabletInformation info) {
464474
final SanitizedTabletInformation sti = new SanitizedTabletInformation(info);
465-
tablets.computeIfAbsent(tableName, (t) -> Collections.synchronizedList(new ArrayList<>()))
475+
tablets.computeIfAbsent(tableId, (t) -> Collections.synchronizedList(new ArrayList<>()))
466476
.add(sti);
467-
tables.computeIfAbsent(tableName, (t) -> new TableSummary()).addTablet(sti);
477+
tables.computeIfAbsent(tableId, (t) -> new TableSummary(tableName)).addTablet(sti);
468478
if (sti.getEstimatedEntries() == 0) {
469479
suggestions.add("Tablet " + sti.getTabletId().toString() + " (tid: "
470480
+ sti.getTabletId().getTable() + ") may have zero entries and could be merged.");
@@ -582,12 +592,12 @@ public List<TExternalCompaction> getCompactions(String group) {
582592
return list.getCompactions();
583593
}
584594

585-
public Map<String,TableSummary> getTables() {
595+
public Map<TableId,TableSummary> getTables() {
586596
return this.tables;
587597
}
588598

589-
public List<TabletInformation> getTablets(String table) {
590-
return this.tablets.get(table);
599+
public List<TabletInformation> getTablets(TableId tableId) {
600+
return this.tablets.get(tableId);
591601
}
592602

593603
public Map<String,Map<String,ProcessSummary>> getDeploymentOverview() {

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

+9-7
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
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;
2223
import static org.apache.accumulo.monitor.util.ParameterValidator.HOSTNAME_PORT_REGEX;
2324

2425
import java.io.IOException;
@@ -42,6 +43,7 @@
4243
import org.apache.accumulo.core.client.TableNotFoundException;
4344
import org.apache.accumulo.core.conf.AccumuloConfiguration;
4445
import org.apache.accumulo.core.conf.Property;
46+
import org.apache.accumulo.core.data.TableId;
4547
import org.apache.accumulo.monitor.Monitor;
4648
import org.glassfish.jersey.server.mvc.Template;
4749
import org.slf4j.Logger;
@@ -277,24 +279,24 @@ public Map<String,Object> getTables() {
277279
/**
278280
* Returns participating tservers template
279281
*
280-
* @param tableID Table ID for participating tservers
282+
* @param tableId Table ID for participating tservers
281283
* @return Participating tservers model
282284
*/
283285
@GET
284-
@Path("tables/{tableID}")
286+
@Path("tables/{tableId}")
285287
@Template(name = "/default.ftl")
286-
public Map<String,Object> getTables(@PathParam("tableID") @NotNull String tableID)
288+
public Map<String,Object> getTables(
289+
@PathParam("tableId") @NotNull @Pattern(regexp = ALPHA_NUM_REGEX_TABLE_ID) String tableId)
287290
throws TableNotFoundException {
288-
// TODO: switched to use tablename as param. switch back to tableID
289-
// String tableName = monitor.getContext().getTableName(TableId.of(tableID));
291+
String tableName = monitor.getContext().getTableName(TableId.of(tableId));
290292

291293
Map<String,Object> model = getModel();
292294
model.put("title", "Table Status");
293295

294296
model.put("template", "table.ftl");
295297
model.put("js", "table.js");
296-
model.put("tableID", tableID);
297-
model.put("table", tableID);
298+
model.put("tableId", tableId);
299+
model.put("table", tableName);
298300

299301
return model;
300302
}

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ function refresh() {
3838
/**
3939
* Makes the REST call to fetch tablet details and render them.
4040
*/
41-
function initTabletsTable(tableID) {
42-
var tabletsUrl = '/rest-v2/tables/' + tableID + '/tablets';
41+
function initTabletsTable(tableId) {
42+
var tabletsUrl = '/rest-v2/tables/' + tableId + '/tablets';
4343
console.debug('Fetching tablets info from: ' + tabletsUrl);
4444

4545
tabletsTable = $('#tabletsList').DataTable({
@@ -83,10 +83,10 @@ function initTabletsTable(tableID) {
8383
/**
8484
* Initialize the table
8585
*
86-
* @param {String} tableID the accumulo table ID
86+
* @param {String} tableId the accumulo table ID
8787
*/
88-
function initTableServerTable(tableID) {
89-
const url = '/rest-v2/tables/' + tableID;
88+
function initTableServerTable(tableId) {
89+
const url = '/rest-v2/tables/' + tableId;
9090
console.debug('REST url used to fetch summary data: ' + url);
9191

9292
tableServersTable = $('#participatingTServers').DataTable({
@@ -163,5 +163,5 @@ function initTableServerTable(tableID) {
163163
});
164164

165165
refreshTable();
166-
initTabletsTable(tableID);
166+
initTabletsTable(tableId);
167167
}

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
-->
2121
<script>
2222
/**
23-
* Creates participating Tservers initial table, passes the tableID from the template
23+
* Creates participating Tservers initial table, passes the tableId from the template
2424
*/
2525
$(function () {
26-
initTableServerTable('${table}');
26+
initTableServerTable('${tableId}');
2727
});
2828
</script>
2929
<div class="row">
@@ -60,8 +60,8 @@
6060
<!-- Section for tablets details DataTable -->
6161
<div class="row">
6262
<div class="col-xs-12">
63-
<caption><span class="table-caption">Tablet Details</span></caption>
6463
<table id="tabletsList" class="table caption-top table-bordered table-striped table-condensed">
64+
<caption><span class="table-caption">Tablet Details</span></caption>
6565
<thead>
6666
<tr>
6767
<th>Tablet ID</th>

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"url": "/rest-v2/tables",
3333
"dataSrc": function (json) {
3434
return Object.keys(json).map(function (key) {
35-
json[key].tablename = key;
35+
json[key].tableId = key;
3636
return json[key];
3737
});
3838
}
@@ -51,11 +51,11 @@
5151
],
5252
"columns": [
5353
{
54-
"data": "tablename",
54+
"data": "tableName",
5555
"type": "html",
5656
"render": function (data, type, row, meta) {
5757
if (type === 'display') {
58-
data = '<a href="/tables/' + row.tablename + '">' + row.tablename + '</a>';
58+
data = '<a href="/tables/' + row.tableId + '">' + row.tableName + '</a>';
5959
}
6060
return data;
6161
}

0 commit comments

Comments
 (0)