Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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<TabletInformation> getTabletInformation(final String tableName, final Range range,
TabletInformation.Field... fields) throws TableNotFoundException {
default Stream<TabletInformation> getTabletInformation(final String tableName,
final RowRange rowRange, TabletInformation.Field... fields) throws TableNotFoundException {
throw new UnsupportedOperationException();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2221,16 +2221,18 @@ private void validatePropertiesToSet(Map<String,String> opts, Map<String,String>
}

@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());
Expand All @@ -2255,10 +2257,11 @@ public void setTabletAvailability(String tableName, Range range, TabletAvailabil
}

@Override
public Stream<TabletInformation> getTabletInformation(final String tableName, final Range range,
TabletInformation.Field... fields) throws TableNotFoundException {
public Stream<TabletInformation> 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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -157,7 +157,7 @@ public void run() {
try {
final String tableName = ctx.getQualifiedTableName(tableId);
try (Stream<TabletInformation> 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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() {
Expand All @@ -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())));
}
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -78,7 +78,7 @@ public int execute(String fullCommand, CommandLine cl, Shell shellState) throws
lines.add("TABLE: " + name);

try (Stream<TabletInformation> 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<String,String> idMap = new TreeMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down Expand Up @@ -1105,7 +1105,7 @@ private static void verifyEverythingTable(AccumuloClient client, String table,
IteratorUtil.IteratorScope.scan));

try (Stream<TabletInformation> tabletInfo =
client.tableOperations().getTabletInformation(table, new Range())) {
client.tableOperations().getTabletInformation(table, RowRange.all())) {
tabletInfo.forEach(tabletInformation -> {
if (tabletInformation.getTabletId().getEndRow() == null) {
assertEquals(expectedAvailabilityForDefaultTable,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -801,9 +801,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()));
}
}
Expand Down
11 changes: 6 additions & 5 deletions test/src/main/java/org/apache/accumulo/test/ImportExportIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Text> 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
Expand All @@ -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")));
Expand All @@ -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.
Expand Down Expand Up @@ -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"));
Expand Down
3 changes: 2 additions & 1 deletion test/src/main/java/org/apache/accumulo/test/LocatorIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down
13 changes: 7 additions & 6 deletions test/src/main/java/org/apache/accumulo/test/ScanServerIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
Loading