From f5567dd69245d6d16e12072568557ef5fa703f62 Mon Sep 17 00:00:00 2001 From: Dom Garguilo Date: Mon, 6 Oct 2025 13:56:58 -0400 Subject: [PATCH 1/3] Use RowRange in place of Range for tablet availability API --- .../core/client/admin/TableOperations.java | 14 +-- .../core/client/admin/TabletAvailability.java | 5 +- .../core/clientImpl/TableOperationsImpl.java | 13 ++- .../clientImpl/TableOperationsHelperTest.java | 2 +- .../monitor/next/InformationFetcher.java | 4 +- .../commands/GetAvailabilityCommand.java | 13 +-- .../shell/commands/ListTabletsCommand.java | 4 +- .../commands/SetAvailabilityCommand.java | 13 +-- .../commands/ListTabletsCommandTest.java | 4 +- .../accumulo/test/ComprehensiveITBase.java | 4 +- ...ehensiveTableOperationsIT_SimpleSuite.java | 6 +- .../apache/accumulo/test/ImportExportIT.java | 11 ++- .../org/apache/accumulo/test/LocatorIT.java | 3 +- .../apache/accumulo/test/ScanServerIT.java | 13 +-- .../accumulo/test/TableOperationsIT.java | 97 ++++++++++--------- .../accumulo/test/TestDualAssignment.java | 6 +- .../test/ample/metadata/TestAmple.java | 4 +- .../compaction/ExternalCompaction_1_IT.java | 3 +- .../accumulo/test/fate/FateTestUtil.java | 6 +- .../functional/AddSplitIT_SimpleSuite.java | 10 +- .../accumulo/test/functional/BulkNewIT.java | 9 +- .../test/functional/FlushNoFileIT.java | 4 +- .../test/functional/ManagerAssignmentIT.java | 7 +- .../test/functional/MergeTabletsITBase.java | 5 +- .../functional/OnDemandTabletUnloadingIT.java | 3 +- .../test/functional/SplitMillionIT.java | 5 +- .../test/functional/TabletAvailabilityIT.java | 13 +-- 27 files changed, 150 insertions(+), 131 deletions(-) diff --git a/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperations.java b/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperations.java index 147383df11d..ce19066684f 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperations.java +++ b/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperations.java @@ -1063,16 +1063,16 @@ default TimeType getTimeType(String tableName) throws TableNotFoundException { /** * Sets the tablet availability for a range of Tablets in the specified table, but does not wait - * for the tablets to reach this availability state. For the Range parameter, note that the Row - * portion of the start and end Keys and the inclusivity parameters are used when determining the - * range of affected tablets. The other portions of the start and end Keys are not used. + * for the tablets to reach this availability state. The supplied row range is compared against + * the tablets' start/end rows using its lower/upper bounds and inclusivity flags; any non-row + * portions of the keys are ignored. * * @param tableName table name - * @param range tablet range + * @param rowRange tablet row range * @param tabletAvailability tablet availability * @since 4.0.0 */ - default void setTabletAvailability(String tableName, Range range, + default void setTabletAvailability(String tableName, RowRange rowRange, TabletAvailability tabletAvailability) throws AccumuloSecurityException, AccumuloException, TableNotFoundException { throw new UnsupportedOperationException(); @@ -1085,8 +1085,8 @@ default void setTabletAvailability(String tableName, Range range, * may be backed by a scanner, so it's best to close the stream. * @since 4.0.0 */ - default Stream getTabletInformation(final String tableName, final Range range, - TabletInformation.Field... fields) throws TableNotFoundException { + default Stream getTabletInformation(final String tableName, + final RowRange rowRange, TabletInformation.Field... fields) throws TableNotFoundException { throw new UnsupportedOperationException(); } diff --git a/core/src/main/java/org/apache/accumulo/core/client/admin/TabletAvailability.java b/core/src/main/java/org/apache/accumulo/core/client/admin/TabletAvailability.java index 34f0ae2a253..512cba250e7 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/admin/TabletAvailability.java +++ b/core/src/main/java/org/apache/accumulo/core/client/admin/TabletAvailability.java @@ -18,9 +18,10 @@ */ package org.apache.accumulo.core.client.admin; +import org.apache.accumulo.core.data.RowRange; + /** - * @see TableOperations#setTabletAvailability(String, org.apache.accumulo.core.data.Range, - * TabletAvailability) + * @see TableOperations#setTabletAvailability(String, RowRange, TabletAvailability) * @since 4.0.0 */ public enum TabletAvailability { diff --git a/core/src/main/java/org/apache/accumulo/core/clientImpl/TableOperationsImpl.java b/core/src/main/java/org/apache/accumulo/core/clientImpl/TableOperationsImpl.java index a326f2336af..19f8db11a3e 100644 --- a/core/src/main/java/org/apache/accumulo/core/clientImpl/TableOperationsImpl.java +++ b/core/src/main/java/org/apache/accumulo/core/clientImpl/TableOperationsImpl.java @@ -2221,16 +2221,18 @@ private void validatePropertiesToSet(Map opts, Map } @Override - public void setTabletAvailability(String tableName, Range range, TabletAvailability availability) - throws AccumuloSecurityException, AccumuloException { + public void setTabletAvailability(String tableName, RowRange rowRange, + TabletAvailability availability) throws AccumuloSecurityException, AccumuloException { EXISTING_TABLE_NAME.validate(tableName); if (SystemTables.containsTableName(tableName)) { throw new AccumuloException("Cannot set set tablet availability for table " + tableName); } - checkArgument(range != null, "range is null"); + checkArgument(rowRange != null, "rowRange is null"); checkArgument(availability != null, "tabletAvailability is null"); + Range range = rowRange.asRange(); + byte[] bRange; try { bRange = new TSerializer().serialize(range.toThrift()); @@ -2255,10 +2257,11 @@ public void setTabletAvailability(String tableName, Range range, TabletAvailabil } @Override - public Stream getTabletInformation(final String tableName, final Range range, - TabletInformation.Field... fields) throws TableNotFoundException { + public Stream getTabletInformation(final String tableName, + final RowRange rowRange, TabletInformation.Field... fields) throws TableNotFoundException { EXISTING_TABLE_NAME.validate(tableName); + final Range range = rowRange.asRange(); final Text scanRangeStart = (range.getStartKey() == null) ? null : range.getStartKey().getRow(); TableId tableId = context.getTableId(tableName); diff --git a/core/src/test/java/org/apache/accumulo/core/clientImpl/TableOperationsHelperTest.java b/core/src/test/java/org/apache/accumulo/core/clientImpl/TableOperationsHelperTest.java index 040d21fd0ae..90329f497d7 100644 --- a/core/src/test/java/org/apache/accumulo/core/clientImpl/TableOperationsHelperTest.java +++ b/core/src/test/java/org/apache/accumulo/core/clientImpl/TableOperationsHelperTest.java @@ -212,7 +212,7 @@ public void offline(String tableName, boolean wait) {} public void online(String tableName, boolean wait) {} @Override - public void setTabletAvailability(String tableName, Range range, + public void setTabletAvailability(String tableName, RowRange rowRange, TabletAvailability tabletAvailability) throws AccumuloSecurityException, AccumuloException, TableNotFoundException {} diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/next/InformationFetcher.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/next/InformationFetcher.java index af832ee3e1c..1a412b23e11 100644 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/next/InformationFetcher.java +++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/next/InformationFetcher.java @@ -45,7 +45,7 @@ import org.apache.accumulo.core.compaction.thrift.CompactionCoordinatorService; import org.apache.accumulo.core.compaction.thrift.TExternalCompactionList; import org.apache.accumulo.core.conf.Property; -import org.apache.accumulo.core.data.Range; +import org.apache.accumulo.core.data.RowRange; import org.apache.accumulo.core.data.TableId; import org.apache.accumulo.core.process.thrift.MetricResponse; import org.apache.accumulo.core.process.thrift.ServerProcessService.Client; @@ -157,7 +157,7 @@ public void run() { try { final String tableName = ctx.getQualifiedTableName(tableId); try (Stream tablets = - this.ctx.tableOperations().getTabletInformation(tableName, new Range())) { + this.ctx.tableOperations().getTabletInformation(tableName, RowRange.all())) { tablets.forEach(t -> summary.processTabletInformation(tableId, tableName, t)); } } catch (TableNotFoundException e) { diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/GetAvailabilityCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/GetAvailabilityCommand.java index 3be57ba7f81..04861b2ace0 100644 --- a/shell/src/main/java/org/apache/accumulo/shell/commands/GetAvailabilityCommand.java +++ b/shell/src/main/java/org/apache/accumulo/shell/commands/GetAvailabilityCommand.java @@ -18,7 +18,7 @@ */ package org.apache.accumulo.shell.commands; -import org.apache.accumulo.core.data.Range; +import org.apache.accumulo.core.data.RowRange; import org.apache.accumulo.shell.Shell; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.Option; @@ -30,7 +30,7 @@ public class GetAvailabilityCommand extends TableOperation { private Option optRow; private Option optStartRowExclusive; private Option optEndRowExclusive; - private Range range; + private RowRange rowRange; @Override public String getName() { @@ -46,8 +46,8 @@ public String description() { protected void doTableOp(Shell shellState, String tableName) throws Exception { shellState.getWriter().println("TABLE: " + tableName); shellState.getWriter().println("TABLET ID AVAILABILITY"); - try (var tabletInformation = - shellState.getAccumuloClient().tableOperations().getTabletInformation(tableName, range)) { + try (var tabletInformation = shellState.getAccumuloClient().tableOperations() + .getTabletInformation(tableName, rowRange)) { tabletInformation.forEach(p -> shellState.getWriter() .println(String.format("%-10s %s", p.getTabletId(), p.getTabletAvailability()))); } @@ -65,13 +65,14 @@ public int execute(final String fullCommand, final CommandLine cl, final Shell s } if (cl.hasOption(optRow.getOpt())) { - this.range = new Range(new Text(cl.getOptionValue(optRow.getOpt()).getBytes(Shell.CHARSET))); + this.rowRange = + RowRange.closed(new Text(cl.getOptionValue(optRow.getOpt()).getBytes(Shell.CHARSET))); } else { Text startRow = OptUtil.getStartRow(cl); Text endRow = OptUtil.getEndRow(cl); final boolean startInclusive = !cl.hasOption(optStartRowExclusive.getOpt()); final boolean endInclusive = !cl.hasOption(optEndRowExclusive.getOpt()); - this.range = new Range(startRow, startInclusive, endRow, endInclusive); + this.rowRange = RowRange.range(startRow, startInclusive, endRow, endInclusive); } return super.execute(fullCommand, cl, shellState); } diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/ListTabletsCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/ListTabletsCommand.java index e4a9b80e2f1..0d751dcc437 100644 --- a/shell/src/main/java/org/apache/accumulo/shell/commands/ListTabletsCommand.java +++ b/shell/src/main/java/org/apache/accumulo/shell/commands/ListTabletsCommand.java @@ -33,7 +33,7 @@ import org.apache.accumulo.core.client.admin.TableOperations; import org.apache.accumulo.core.client.admin.TabletInformation; import org.apache.accumulo.core.data.NamespaceId; -import org.apache.accumulo.core.data.Range; +import org.apache.accumulo.core.data.RowRange; import org.apache.accumulo.core.data.TableId; import org.apache.accumulo.core.util.NumUtil; import org.apache.accumulo.shell.Shell; @@ -78,7 +78,7 @@ public int execute(String fullCommand, CommandLine cl, Shell shellState) throws lines.add("TABLE: " + name); try (Stream tabletInfoStream = - shellState.getContext().tableOperations().getTabletInformation(name, new Range())) { + shellState.getContext().tableOperations().getTabletInformation(name, RowRange.all())) { final AtomicInteger counter = new AtomicInteger(1); tabletInfoStream.forEach(tabletInfo -> { int i = counter.getAndIncrement(); diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/SetAvailabilityCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/SetAvailabilityCommand.java index e47d79cceab..36ecc192967 100644 --- a/shell/src/main/java/org/apache/accumulo/shell/commands/SetAvailabilityCommand.java +++ b/shell/src/main/java/org/apache/accumulo/shell/commands/SetAvailabilityCommand.java @@ -24,7 +24,7 @@ import org.apache.accumulo.core.client.AccumuloSecurityException; import org.apache.accumulo.core.client.TableNotFoundException; import org.apache.accumulo.core.client.admin.TabletAvailability; -import org.apache.accumulo.core.data.Range; +import org.apache.accumulo.core.data.RowRange; import org.apache.accumulo.shell.Shell; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.Option; @@ -38,7 +38,7 @@ public class SetAvailabilityCommand extends TableOperation { private Option optEndRowExclusive; private Option availabilityOpt; - private Range range; + private RowRange rowRange; private TabletAvailability tabletAvailability; @Override @@ -54,10 +54,10 @@ public String description() { @Override protected void doTableOp(final Shell shellState, final String tableName) throws AccumuloException, AccumuloSecurityException, TableNotFoundException, IOException { - shellState.getAccumuloClient().tableOperations().setTabletAvailability(tableName, range, + shellState.getAccumuloClient().tableOperations().setTabletAvailability(tableName, rowRange, tabletAvailability); Shell.log.debug("Set tablet availability: {} on table: {}, range: {}", tabletAvailability, - tableName, range); + tableName, rowRange); } @Override @@ -73,13 +73,14 @@ public int execute(final String fullCommand, final CommandLine cl, final Shell s } if (cl.hasOption(optRow.getOpt())) { - this.range = new Range(new Text(cl.getOptionValue(optRow.getOpt()).getBytes(Shell.CHARSET))); + this.rowRange = + RowRange.closed(new Text(cl.getOptionValue(optRow.getOpt()).getBytes(Shell.CHARSET))); } else { Text startRow = OptUtil.getStartRow(cl); Text endRow = OptUtil.getEndRow(cl); final boolean startInclusive = !cl.hasOption(optStartRowExclusive.getOpt()); final boolean endInclusive = !cl.hasOption(optEndRowExclusive.getOpt()); - this.range = new Range(startRow, startInclusive, endRow, endInclusive); + this.rowRange = RowRange.range(startRow, startInclusive, endRow, endInclusive); } this.tabletAvailability = diff --git a/shell/src/test/java/org/apache/accumulo/shell/commands/ListTabletsCommandTest.java b/shell/src/test/java/org/apache/accumulo/shell/commands/ListTabletsCommandTest.java index b7bd5f1f66e..a6dd87d5dd0 100644 --- a/shell/src/test/java/org/apache/accumulo/shell/commands/ListTabletsCommandTest.java +++ b/shell/src/test/java/org/apache/accumulo/shell/commands/ListTabletsCommandTest.java @@ -39,7 +39,7 @@ import org.apache.accumulo.core.client.admin.TabletAvailability; import org.apache.accumulo.core.clientImpl.ClientContext; import org.apache.accumulo.core.clientImpl.TabletInformationImpl; -import org.apache.accumulo.core.data.Range; +import org.apache.accumulo.core.data.RowRange; import org.apache.accumulo.core.data.TableId; import org.apache.accumulo.core.dataImpl.KeyExtent; import org.apache.accumulo.core.metadata.ReferencedTabletFile; @@ -193,7 +193,7 @@ public void mockTest() throws Exception { EasyMock.expect(shellState.getContext()).andReturn(context).anyTimes(); EasyMock.expect(client.tableOperations()).andReturn(tableOps).anyTimes(); EasyMock.expect(context.tableOperations()).andReturn(tableOps).anyTimes(); - EasyMock.expect(tableOps.getTabletInformation(tableName, new Range())) + EasyMock.expect(tableOps.getTabletInformation(tableName, RowRange.all())) .andReturn(Stream.of(tabletInformation)); Map idMap = new TreeMap<>(); diff --git a/test/src/main/java/org/apache/accumulo/test/ComprehensiveITBase.java b/test/src/main/java/org/apache/accumulo/test/ComprehensiveITBase.java index df1fdf03b95..a5726af9f33 100644 --- a/test/src/main/java/org/apache/accumulo/test/ComprehensiveITBase.java +++ b/test/src/main/java/org/apache/accumulo/test/ComprehensiveITBase.java @@ -850,7 +850,7 @@ public void testCreateTableWithManyOptions() throws Exception { // set last tablet in table to always be HOSTED, setting a tablet availability here will test // export and cloning tables with tablet availabilities client.tableOperations().setTabletAvailability(everythingTable, - new Range(everythingSplits.last(), false, null, true), TabletAvailability.HOSTED); + RowRange.greaterThan(everythingSplits.last()), TabletAvailability.HOSTED); write(client, everythingTable, generateMutations(0, 100, tr -> true)); @@ -1105,7 +1105,7 @@ private static void verifyEverythingTable(AccumuloClient client, String table, IteratorUtil.IteratorScope.scan)); try (Stream tabletInfo = - client.tableOperations().getTabletInformation(table, new Range())) { + client.tableOperations().getTabletInformation(table, RowRange.all())) { tabletInfo.forEach(tabletInformation -> { if (tabletInformation.getTabletId().getEndRow() == null) { assertEquals(expectedAvailabilityForDefaultTable, diff --git a/test/src/main/java/org/apache/accumulo/test/ComprehensiveTableOperationsIT_SimpleSuite.java b/test/src/main/java/org/apache/accumulo/test/ComprehensiveTableOperationsIT_SimpleSuite.java index bb929ad151a..148be657719 100644 --- a/test/src/main/java/org/apache/accumulo/test/ComprehensiveTableOperationsIT_SimpleSuite.java +++ b/test/src/main/java/org/apache/accumulo/test/ComprehensiveTableOperationsIT_SimpleSuite.java @@ -741,9 +741,9 @@ public void test_setTabletAvailability_getTabletInformation() throws Exception { for (var sysTable : SystemTables.tableNames()) { // should not be able to unhost any system table assertThrows(AccumuloException.class, - () -> ops.setTabletAvailability(sysTable, new Range(), TabletAvailability.UNHOSTED)); - assertTrue(ops.getTabletInformation(sysTable, new Range()).findAny().isPresent()); - ops.getTabletInformation(sysTable, new Range()) + () -> ops.setTabletAvailability(sysTable, RowRange.all(), TabletAvailability.UNHOSTED)); + assertTrue(ops.getTabletInformation(sysTable, RowRange.all()).findAny().isPresent()); + ops.getTabletInformation(sysTable, RowRange.all()) .forEach(ti -> assertEquals(TabletAvailability.HOSTED, ti.getTabletAvailability())); } } diff --git a/test/src/main/java/org/apache/accumulo/test/ImportExportIT.java b/test/src/main/java/org/apache/accumulo/test/ImportExportIT.java index e35bece0f2c..5eb233db79b 100644 --- a/test/src/main/java/org/apache/accumulo/test/ImportExportIT.java +++ b/test/src/main/java/org/apache/accumulo/test/ImportExportIT.java @@ -55,6 +55,7 @@ import org.apache.accumulo.core.data.Key; import org.apache.accumulo.core.data.Mutation; import org.apache.accumulo.core.data.Range; +import org.apache.accumulo.core.data.RowRange; import org.apache.accumulo.core.data.TableId; import org.apache.accumulo.core.data.TabletId; import org.apache.accumulo.core.data.Value; @@ -364,9 +365,9 @@ public void testImportedTableIsOnDemand() throws Exception { // add split 'h' and 'q'. Leave first as ONDEMAND, set second to UNHOSTED, and third to HOSTED SortedSet splits = Sets.newTreeSet(Arrays.asList(new Text("h"), new Text("q"))); client.tableOperations().addSplits(srcTable, splits); - Range range = new Range(new Text("h"), false, new Text("q"), true); + RowRange range = RowRange.openClosed(new Text("h"), new Text("q")); client.tableOperations().setTabletAvailability(srcTable, range, TabletAvailability.UNHOSTED); - range = new Range(new Text("q"), false, null, true); + range = RowRange.greaterThan(new Text("q")); client.tableOperations().setTabletAvailability(srcTable, range, TabletAvailability.HOSTED); // verify @@ -377,7 +378,7 @@ public void testImportedTableIsOnDemand() throws Exception { TabletAvailability.UNHOSTED); setExpectedTabletAvailability(expectedTabletAvailability, srcTableId, null, "q", TabletAvailability.HOSTED); - verifyTabletAvailabilities(client, srcTable, new Range(), expectedTabletAvailability); + verifyTabletAvailabilities(client, srcTable, RowRange.all(), expectedTabletAvailability); // Add a split within each of the existing tablets. Adding 'd', 'm', and 'v' splits = Sets.newTreeSet(Arrays.asList(new Text("d"), new Text("m"), new Text("v"))); @@ -397,7 +398,7 @@ public void testImportedTableIsOnDemand() throws Exception { TabletAvailability.HOSTED); setExpectedTabletAvailability(expectedTabletAvailability, srcTableId, null, "v", TabletAvailability.HOSTED); - verifyTabletAvailabilities(client, srcTable, new Range(), expectedTabletAvailability); + verifyTabletAvailabilities(client, srcTable, RowRange.all(), expectedTabletAvailability); // Make a directory we can use to throw the export and import directories // Must exist on the filesystem the cluster is running. @@ -444,7 +445,7 @@ public void testImportedTableIsOnDemand() throws Exception { // Get all `file` colfams from the metadata table for the new table log.info("Imported into table with ID: {}", destTableId); - client.tableOperations().getTabletInformation(destTable, new Range()) + client.tableOperations().getTabletInformation(destTable, RowRange.all()) .forEach(tabletInformation -> assertEquals(TabletAvailability.ONDEMAND, tabletInformation.getTabletAvailability(), "Expected all tablets in imported table to be ONDEMAND")); diff --git a/test/src/main/java/org/apache/accumulo/test/LocatorIT.java b/test/src/main/java/org/apache/accumulo/test/LocatorIT.java index ff89e81b922..eea4ee57332 100644 --- a/test/src/main/java/org/apache/accumulo/test/LocatorIT.java +++ b/test/src/main/java/org/apache/accumulo/test/LocatorIT.java @@ -44,6 +44,7 @@ import org.apache.accumulo.core.client.admin.TabletAvailability; import org.apache.accumulo.core.client.admin.servers.ServerId; import org.apache.accumulo.core.data.Range; +import org.apache.accumulo.core.data.RowRange; import org.apache.accumulo.core.data.TableId; import org.apache.accumulo.core.data.TabletId; import org.apache.accumulo.core.dataImpl.KeyExtent; @@ -129,7 +130,7 @@ public void testBasic() throws Exception { ranges.clear(); - tableOps.setTabletAvailability(tableName, new Range(), TabletAvailability.HOSTED); + tableOps.setTabletAvailability(tableName, RowRange.all(), TabletAvailability.HOSTED); Wait.waitFor(() -> hostedAndCurrentNotNull .test(ManagerAssignmentIT.getTabletMetadata(client, tableId, null)), 60000, 250); diff --git a/test/src/main/java/org/apache/accumulo/test/ScanServerIT.java b/test/src/main/java/org/apache/accumulo/test/ScanServerIT.java index b4155d506af..9507dbe3fb8 100644 --- a/test/src/main/java/org/apache/accumulo/test/ScanServerIT.java +++ b/test/src/main/java/org/apache/accumulo/test/ScanServerIT.java @@ -56,6 +56,7 @@ import org.apache.accumulo.core.conf.ClientProperty; import org.apache.accumulo.core.conf.Property; import org.apache.accumulo.core.data.Range; +import org.apache.accumulo.core.data.RowRange; import org.apache.accumulo.core.data.TableId; import org.apache.accumulo.core.fate.FateId; import org.apache.accumulo.core.fate.FateInstanceType; @@ -254,7 +255,7 @@ public void testScanTabletsWithOperationIds() throws Exception { // Unload all tablets TableId tid = TableId.of(client.tableOperations().tableIdMap().get(tableName)); - client.tableOperations().setTabletAvailability(tableName, new Range((Text) null, (Text) null), + client.tableOperations().setTabletAvailability(tableName, RowRange.all(), TabletAvailability.ONDEMAND); // Wait for the tablets to be unloaded @@ -373,14 +374,14 @@ protected static int setupTableWithTabletAvailabilityMix(AccumuloClient client, String tableId = client.tableOperations().tableIdMap().get(tableName); // row 1 -> 3 are HOSTED - client.tableOperations().setTabletAvailability(tableName, - new Range(null, true, "row_0000000003", true), TabletAvailability.HOSTED); + client.tableOperations().setTabletAvailability(tableName, RowRange.atMost("row_0000000003"), + TabletAvailability.HOSTED); // row 4 -> 7 are UNHOSTED client.tableOperations().setTabletAvailability(tableName, - new Range("row_0000000004", true, "row_0000000007", true), TabletAvailability.UNHOSTED); + RowRange.closed("row_0000000004", "row_0000000007"), TabletAvailability.UNHOSTED); // row 8 and 9 are ondemand - client.tableOperations().setTabletAvailability(tableName, - new Range("row_0000000008", true, null, true), TabletAvailability.ONDEMAND); + client.tableOperations().setTabletAvailability(tableName, RowRange.atLeast("row_0000000008"), + TabletAvailability.ONDEMAND); // Wait for the UNHOSTED and ONDEMAND tablets to be unloaded due to inactivity Wait.waitFor(() -> ScanServerIT.getNumHostedTablets(client, tableId) == 3, 30_000, 1_000); diff --git a/test/src/main/java/org/apache/accumulo/test/TableOperationsIT.java b/test/src/main/java/org/apache/accumulo/test/TableOperationsIT.java index e5836592832..30f27abc381 100644 --- a/test/src/main/java/org/apache/accumulo/test/TableOperationsIT.java +++ b/test/src/main/java/org/apache/accumulo/test/TableOperationsIT.java @@ -67,7 +67,7 @@ import org.apache.accumulo.core.data.Key; import org.apache.accumulo.core.data.Mutation; import org.apache.accumulo.core.data.PartialKey; -import org.apache.accumulo.core.data.Range; +import org.apache.accumulo.core.data.RowRange; import org.apache.accumulo.core.data.TableId; import org.apache.accumulo.core.data.TabletId; import org.apache.accumulo.core.data.Value; @@ -567,17 +567,17 @@ public void testGetTabletAvailability_DefaultTableCreations() throws AccumuloExc Map expectedTabletAvailability = new HashMap<>(); setExpectedTabletAvailability(expectedTabletAvailability, idMap.get(tableOnDemand), null, null, TabletAvailability.ONDEMAND); - verifyTabletAvailabilities(tableOnDemand, new Range(), expectedTabletAvailability); + verifyTabletAvailabilities(tableOnDemand, RowRange.all(), expectedTabletAvailability); expectedTabletAvailability.clear(); setExpectedTabletAvailability(expectedTabletAvailability, idMap.get(tableHosted), null, null, TabletAvailability.HOSTED); - verifyTabletAvailabilities(tableHosted, new Range(), expectedTabletAvailability); + verifyTabletAvailabilities(tableHosted, RowRange.all(), expectedTabletAvailability); expectedTabletAvailability.clear(); setExpectedTabletAvailability(expectedTabletAvailability, idMap.get(tableUnhosted), null, null, TabletAvailability.UNHOSTED); - verifyTabletAvailabilities(tableUnhosted, new Range(), expectedTabletAvailability); + verifyTabletAvailabilities(tableUnhosted, RowRange.all(), expectedTabletAvailability); verifyTablesWithSplits(tableOnDemandWithSplits, idMap, splits, TabletAvailability.ONDEMAND); verifyTablesWithSplits(tableHostedWithSplits, idMap, splits, TabletAvailability.HOSTED); @@ -611,14 +611,14 @@ public void testGetTabletAvailability_MixedAvailabilities() throws AccumuloExcep accumuloClient.tableOperations().create(tableName, ntc); // set each tablet with a different availability and query to see if they are set accordingly - Range range = new Range(null, false, new Text("d"), true); - accumuloClient.tableOperations().setTabletAvailability(tableName, range, + RowRange rowRange = RowRange.atMost(new Text("d")); + accumuloClient.tableOperations().setTabletAvailability(tableName, rowRange, TabletAvailability.UNHOSTED); - range = new Range(new Text("m"), false, new Text("s"), true); - accumuloClient.tableOperations().setTabletAvailability(tableName, range, + rowRange = RowRange.openClosed(new Text("m"), new Text("s")); + accumuloClient.tableOperations().setTabletAvailability(tableName, rowRange, TabletAvailability.HOSTED); - range = new Range(new Text("s"), false, null, true); - accumuloClient.tableOperations().setTabletAvailability(tableName, range, + rowRange = RowRange.greaterThan(new Text("s")); + accumuloClient.tableOperations().setTabletAvailability(tableName, rowRange, TabletAvailability.UNHOSTED); Map idMap = accumuloClient.tableOperations().tableIdMap(); @@ -634,7 +634,7 @@ public void testGetTabletAvailability_MixedAvailabilities() throws AccumuloExcep TabletAvailability.HOSTED); setExpectedTabletAvailability(expectedTabletAvailability, tableId, null, "s", TabletAvailability.UNHOSTED); - verifyTabletAvailabilities(tableName, new Range(), expectedTabletAvailability); + verifyTabletAvailabilities(tableName, RowRange.all(), expectedTabletAvailability); } finally { accumuloClient.tableOperations().delete(tableName); } @@ -660,12 +660,12 @@ public void testGetTabletAvailability_NonSplitBoundaries() throws AccumuloExcept // set each different availability for each tablet and query to see if they are set // accordingly - accumuloClient.tableOperations().setTabletAvailability(tableName, new Range(new Text("d")), - TabletAvailability.HOSTED); - accumuloClient.tableOperations().setTabletAvailability(tableName, new Range(new Text("m")), - TabletAvailability.UNHOSTED); - accumuloClient.tableOperations().setTabletAvailability(tableName, new Range(new Text("s")), - TabletAvailability.HOSTED); + accumuloClient.tableOperations().setTabletAvailability(tableName, + RowRange.closed(new Text("d")), TabletAvailability.HOSTED); + accumuloClient.tableOperations().setTabletAvailability(tableName, + RowRange.closed(new Text("m")), TabletAvailability.UNHOSTED); + accumuloClient.tableOperations().setTabletAvailability(tableName, + RowRange.closed(new Text("s")), TabletAvailability.HOSTED); idMap = accumuloClient.tableOperations().tableIdMap(); tableId = idMap.get(tableName); @@ -673,11 +673,12 @@ public void testGetTabletAvailability_NonSplitBoundaries() throws AccumuloExcept setExpectedTabletAvailability(expectedTabletAvailability, tableId, "d", null, TabletAvailability.HOSTED); // test using row as range constructor - verifyTabletAvailabilities(tableName, new Range("a"), expectedTabletAvailability); + verifyTabletAvailabilities(tableName, RowRange.closed(new Text("a")), + expectedTabletAvailability); // test using startRowInclusive set to true - Range range = new Range(new Text("c"), true, new Text("c"), true); - verifyTabletAvailabilities(tableName, range, expectedTabletAvailability); + RowRange rowRange = RowRange.closed(new Text("c")); + verifyTabletAvailabilities(tableName, rowRange, expectedTabletAvailability); expectedTabletAvailability.clear(); setExpectedTabletAvailability(expectedTabletAvailability, tableId, "m", "d", @@ -685,8 +686,8 @@ public void testGetTabletAvailability_NonSplitBoundaries() throws AccumuloExcept setExpectedTabletAvailability(expectedTabletAvailability, tableId, "s", "m", TabletAvailability.HOSTED); - range = new Range(new Text("m"), new Text("p")); - verifyTabletAvailabilities(tableName, range, expectedTabletAvailability); + rowRange = RowRange.closed(new Text("m"), new Text("p")); + verifyTabletAvailabilities(tableName, rowRange, expectedTabletAvailability); expectedTabletAvailability.clear(); setExpectedTabletAvailability(expectedTabletAvailability, tableId, "d", null, @@ -698,8 +699,8 @@ public void testGetTabletAvailability_NonSplitBoundaries() throws AccumuloExcept setExpectedTabletAvailability(expectedTabletAvailability, tableId, null, "s", TabletAvailability.ONDEMAND); - range = new Range("b", false, "t", true); - verifyTabletAvailabilities(tableName, range, expectedTabletAvailability); + rowRange = RowRange.openClosed("b", "t"); + verifyTabletAvailabilities(tableName, rowRange, expectedTabletAvailability); } finally { accumuloClient.tableOperations().delete(tableName); @@ -719,14 +720,14 @@ public void testGetTabletAvailability_DelayedSplits() throws AccumuloException, Map idMap = accumuloClient.tableOperations().tableIdMap(); // set goals to HOSTED - accumuloClient.tableOperations().setTabletAvailability(tableName, new Range(), + accumuloClient.tableOperations().setTabletAvailability(tableName, RowRange.all(), TabletAvailability.HOSTED); Map expectedTabletAvailability = new HashMap<>(); String tableId = idMap.get(tableName); setExpectedTabletAvailability(expectedTabletAvailability, tableId, null, null, TabletAvailability.HOSTED); - verifyTabletAvailabilities(tableName, new Range(), expectedTabletAvailability); + verifyTabletAvailabilities(tableName, RowRange.all(), expectedTabletAvailability); // Add splits after the fact SortedSet splits = @@ -742,7 +743,7 @@ public void testGetTabletAvailability_DelayedSplits() throws AccumuloException, TabletAvailability.HOSTED); setExpectedTabletAvailability(expectedTabletAvailability, tableId, null, "r", TabletAvailability.HOSTED); - verifyTabletAvailabilities(tableName, new Range(), expectedTabletAvailability); + verifyTabletAvailabilities(tableName, RowRange.all(), expectedTabletAvailability); } finally { accumuloClient.tableOperations().delete(tableName); } @@ -770,11 +771,11 @@ public void testGetTabletAvailability_StaggeredSplits() throws AccumuloException // add split 'h' and 'q'. Leave first as ONDEMAND, set second to UNHOSTED, and third to HOSTED SortedSet splits = Sets.newTreeSet(Arrays.asList(new Text("h"), new Text("q"))); accumuloClient.tableOperations().addSplits(tableName, splits); - Range range = new Range(new Text("h"), false, new Text("q"), true); - accumuloClient.tableOperations().setTabletAvailability(tableName, range, + RowRange rowRange = RowRange.openClosed(new Text("h"), new Text("q")); + accumuloClient.tableOperations().setTabletAvailability(tableName, rowRange, TabletAvailability.UNHOSTED); - range = new Range(new Text("q"), false, null, true); - accumuloClient.tableOperations().setTabletAvailability(tableName, range, + rowRange = RowRange.greaterThan(new Text("q")); + accumuloClient.tableOperations().setTabletAvailability(tableName, rowRange, TabletAvailability.HOSTED); // verify @@ -785,7 +786,7 @@ public void testGetTabletAvailability_StaggeredSplits() throws AccumuloException TabletAvailability.UNHOSTED); setExpectedTabletAvailability(expectedTabletAvailability, tableId, null, "q", TabletAvailability.HOSTED); - verifyTabletAvailabilities(tableName, new Range(), expectedTabletAvailability); + verifyTabletAvailabilities(tableName, RowRange.all(), expectedTabletAvailability); // Add a split within each of the existing tablets. Adding 'd', 'm', and 'v' splits = Sets.newTreeSet(Arrays.asList(new Text("d"), new Text("m"), new Text("v"))); @@ -805,7 +806,7 @@ public void testGetTabletAvailability_StaggeredSplits() throws AccumuloException TabletAvailability.HOSTED); setExpectedTabletAvailability(expectedTabletAvailability, tableId, null, "v", TabletAvailability.HOSTED); - verifyTabletAvailabilities(tableName, new Range(), expectedTabletAvailability); + verifyTabletAvailabilities(tableName, RowRange.all(), expectedTabletAvailability); } finally { accumuloClient.tableOperations().delete(tableName); } @@ -827,33 +828,33 @@ private void verifyTablesWithSplits(String tableName, Map idMap, tabletAvailability); setExpectedTabletAvailability(expectedTabletAvailability, tableId, null, splitPts[2], tabletAvailability); - verifyTabletAvailabilities(tableName, new Range(), expectedTabletAvailability); + verifyTabletAvailabilities(tableName, RowRange.all(), expectedTabletAvailability); // verify individual tablets can be retrieved expectedTabletAvailability.clear(); setExpectedTabletAvailability(expectedTabletAvailability, tableId, splitPts[0], null, tabletAvailability); - verifyTabletAvailabilities(tableName, new Range(null, new Text(splitPts[0])), + verifyTabletAvailabilities(tableName, RowRange.atMost(new Text(splitPts[0])), expectedTabletAvailability); expectedTabletAvailability.clear(); setExpectedTabletAvailability(expectedTabletAvailability, tableId, splitPts[1], splitPts[0], tabletAvailability); verifyTabletAvailabilities(tableName, - new Range(new Text(splitPts[0]), false, new Text(splitPts[1]), true), + RowRange.openClosed(new Text(splitPts[0]), new Text(splitPts[1])), expectedTabletAvailability); expectedTabletAvailability.clear(); setExpectedTabletAvailability(expectedTabletAvailability, tableId, splitPts[2], splitPts[1], tabletAvailability); verifyTabletAvailabilities(tableName, - new Range(new Text(splitPts[1]), false, new Text(splitPts[2]), true), + RowRange.openClosed(new Text(splitPts[1]), new Text(splitPts[2])), expectedTabletAvailability); expectedTabletAvailability.clear(); setExpectedTabletAvailability(expectedTabletAvailability, tableId, null, splitPts[2], tabletAvailability); - verifyTabletAvailabilities(tableName, new Range(new Text(splitPts[2]), false, null, true), + verifyTabletAvailabilities(tableName, RowRange.greaterThan(new Text(splitPts[2])), expectedTabletAvailability); expectedTabletAvailability.clear(); @@ -862,20 +863,20 @@ private void verifyTablesWithSplits(String tableName, Map idMap, setExpectedTabletAvailability(expectedTabletAvailability, tableId, splitPts[2], splitPts[1], tabletAvailability); verifyTabletAvailabilities(tableName, - new Range(new Text(splitPts[0]), false, new Text(splitPts[2]), true), + RowRange.openClosed(new Text(splitPts[0]), new Text(splitPts[2])), expectedTabletAvailability); } - public static void verifyTabletAvailabilities(String tableName, Range range, + public static void verifyTabletAvailabilities(String tableName, RowRange rowRange, Map expectedAvailability) throws TableNotFoundException { - verifyTabletAvailabilities(accumuloClient, tableName, range, expectedAvailability); + verifyTabletAvailabilities(accumuloClient, tableName, rowRange, expectedAvailability); } public static void verifyTabletAvailabilities(AccumuloClient client, String tableName, - Range range, Map expectedAvailability) + RowRange rowRange, Map expectedAvailability) throws TableNotFoundException { Map seenAvailability = - client.tableOperations().getTabletInformation(tableName, range).collect(Collectors + client.tableOperations().getTabletInformation(tableName, rowRange).collect(Collectors .toMap(TabletInformation::getTabletId, TabletInformation::getTabletAvailability)); assertEquals(expectedAvailability, seenAvailability); } @@ -942,7 +943,7 @@ public void testGetTabletInformation() throws Exception { var tableId = TableId.of(accumuloClient.tableOperations().tableIdMap().get(tableName)); try (var tablets = accumuloClient.tableOperations().getTabletInformation(tableName, - new Range(), TabletInformation.Field.LOCATION)) { + RowRange.all(), TabletInformation.Field.LOCATION)) { var tabletList = tablets.collect(Collectors.toList()); assertEquals(9, tabletList.size()); tabletList.forEach(ti -> { @@ -960,7 +961,7 @@ public void testGetTabletInformation() throws Exception { } try (var tablets = accumuloClient.tableOperations().getTabletInformation(tableName, - new Range(), TabletInformation.Field.FILES)) { + RowRange.all(), TabletInformation.Field.FILES)) { var tabletList = tablets.collect(Collectors.toList()); assertEquals(9, tabletList.size()); tabletList.forEach(ti -> { @@ -978,7 +979,7 @@ public void testGetTabletInformation() throws Exception { } try (var tablets = accumuloClient.tableOperations().getTabletInformation(tableName, - new Range(), TabletInformation.Field.FILES, TabletInformation.Field.LOCATION)) { + RowRange.all(), TabletInformation.Field.FILES, TabletInformation.Field.LOCATION)) { var tabletList = tablets.collect(Collectors.toList()); assertEquals(9, tabletList.size()); tabletList.forEach(ti -> { @@ -996,7 +997,7 @@ public void testGetTabletInformation() throws Exception { } try (var tablets = accumuloClient.tableOperations().getTabletInformation(tableName, - new Range(), TabletInformation.Field.AVAILABILITY)) { + RowRange.all(), TabletInformation.Field.AVAILABILITY)) { var tabletList = tablets.collect(Collectors.toList()); assertEquals(9, tabletList.size()); tabletList.forEach(ti -> { @@ -1014,7 +1015,7 @@ public void testGetTabletInformation() throws Exception { } try (var tablets = accumuloClient.tableOperations().getTabletInformation(tableName, - new Range(), TabletInformation.Field.MERGEABILITY)) { + RowRange.all(), TabletInformation.Field.MERGEABILITY)) { var tabletList = tablets.collect(Collectors.toList()); assertEquals(9, tabletList.size()); tabletList.forEach(ti -> { diff --git a/test/src/main/java/org/apache/accumulo/test/TestDualAssignment.java b/test/src/main/java/org/apache/accumulo/test/TestDualAssignment.java index d04ff0d68f0..3c3525e7a6f 100644 --- a/test/src/main/java/org/apache/accumulo/test/TestDualAssignment.java +++ b/test/src/main/java/org/apache/accumulo/test/TestDualAssignment.java @@ -31,7 +31,7 @@ import org.apache.accumulo.core.client.admin.NewTableConfiguration; import org.apache.accumulo.core.client.admin.TabletAvailability; import org.apache.accumulo.core.conf.Property; -import org.apache.accumulo.core.data.Range; +import org.apache.accumulo.core.data.RowRange; import org.apache.accumulo.core.dataImpl.KeyExtent; import org.apache.accumulo.core.metadata.schema.TabletMetadata; import org.apache.accumulo.miniclusterImpl.MiniAccumuloConfigImpl; @@ -83,7 +83,7 @@ public void test() throws Exception { // This operation will fail when there are two locations set on a tablet assertThrows(AccumuloException.class, () -> c.tableOperations().setTabletAvailability(table, - new Range(), TabletAvailability.HOSTED)); + RowRange.all(), TabletAvailability.HOSTED)); try (var scanner = c.createScanner(table)) { // should not be able to scan the table when a tablet has multiple locations @@ -116,7 +116,7 @@ public void test() throws Exception { } // this should no longer fail - c.tableOperations().setTabletAvailability(table, new Range(), TabletAvailability.HOSTED); + c.tableOperations().setTabletAvailability(table, RowRange.all(), TabletAvailability.HOSTED); } } } diff --git a/test/src/main/java/org/apache/accumulo/test/ample/metadata/TestAmple.java b/test/src/main/java/org/apache/accumulo/test/ample/metadata/TestAmple.java index 8a0041beae1..d81264a2453 100644 --- a/test/src/main/java/org/apache/accumulo/test/ample/metadata/TestAmple.java +++ b/test/src/main/java/org/apache/accumulo/test/ample/metadata/TestAmple.java @@ -41,7 +41,7 @@ import org.apache.accumulo.core.conf.SiteConfiguration; import org.apache.accumulo.core.data.Key; import org.apache.accumulo.core.data.Mutation; -import org.apache.accumulo.core.data.Range; +import org.apache.accumulo.core.data.RowRange; import org.apache.accumulo.core.data.TableId; import org.apache.accumulo.core.data.Value; import org.apache.accumulo.core.dataImpl.KeyExtent; @@ -300,7 +300,7 @@ public static void createMetadataTable(ClientContext client, String table) throw TabletAvailability availability; try (var tabletStream = client.tableOperations() - .getTabletInformation(SystemTables.METADATA.tableName(), new Range())) { + .getTabletInformation(SystemTables.METADATA.tableName(), RowRange.all())) { availability = tabletStream.map(TabletInformation::getTabletAvailability).distinct() .collect(MoreCollectors.onlyElement()); } diff --git a/test/src/main/java/org/apache/accumulo/test/compaction/ExternalCompaction_1_IT.java b/test/src/main/java/org/apache/accumulo/test/compaction/ExternalCompaction_1_IT.java index 0444e28ca03..88e42167be9 100644 --- a/test/src/main/java/org/apache/accumulo/test/compaction/ExternalCompaction_1_IT.java +++ b/test/src/main/java/org/apache/accumulo/test/compaction/ExternalCompaction_1_IT.java @@ -78,6 +78,7 @@ import org.apache.accumulo.core.data.Mutation; import org.apache.accumulo.core.data.Range; import org.apache.accumulo.core.data.ResourceGroupId; +import org.apache.accumulo.core.data.RowRange; import org.apache.accumulo.core.data.TableId; import org.apache.accumulo.core.data.TabletId; import org.apache.accumulo.core.data.Value; @@ -535,7 +536,7 @@ public void testManytablets() throws Exception { List tabletIds; // start a compaction on each tablet - try (var tablets = client.tableOperations().getTabletInformation(table1, new Range())) { + try (var tablets = client.tableOperations().getTabletInformation(table1, RowRange.all())) { tabletIds = tablets.map(TabletInformation::getTabletId).collect(Collectors.toList()); } // compact the even tablet with a modulus filter of 2 diff --git a/test/src/main/java/org/apache/accumulo/test/fate/FateTestUtil.java b/test/src/main/java/org/apache/accumulo/test/fate/FateTestUtil.java index 4608065bb36..7ea9200d6b8 100644 --- a/test/src/main/java/org/apache/accumulo/test/fate/FateTestUtil.java +++ b/test/src/main/java/org/apache/accumulo/test/fate/FateTestUtil.java @@ -33,7 +33,7 @@ import org.apache.accumulo.core.clientImpl.ClientContext; import org.apache.accumulo.core.conf.ConfigurationCopy; import org.apache.accumulo.core.conf.Property; -import org.apache.accumulo.core.data.Range; +import org.apache.accumulo.core.data.RowRange; import org.apache.accumulo.core.fate.Fate; import org.apache.accumulo.core.fate.FateId; import org.apache.accumulo.core.fate.FateKey; @@ -64,8 +64,8 @@ public static void createFateTable(ClientContext client, String table) throws Ex client.tableOperations().getTableProperties(SystemTables.FATE.tableName()); TabletAvailability availability; - try (var tabletStream = - client.tableOperations().getTabletInformation(SystemTables.FATE.tableName(), new Range())) { + try (var tabletStream = client.tableOperations() + .getTabletInformation(SystemTables.FATE.tableName(), RowRange.all())) { availability = tabletStream.map(TabletInformation::getTabletAvailability).distinct() .collect(MoreCollectors.onlyElement()); } diff --git a/test/src/main/java/org/apache/accumulo/test/functional/AddSplitIT_SimpleSuite.java b/test/src/main/java/org/apache/accumulo/test/functional/AddSplitIT_SimpleSuite.java index d36a37a51c2..ca665cd6e5b 100644 --- a/test/src/main/java/org/apache/accumulo/test/functional/AddSplitIT_SimpleSuite.java +++ b/test/src/main/java/org/apache/accumulo/test/functional/AddSplitIT_SimpleSuite.java @@ -50,7 +50,7 @@ import org.apache.accumulo.core.clientImpl.TabletMergeabilityUtil; import org.apache.accumulo.core.data.Key; import org.apache.accumulo.core.data.Mutation; -import org.apache.accumulo.core.data.Range; +import org.apache.accumulo.core.data.RowRange; import org.apache.accumulo.core.data.TableId; import org.apache.accumulo.core.data.Value; import org.apache.accumulo.core.metadata.schema.TabletsMetadata; @@ -205,13 +205,13 @@ public void updateSplitWithMergeabilityTest() throws Exception { var split = new Text(String.format("%09d", 777)); splits.put(split, TabletMergeability.after(Duration.ofMinutes(5))); - var originalTmi = c.tableOperations().getTabletInformation(tableName, new Range(split)) + var originalTmi = c.tableOperations().getTabletInformation(tableName, RowRange.closed(split)) .findFirst().orElseThrow().getTabletMergeabilityInfo(); assertTrue(originalTmi.getElapsed().orElseThrow().toNanos() > 0); // Update existing with same delay of 5 minutes c.tableOperations().putSplits(tableName, splits); - var updatedTmi = c.tableOperations().getTabletInformation(tableName, new Range(split)) + var updatedTmi = c.tableOperations().getTabletInformation(tableName, RowRange.closed(split)) .findFirst().orElseThrow().getTabletMergeabilityInfo(); // TabletMergeability setting should be the same but the new elapsed time should @@ -244,7 +244,7 @@ public void addSplitIsMergeableTest() throws Exception { Thread.sleep(100); assertEquals(splits.keySet(), new TreeSet<>(c.tableOperations().listSplits(tableName))); - var tableInfo = c.tableOperations().getTabletInformation(tableName, new Range()) + var tableInfo = c.tableOperations().getTabletInformation(tableName, RowRange.all()) .collect(Collectors.toMap(ti -> ti.getTabletId().getEndRow(), Function.identity())); // Set to always @@ -372,7 +372,7 @@ private void verifySplits(TableId id, SortedMap splits) private void verifySplitsWithApi(AccumuloClient c, String tableName, SortedMap splits) throws TableNotFoundException { final Set addedSplits = new HashSet<>(splits.keySet()); - c.tableOperations().getTabletInformation(tableName, new Range()).forEach(ti -> { + c.tableOperations().getTabletInformation(tableName, RowRange.all()).forEach(ti -> { var tmInfo = ti.getTabletMergeabilityInfo(); var split = ti.getTabletId().getEndRow(); // default tablet should always be set to always diff --git a/test/src/main/java/org/apache/accumulo/test/functional/BulkNewIT.java b/test/src/main/java/org/apache/accumulo/test/functional/BulkNewIT.java index 95e5ca2dee6..28ec6ef9629 100644 --- a/test/src/main/java/org/apache/accumulo/test/functional/BulkNewIT.java +++ b/test/src/main/java/org/apache/accumulo/test/functional/BulkNewIT.java @@ -80,6 +80,7 @@ import org.apache.accumulo.core.data.LoadPlan.RangeType; import org.apache.accumulo.core.data.Mutation; import org.apache.accumulo.core.data.Range; +import org.apache.accumulo.core.data.RowRange; import org.apache.accumulo.core.data.TableId; import org.apache.accumulo.core.data.Value; import org.apache.accumulo.core.data.constraints.Constraint; @@ -1045,11 +1046,11 @@ public void testAvailability() throws Exception { addSplits(c, tableName, "0100 0200 0300 0400 0500"); - c.tableOperations().setTabletAvailability(tableName, new Range("0100", false, "0200", true), + c.tableOperations().setTabletAvailability(tableName, RowRange.openClosed("0100", "0200"), TabletAvailability.HOSTED); - c.tableOperations().setTabletAvailability(tableName, new Range("0300", false, "0400", true), + c.tableOperations().setTabletAvailability(tableName, RowRange.openClosed("0300", "0400"), TabletAvailability.HOSTED); - c.tableOperations().setTabletAvailability(tableName, new Range("0400", false, null, true), + c.tableOperations().setTabletAvailability(tableName, RowRange.greaterThan("0400"), TabletAvailability.UNHOSTED); // verify tablet availabilities are as expected @@ -1188,7 +1189,7 @@ private static Map getLocationStatus(AccumuloClient c, String ta */ private static Map getTabletAvailabilities(AccumuloClient c, String tableName) throws TableNotFoundException { - try (var tabletsInfo = c.tableOperations().getTabletInformation(tableName, new Range())) { + try (var tabletsInfo = c.tableOperations().getTabletInformation(tableName, RowRange.all())) { return tabletsInfo.collect(Collectors.toMap(ti -> { var er = ti.getTabletId().getEndRow(); return er == null ? "NULL" : er.toString(); diff --git a/test/src/main/java/org/apache/accumulo/test/functional/FlushNoFileIT.java b/test/src/main/java/org/apache/accumulo/test/functional/FlushNoFileIT.java index ab2c8838c15..f985b9a4e2f 100644 --- a/test/src/main/java/org/apache/accumulo/test/functional/FlushNoFileIT.java +++ b/test/src/main/java/org/apache/accumulo/test/functional/FlushNoFileIT.java @@ -42,6 +42,7 @@ import org.apache.accumulo.core.data.Key; import org.apache.accumulo.core.data.Mutation; import org.apache.accumulo.core.data.Range; +import org.apache.accumulo.core.data.RowRange; import org.apache.accumulo.core.data.TableId; import org.apache.accumulo.core.data.Value; import org.apache.accumulo.core.dataImpl.KeyExtent; @@ -126,7 +127,8 @@ public void test() throws Exception { }); // Host all tablets - c.tableOperations().setTabletAvailability(tableName, new Range(), TabletAvailability.HOSTED); + c.tableOperations().setTabletAvailability(tableName, RowRange.all(), + TabletAvailability.HOSTED); // Wait for all tablets to be hosted Wait.waitFor(() -> ManagerAssignmentIT.countTabletsWithLocation(c, tableId) == 3); diff --git a/test/src/main/java/org/apache/accumulo/test/functional/ManagerAssignmentIT.java b/test/src/main/java/org/apache/accumulo/test/functional/ManagerAssignmentIT.java index d4b5d9655a2..aec39e56f7e 100644 --- a/test/src/main/java/org/apache/accumulo/test/functional/ManagerAssignmentIT.java +++ b/test/src/main/java/org/apache/accumulo/test/functional/ManagerAssignmentIT.java @@ -61,6 +61,7 @@ import org.apache.accumulo.core.data.Mutation; import org.apache.accumulo.core.data.Range; import org.apache.accumulo.core.data.ResourceGroupId; +import org.apache.accumulo.core.data.RowRange; import org.apache.accumulo.core.data.TableId; import org.apache.accumulo.core.dataImpl.KeyExtent; import org.apache.accumulo.core.fate.FateId; @@ -180,7 +181,7 @@ public void test() throws Exception { assertEquals(TabletAvailability.ONDEMAND, online.getTabletAvailability()); // set the tablet availability to HOSTED - client.tableOperations().setTabletAvailability(tableName, new Range(), + client.tableOperations().setTabletAvailability(tableName, RowRange.all(), TabletAvailability.HOSTED); Predicate hostedOrCurrentNotNull = @@ -196,7 +197,7 @@ public void test() throws Exception { assertEquals(TabletAvailability.HOSTED, always.getTabletAvailability()); // set the hosting availability to never - client.tableOperations().setTabletAvailability(tableName, new Range(), + client.tableOperations().setTabletAvailability(tableName, RowRange.all(), TabletAvailability.UNHOSTED); Predicate unhostedOrCurrentNull = t -> (t.getTabletAvailability() == TabletAvailability.UNHOSTED && !t.hasCurrent()); @@ -210,7 +211,7 @@ public void test() throws Exception { assertEquals(TabletAvailability.UNHOSTED, unhosted.getTabletAvailability()); // set the tablet availability to ONDEMAND - client.tableOperations().setTabletAvailability(tableName, new Range(), + client.tableOperations().setTabletAvailability(tableName, RowRange.all(), TabletAvailability.ONDEMAND); Predicate ondemandHosted = t -> t.getTabletAvailability() == TabletAvailability.ONDEMAND; diff --git a/test/src/main/java/org/apache/accumulo/test/functional/MergeTabletsITBase.java b/test/src/main/java/org/apache/accumulo/test/functional/MergeTabletsITBase.java index 80870f43bca..5a43744bd95 100644 --- a/test/src/main/java/org/apache/accumulo/test/functional/MergeTabletsITBase.java +++ b/test/src/main/java/org/apache/accumulo/test/functional/MergeTabletsITBase.java @@ -57,6 +57,7 @@ import org.apache.accumulo.core.data.Mutation; import org.apache.accumulo.core.data.Range; import org.apache.accumulo.core.data.ResourceGroupId; +import org.apache.accumulo.core.data.RowRange; import org.apache.accumulo.core.data.TableId; import org.apache.accumulo.core.data.Value; import org.apache.accumulo.core.dataImpl.KeyExtent; @@ -176,9 +177,9 @@ public void merge() throws Exception { bw.addMutation(m); } } - c.tableOperations().setTabletAvailability(tableName, new Range("d", "e"), + c.tableOperations().setTabletAvailability(tableName, RowRange.closed("d", "e"), TabletAvailability.HOSTED); - c.tableOperations().setTabletAvailability(tableName, new Range("e", "f"), + c.tableOperations().setTabletAvailability(tableName, RowRange.closed("e", "f"), TabletAvailability.UNHOSTED); c.tableOperations().flush(tableName, null, null, true); c.tableOperations().merge(tableName, new Text("c1"), new Text("f1")); diff --git a/test/src/main/java/org/apache/accumulo/test/functional/OnDemandTabletUnloadingIT.java b/test/src/main/java/org/apache/accumulo/test/functional/OnDemandTabletUnloadingIT.java index a8e3db04603..560583ab35e 100644 --- a/test/src/main/java/org/apache/accumulo/test/functional/OnDemandTabletUnloadingIT.java +++ b/test/src/main/java/org/apache/accumulo/test/functional/OnDemandTabletUnloadingIT.java @@ -47,6 +47,7 @@ import org.apache.accumulo.core.conf.Property; import org.apache.accumulo.core.data.Mutation; import org.apache.accumulo.core.data.Range; +import org.apache.accumulo.core.data.RowRange; import org.apache.accumulo.core.data.TableId; import org.apache.accumulo.core.metadata.schema.TabletMetadata; import org.apache.accumulo.core.spi.ondemand.LastAccessTimeOnDemandTabletUnloader; @@ -197,7 +198,7 @@ public void testTransitionFromHostedToOndemand() throws Exception { // transition all tablets to ondemand. Since no tablets have a hosting requested column set // the manager should unassign all tablets. - c.tableOperations().setTabletAvailability(tableName, new Range(), + c.tableOperations().setTabletAvailability(tableName, RowRange.all(), TabletAvailability.ONDEMAND); Wait.waitFor(() -> ManagerAssignmentIT.countTabletsWithLocation(c, TableId.of(tableId)) == 0); diff --git a/test/src/main/java/org/apache/accumulo/test/functional/SplitMillionIT.java b/test/src/main/java/org/apache/accumulo/test/functional/SplitMillionIT.java index 38479a5eb41..2fa1df8b577 100644 --- a/test/src/main/java/org/apache/accumulo/test/functional/SplitMillionIT.java +++ b/test/src/main/java/org/apache/accumulo/test/functional/SplitMillionIT.java @@ -42,6 +42,7 @@ import org.apache.accumulo.core.data.Key; import org.apache.accumulo.core.data.Mutation; import org.apache.accumulo.core.data.Range; +import org.apache.accumulo.core.data.RowRange; import org.apache.accumulo.core.data.TableId; import org.apache.accumulo.core.data.Value; import org.apache.accumulo.core.iterators.Filter; @@ -153,7 +154,7 @@ public void testOneMillionTablets() throws Exception { long count; t1 = System.currentTimeMillis(); try (var tabletInformation = - c.tableOperations().getTabletInformation(tableName, new Range())) { + c.tableOperations().getTabletInformation(tableName, RowRange.all())) { count = tabletInformation.count(); } t2 = System.currentTimeMillis(); @@ -175,7 +176,7 @@ public void testOneMillionTablets() throws Exception { // of the tablets for the clone table will be hosted. The subsequent merge operation // is a metadata-only operation unless the tablet is hosted. If the tablet is hosted // then the tablet has to be closed making the merge operation take longer. - c.tableOperations().setTabletAvailability(tableName, new Range(), + c.tableOperations().setTabletAvailability(tableName, RowRange.all(), TabletAvailability.UNHOSTED); // clone the table to test cloning with lots of tablets and also to give merge its own table diff --git a/test/src/main/java/org/apache/accumulo/test/functional/TabletAvailabilityIT.java b/test/src/main/java/org/apache/accumulo/test/functional/TabletAvailabilityIT.java index b8e1e4c2888..7ac3edf4505 100644 --- a/test/src/main/java/org/apache/accumulo/test/functional/TabletAvailabilityIT.java +++ b/test/src/main/java/org/apache/accumulo/test/functional/TabletAvailabilityIT.java @@ -44,6 +44,7 @@ import org.apache.accumulo.core.client.admin.TabletAvailability; import org.apache.accumulo.core.data.Mutation; import org.apache.accumulo.core.data.Range; +import org.apache.accumulo.core.data.RowRange; import org.apache.accumulo.core.metadata.SystemTables; import org.apache.accumulo.harness.AccumuloClusterHarness; import org.apache.hadoop.io.Text; @@ -56,7 +57,7 @@ public void testSystemFails() throws Exception { try (AccumuloClient client = Accumulo.newClient().from(getClientProps()).build()) { for (SystemTables t : SystemTables.values()) { assertThrows(AccumuloException.class, () -> client.tableOperations() - .setTabletAvailability(t.tableName(), new Range(), UNHOSTED)); + .setTabletAvailability(t.tableName(), RowRange.all(), UNHOSTED)); } } } @@ -68,7 +69,7 @@ public void testOffline() throws Exception { client.tableOperations().create(table, new NewTableConfiguration().createOffline()); assertThrows(TableOfflineException.class, - () -> client.tableOperations().setTabletAvailability(table, new Range(), HOSTED)); + () -> client.tableOperations().setTabletAvailability(table, RowRange.all(), HOSTED)); } } @@ -94,9 +95,9 @@ public void testBoundries() throws Exception { for (var a1 : TabletAvailability.values()) { for (var a2 : TabletAvailability.values()) { availabilites.put(row(r), a1); - client.tableOperations().setTabletAvailability(table, new Range(row(r++)), a1); + client.tableOperations().setTabletAvailability(table, RowRange.closed(row(r++)), a1); availabilites.put(row(r), a2); - client.tableOperations().setTabletAvailability(table, new Range(row(r++)), a2); + client.tableOperations().setTabletAvailability(table, RowRange.closed(row(r++)), a2); } } @@ -104,7 +105,7 @@ public void testBoundries() throws Exception { // ensure tablet availability is as expected SortedMap availabilitesSeen = new TreeMap<>(); - client.tableOperations().getTabletInformation(table, new Range()).forEach(ti -> { + client.tableOperations().getTabletInformation(table, RowRange.all()).forEach(ti -> { if (ti.getTabletId().getEndRow() != null) { availabilitesSeen.put(ti.getTabletId().getEndRow().toString(), ti.getTabletAvailability()); @@ -149,7 +150,7 @@ public void testBoundries() throws Exception { } // verify nothing was actually written to the unhosted tablets - client.tableOperations().setTabletAvailability(table, new Range(), HOSTED); + client.tableOperations().setTabletAvailability(table, RowRange.all(), HOSTED); for (var entry : availabilites.entrySet()) { if (entry.getValue() == UNHOSTED) { var row = entry.getKey(); From 814e8cc1653a9081740ce36c1e3cef96566065e8 Mon Sep 17 00:00:00 2001 From: Dom Garguilo Date: Mon, 6 Oct 2025 14:32:04 -0400 Subject: [PATCH 2/3] fix javadoc method mention --- .../apache/accumulo/core/client/admin/TabletInformation.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/apache/accumulo/core/client/admin/TabletInformation.java b/core/src/main/java/org/apache/accumulo/core/client/admin/TabletInformation.java index adf0427231b..0b92e8b64eb 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/admin/TabletInformation.java +++ b/core/src/main/java/org/apache/accumulo/core/client/admin/TabletInformation.java @@ -20,7 +20,7 @@ import java.util.Optional; -import org.apache.accumulo.core.data.Range; +import org.apache.accumulo.core.data.RowRange; import org.apache.accumulo.core.data.TabletId; /** @@ -30,7 +30,7 @@ public interface TabletInformation { /** * Used to limit what information is obtained per tablet when calling - * {@link TableOperations#getTabletInformation(String, Range, Field...)} + * {@link TableOperations#getTabletInformation(String, RowRange, Field...)} * * @since 4.0.0 */ From 725b534155ae9bcf7d267c2761d074d4ed027162 Mon Sep 17 00:00:00 2001 From: "Dom G." Date: Thu, 20 Nov 2025 15:39:14 -0500 Subject: [PATCH 3/3] Refine Javadoc for tablet availability method Removed redundant information about non-row portions of keys in the Javadoc. --- .../org/apache/accumulo/core/client/admin/TableOperations.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperations.java b/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperations.java index ce19066684f..c4ebda2419f 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperations.java +++ b/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperations.java @@ -1064,8 +1064,7 @@ default TimeType getTimeType(String tableName) throws TableNotFoundException { /** * Sets the tablet availability for a range of Tablets in the specified table, but does not wait * for the tablets to reach this availability state. The supplied row range is compared against - * the tablets' start/end rows using its lower/upper bounds and inclusivity flags; any non-row - * portions of the keys are ignored. + * the tablets' start/end rows using its lower/upper bounds and inclusivity flags. * * @param tableName table name * @param rowRange tablet row range