dlmarion commented on code in PR #3379:
URL: https://github.com/apache/accumulo/pull/3379#discussion_r1186139049
##########
test/src/main/java/org/apache/accumulo/test/NewTableConfigurationIT.java:
##########
@@ -93,6 +100,85 @@ public void testSetPropertiesOverwriteOlderProperties()
}
}
+ @Test
+ public void testCreateTableWithInitialHostingGoal() throws AccumuloException,
+ AccumuloSecurityException, TableNotFoundException, TableExistsException {
+ try (AccumuloClient client =
Accumulo.newClient().from(getClientProps()).build()) {
+
+ String[] tableNames = getUniqueNames(8);
+
+ // use a default NewTableConfiguration
+ verifyNtcWithGoal(client, tableNames[0], null, null);
+ // set initial goals for tables upon creation, without splits
+ verifyNtcWithGoal(client, tableNames[1], TabletHostingGoal.ONDEMAND,
null);
+ verifyNtcWithGoal(client, tableNames[2], TabletHostingGoal.ALWAYS, null);
+ verifyNtcWithGoal(client, tableNames[3], TabletHostingGoal.NEVER, null);
+
+ SortedSet<Text> splits = new TreeSet<>();
+ splits.add(new Text("d"));
+ splits.add(new Text("h"));
+ splits.add(new Text("m"));
+ splits.add(new Text("r"));
+ splits.add(new Text("w"));
+
+ // Use NTC to set initial splits. Verify each tablet has hosting goal
set.
+ // Should work with no goal explicitly supplied as well as each of the
accepted goals
+ verifyNtcWithGoal(client, tableNames[4], null, splits);
+ verifyNtcWithGoal(client, tableNames[5], TabletHostingGoal.ONDEMAND,
splits);
+ verifyNtcWithGoal(client, tableNames[6], TabletHostingGoal.ALWAYS,
splits);
+ verifyNtcWithGoal(client, tableNames[7], TabletHostingGoal.NEVER,
splits);
+ }
+ }
+
+ // Verify that NewTableConfiguration correctly sets the initial hosting goal
on a table, both with
+ // and without initial splits being set.
+ private void verifyNtcWithGoal(AccumuloClient client, String tableName,
TabletHostingGoal goal,
+ SortedSet<Text> splits) throws TableNotFoundException, AccumuloException,
+ AccumuloSecurityException, TableExistsException {
+
+ NewTableConfiguration ntc = new NewTableConfiguration();
+
+ // If goal not supplied via NewTableConfiguration, expect ONDEMAND as
default
+ String expectedGoal = TabletHostingGoal.ONDEMAND.toString();
+ if (goal != null) {
+ expectedGoal = goal.toString();
+ ntc.withInitialHostingGoal(goal);
+ }
+
+ // Set expected number of tablets if no splits are provided
+ int expectedTabletCount = 1;
+ if (splits != null) {
+ expectedTabletCount = splits.size() + 1;
+ ntc.withSplits(splits);
+ }
+ client.tableOperations().create(tableName, ntc);
+
+ String tableId = getTableId(tableName);
+ Text beginRow;
+ Text endRow = new Text(tableId + "<");
+ if (expectedTabletCount == 1) {
+ beginRow = endRow;
+ } else {
+ beginRow = new Text(tableId + ";" + splits.first());
+ }
+ Range range = new Range(beginRow, endRow);
+ try (Scanner scanner = client.createScanner("accumulo.metadata")) {
+ scanner.fetchColumn(new Text("hosting"), new Text("goal"));
Review Comment:
```suggestion
HostingColumnFamily.GOAL_COLUMN.fetch(scanner);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]