Skip to content

Commit ac95d60

Browse files
committed
Merge branch 'main' into accumulo-5160
2 parents f07af6e + b694d6c commit ac95d60

File tree

18 files changed

+1128
-992
lines changed

18 files changed

+1128
-992
lines changed

core/src/main/java/org/apache/accumulo/core/file/blockfile/impl/CachableBlockFile.java

+10-11
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646

4747
import com.github.benmanes.caffeine.cache.Cache;
4848

49+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
50+
4951
/**
5052
* This is a wrapper class for BCFile that includes a cache for independent caches for datablocks
5153
* and metadatablocks
@@ -331,6 +333,8 @@ public Map<String,Loader> getDependencies() {
331333
return Collections.emptyMap();
332334
}
333335

336+
@SuppressFBWarnings(value = {"NP_LOAD_OF_KNOWN_NULL_VALUE"},
337+
justification = "Spotbugs false positive, see spotbugs issue 2836.")
334338
@Override
335339
public byte[] load(int maxSize, Map<String,byte[]> dependencies) {
336340

@@ -345,23 +349,18 @@ public byte[] load(int maxSize, Map<String,byte[]> dependencies) {
345349
}
346350
}
347351

348-
BlockReader _currBlock = getBlockReader(maxSize, reader);
349-
if (_currBlock == null) {
350-
return null;
351-
}
352+
try (BlockReader _currBlock = getBlockReader(maxSize, reader)) {
353+
if (_currBlock == null) {
354+
return null;
355+
}
352356

353-
byte[] b = null;
354-
try {
355-
b = new byte[(int) _currBlock.getRawSize()];
357+
byte[] b = new byte[(int) _currBlock.getRawSize()];
356358
_currBlock.readFully(b);
359+
return b;
357360
} catch (IOException e) {
358361
log.debug("Error full blockRead for file " + cacheId + " for block " + getBlockId(), e);
359362
throw new UncheckedIOException(e);
360-
} finally {
361-
_currBlock.close();
362363
}
363-
364-
return b;
365364
} catch (IOException e) {
366365
throw new UncheckedIOException(e);
367366
}

hadoop-mapreduce/src/test/java/org/apache/accumulo/hadoop/its/mapreduce/AccumuloInputFormatIT.java

+13-6
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@
5353
import org.apache.accumulo.hadoop.mapreduce.InputFormatBuilder.InputFormatOptions;
5454
import org.apache.accumulo.hadoopImpl.mapreduce.BatchInputSplit;
5555
import org.apache.accumulo.hadoopImpl.mapreduce.RangeInputSplit;
56-
import org.apache.accumulo.harness.AccumuloClusterHarness;
57-
import org.apache.accumulo.miniclusterImpl.MiniAccumuloConfigImpl;
56+
import org.apache.accumulo.harness.SharedMiniClusterBase;
5857
import org.apache.hadoop.conf.Configuration;
5958
import org.apache.hadoop.conf.Configured;
6059
import org.apache.hadoop.io.Text;
@@ -66,7 +65,9 @@
6665
import org.apache.hadoop.mapreduce.lib.output.NullOutputFormat;
6766
import org.apache.hadoop.util.Tool;
6867
import org.apache.hadoop.util.ToolRunner;
68+
import org.junit.jupiter.api.AfterAll;
6969
import org.junit.jupiter.api.AfterEach;
70+
import org.junit.jupiter.api.BeforeAll;
7071
import org.junit.jupiter.api.BeforeEach;
7172
import org.junit.jupiter.api.Test;
7273

@@ -78,7 +79,7 @@
7879
*
7980
* @since 2.0
8081
*/
81-
public class AccumuloInputFormatIT extends AccumuloClusterHarness {
82+
public class AccumuloInputFormatIT extends SharedMiniClusterBase {
8283

8384
AccumuloInputFormat inputFormat;
8485
AccumuloClient client;
@@ -88,9 +89,15 @@ protected Duration defaultTimeout() {
8889
return Duration.ofMinutes(4);
8990
}
9091

91-
@Override
92-
public void configureMiniCluster(MiniAccumuloConfigImpl cfg, Configuration hadoopCoreSite) {
93-
cfg.getClusterServerConfiguration().setNumDefaultTabletServers(1);
92+
@BeforeAll
93+
public static void setup() throws Exception {
94+
SharedMiniClusterBase.startMiniClusterWithConfig(
95+
(cfg, coreSite) -> cfg.getClusterServerConfiguration().setNumDefaultTabletServers(1));
96+
}
97+
98+
@AfterAll
99+
public static void teardown() {
100+
SharedMiniClusterBase.stopMiniCluster();
94101
}
95102

96103
@BeforeEach

server/base/src/main/java/org/apache/accumulo/server/AbstractServer.java

+7
Original file line numberDiff line numberDiff line change
@@ -371,4 +371,11 @@ public void startServiceLockVerificationThread() {
371371
@Override
372372
public void close() {}
373373

374+
protected void waitForUpgrade() throws InterruptedException {
375+
while (AccumuloDataVersion.getCurrentVersion(getContext()) < AccumuloDataVersion.get()) {
376+
log.info("Waiting for upgrade to complete.");
377+
Thread.sleep(1000);
378+
}
379+
}
380+
374381
}

server/gc/src/main/java/org/apache/accumulo/gc/SimpleGarbageCollector.java

+8
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,14 @@ boolean inSafeMode() {
154154
@Override
155155
@SuppressFBWarnings(value = "DM_EXIT", justification = "main class can call System.exit")
156156
public void run() {
157+
158+
try {
159+
waitForUpgrade();
160+
} catch (InterruptedException e) {
161+
log.error("Interrupted while waiting for upgrade to complete, exiting...");
162+
System.exit(1);
163+
}
164+
157165
final VolumeManager fs = getContext().getVolumeManager();
158166

159167
// Sleep for an initial period, giving the manager time to start up and

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

+5-6
Original file line numberDiff line numberDiff line change
@@ -279,24 +279,23 @@ public Map<String,Object> getTables() {
279279
/**
280280
* Returns participating tservers template
281281
*
282-
* @param tableID Table ID for participating tservers
282+
* @param tableId Table ID for participating tservers
283283
* @return Participating tservers model
284284
*/
285285
@GET
286-
@Path("tables/{tableID}")
286+
@Path("tables/{tableId}")
287287
@Template(name = "/default.ftl")
288288
public Map<String,Object> getTables(
289-
@PathParam("tableID") @NotNull @Pattern(regexp = ALPHA_NUM_REGEX_TABLE_ID) String tableID)
289+
@PathParam("tableId") @NotNull @Pattern(regexp = ALPHA_NUM_REGEX_TABLE_ID) String tableId)
290290
throws TableNotFoundException {
291-
292-
String tableName = monitor.getContext().getTableName(TableId.of(tableID));
291+
String tableName = monitor.getContext().getTableName(TableId.of(tableId));
293292

294293
Map<String,Object> model = getModel();
295294
model.put("title", "Table Status");
296295

297296
model.put("template", "table.ftl");
298297
model.put("js", "table.js");
299-
model.put("tableID", tableID);
298+
model.put("tableId", tableId);
300299
model.put("table", tableName);
301300

302301
return model;

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
// Suffixes for quantity
2626
var QUANTITY_SUFFIX = ['', 'K', 'M', 'B', 'T', 'e15', 'e18', 'e21'];
2727
// Suffixes for size
28-
var SIZE_SUFFIX = ['', 'K', 'M', 'G', 'T', 'P', 'E', 'Z'];
28+
var SIZE_SUFFIX = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB'];
2929

3030
/**
3131
* Initializes Auto Refresh to false if it is not set,
@@ -103,14 +103,14 @@ function bigNumber(big, suffixes, base) {
103103
}
104104

105105
/**
106-
* Converts a number to a size with suffix
106+
* Converts a size in bytes to a human-readable string with appropriate units.
107107
*
108-
* @param {number} size Number to convert
109-
* @return {string} Number with suffix added
108+
* @param {number} size - The size in bytes to be converted.
109+
* @returns {string} The human-readable string representation of the size.
110110
*/
111111
function bigNumberForSize(size) {
112-
if (size === null) {
113-
size = 0;
112+
if (size === 0) {
113+
return '0B';
114114
}
115115
return bigNumber(size, SIZE_SUFFIX, 1024);
116116
}

0 commit comments

Comments
 (0)