Skip to content

Commit 1430a7e

Browse files
committed
Rename hosting goal to availability
1 parent f9e4c92 commit 1430a7e

File tree

8 files changed

+51
-49
lines changed

8 files changed

+51
-49
lines changed

core/src/main/java/org/apache/accumulo/core/client/admin/ImportConfiguration.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ public interface ImportConfiguration {
4545
boolean isKeepMappings();
4646

4747
/**
48-
* @return the initial hosting goal for the table
48+
* @return the initial tablet availability for the table
4949
*
5050
* @since 4.0.0
5151
*/
52-
TabletHostingGoal getInitialHostingGoal();
52+
TabletAvailability getInitialAvailability();
5353

5454
/**
5555
* A ImportConfiguration builder
@@ -81,12 +81,12 @@ interface Builder {
8181
Builder setKeepMappings(boolean keepMappings);
8282

8383
/**
84-
* set the initial hosting goal for the table
84+
* set the initial tablet availability for the table
8585
*
86-
* @param initialTabletGoal the initial hosting goal for the table
86+
* @param initialAvailability the initial tablet availability for the table
8787
* @since 4.0.0
8888
*/
89-
Builder setInitialHostingGoal(TabletHostingGoal initialTabletGoal);
89+
Builder setInitialAvailability(TabletAvailability initialAvailability);
9090

9191
/**
9292
* Build the import table configuration

core/src/main/java/org/apache/accumulo/core/clientImpl/ImportConfigurationImpl.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@
1919
package org.apache.accumulo.core.clientImpl;
2020

2121
import org.apache.accumulo.core.client.admin.ImportConfiguration;
22-
import org.apache.accumulo.core.client.admin.TabletHostingGoal;
22+
import org.apache.accumulo.core.client.admin.TabletAvailability;
2323

2424
import com.google.common.base.Preconditions;
2525

2626
public class ImportConfigurationImpl implements ImportConfiguration, ImportConfiguration.Builder {
2727
private boolean built = false;
2828
private boolean keepOffline = false;
2929
private boolean keepMappingsFile = false;
30-
private TabletHostingGoal initialHostingGoal = TabletHostingGoal.ONDEMAND;
30+
private TabletAvailability initialAvailability = TabletAvailability.ONDEMAND;
3131

3232
private final static String BUILT_ERROR_MSG = "ImportConfiguration was already built";
3333
private final static String NOT_BUILT_ERROR_MSG = "ImportConfiguration was not built yet";
@@ -47,10 +47,10 @@ public Builder setKeepMappings(boolean keepMappings) {
4747
}
4848

4949
@Override
50-
public Builder setInitialHostingGoal(TabletHostingGoal initialTabletHostingGoal) {
50+
public Builder setInitialAvailability(TabletAvailability initialAvailability) {
5151
Preconditions.checkState(!built, BUILT_ERROR_MSG);
52-
Preconditions.checkState(initialTabletHostingGoal != null, "initialTabletHostingGoal is null");
53-
this.initialHostingGoal = initialTabletHostingGoal;
52+
Preconditions.checkState(initialAvailability != null, "initialAvailability is null");
53+
this.initialAvailability = initialAvailability;
5454
return this;
5555
}
5656

@@ -73,8 +73,8 @@ public boolean isKeepMappings() {
7373
}
7474

7575
@Override
76-
public TabletHostingGoal getInitialHostingGoal() {
76+
public TabletAvailability getInitialAvailability() {
7777
Preconditions.checkState(built, NOT_BUILT_ERROR_MSG);
78-
return initialHostingGoal;
78+
return initialAvailability;
7979
}
8080
}

core/src/main/java/org/apache/accumulo/core/clientImpl/TableOperationsImpl.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1637,7 +1637,7 @@ public void importTable(String tableName, Set<String> importDirs, ImportConfigur
16371637
args.add(0, ByteBuffer.wrap(tableName.getBytes(UTF_8)));
16381638
args.add(1, ByteBuffer.wrap(Boolean.toString(keepOffline).getBytes(UTF_8)));
16391639
args.add(2, ByteBuffer.wrap(Boolean.toString(keepMapping).getBytes(UTF_8)));
1640-
args.add(3, ByteBuffer.wrap(ic.getInitialHostingGoal().name().getBytes(UTF_8)));
1640+
args.add(3, ByteBuffer.wrap(ic.getInitialAvailability().name().getBytes(UTF_8)));
16411641
checkedImportDirs.stream().map(s -> s.getBytes(UTF_8)).map(ByteBuffer::wrap).forEach(args::add);
16421642

16431643
try {

server/manager/src/main/java/org/apache/accumulo/manager/FateServiceHandler.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -575,8 +575,8 @@ public void executeFateOperation(TInfo tinfo, TCredentials c, TFateId opid, Fate
575575
validateName(arguments.get(0), tableOp, NEW_TABLE_NAME.and(NOT_BUILTIN_TABLE));
576576
boolean keepOffline = Boolean.parseBoolean(ByteBufferUtil.toString(arguments.get(1)));
577577
boolean keepMappings = Boolean.parseBoolean(ByteBufferUtil.toString(arguments.get(2)));
578-
TabletAvailability initialAvailability =
579-
TabletAvailability.valueOf(ByteBufferUtil.toString(arguments.get(3)));
578+
TabletAvailability initialAvailability =
579+
TabletAvailability.valueOf(ByteBufferUtil.toString(arguments.get(3)));
580580

581581
List<ByteBuffer> exportDirArgs =
582582
arguments.stream().skip(IMPORT_DIR_OFFSET + 1).collect(Collectors.toList());

server/manager/src/main/java/org/apache/accumulo/manager/tableOps/tableImport/ImportTable.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
import org.apache.accumulo.core.Constants;
3535
import org.apache.accumulo.core.client.AccumuloException;
36-
import org.apache.accumulo.core.client.admin.TabletHostingGoal;
36+
import org.apache.accumulo.core.client.admin.TabletAvailability;
3737
import org.apache.accumulo.core.clientImpl.AcceptableThriftTableOperationException;
3838
import org.apache.accumulo.core.clientImpl.TableOperationsImpl;
3939
import org.apache.accumulo.core.clientImpl.thrift.TableOperation;
@@ -65,16 +65,16 @@ public class ImportTable extends ManagerRepo {
6565
private final ImportedTableInfo tableInfo;
6666

6767
public ImportTable(String user, String tableName, Set<String> exportDirs, NamespaceId namespaceId,
68-
boolean keepMappings, boolean keepOffline, TabletHostingGoal initialHostingGoal) {
68+
boolean keepMappings, boolean keepOffline, TabletAvailability initialAvailability) {
6969
tableInfo = new ImportedTableInfo();
7070
tableInfo.tableName = tableName;
7171
tableInfo.user = user;
7272
tableInfo.namespaceId = namespaceId;
7373
tableInfo.directories = parseExportDir(exportDirs);
7474
tableInfo.keepMappings = keepMappings;
7575
tableInfo.keepOffline = keepOffline;
76-
Preconditions.checkState(initialHostingGoal != null, "initialHostingGoal is null");
77-
tableInfo.initialHostingGoal = initialHostingGoal;
76+
Preconditions.checkState(initialAvailability != null, "initialAvailability is null");
77+
tableInfo.initialAvailability = initialAvailability;
7878
}
7979

8080
@Override

server/manager/src/main/java/org/apache/accumulo/manager/tableOps/tableImport/ImportedTableInfo.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import java.io.Serializable;
2222
import java.util.List;
2323

24-
import org.apache.accumulo.core.client.admin.TabletHostingGoal;
24+
import org.apache.accumulo.core.client.admin.TabletAvailability;
2525
import org.apache.accumulo.core.data.NamespaceId;
2626
import org.apache.accumulo.core.data.TableId;
2727

@@ -37,7 +37,7 @@ class ImportedTableInfo implements Serializable {
3737
public String exportFile;
3838
public boolean keepMappings;
3939
public boolean keepOffline;
40-
public TabletHostingGoal initialHostingGoal = TabletHostingGoal.ONDEMAND;
40+
public TabletAvailability initialAvailability = TabletAvailability.ONDEMAND;
4141

4242
static class DirectoryMapping implements Serializable {
4343
private static final long serialVersionUID = 1L;

server/manager/src/main/java/org/apache/accumulo/manager/tableOps/tableImport/PopulateMetadataTable.java

+8-9
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import static java.nio.charset.StandardCharsets.UTF_8;
2222
import static org.apache.accumulo.core.Constants.IMPORT_MAPPINGS_FILE;
23+
import static org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.TabletColumnFamily.AVAILABILITY_COLUMN;
2324

2425
import java.io.BufferedInputStream;
2526
import java.io.BufferedReader;
@@ -128,11 +129,11 @@ public Repo<Manager> call(long tid, Manager manager) throws Exception {
128129
Text currentRow = null;
129130
int dirCount = 0;
130131

131-
TabletAvailability initialHostingGoal = tableInfo.initialHostingGoal;
132-
if (initialHostingGoal == null) {
133-
log.error("Initial hosting goal is null and shouldn't be, defaulting to "
132+
TabletAvailability initialAvailability = tableInfo.initialAvailability;
133+
if (initialAvailability == null) {
134+
log.error("Initial tablet availability is null and shouldn't be, defaulting to "
134135
+ TabletAvailability.ONDEMAND);
135-
initialHostingGoal = TabletAvailability.ONDEMAND;
136+
initialAvailability = TabletAvailability.ONDEMAND;
136137
}
137138

138139
while (true) {
@@ -165,8 +166,7 @@ public Repo<Manager> call(long tid, Manager manager) throws Exception {
165166
if (m == null || !currentRow.equals(metadataRow)) {
166167

167168
if (m != null) {
168-
TabletAvailability.GOAL_COLUMN.put(m,
169-
TabletAvailabilityUtil.toValue(initialHostingGoal));
169+
AVAILABILITY_COLUMN.put(m, TabletAvailabilityUtil.toValue(initialAvailability));
170170
mbw.addMutation(m);
171171
}
172172

@@ -181,9 +181,8 @@ public Repo<Manager> call(long tid, Manager manager) throws Exception {
181181
currentRow = metadataRow;
182182
}
183183

184-
// add the initial hosting goal
185-
TabletAvailability.GOAL_COLUMN.put(m,
186-
TabletAvailabilityUtil.toValue(initialHostingGoal));
184+
// add the initial tablet availability
185+
AVAILABILITY_COLUMN.put(m, TabletAvailabilityUtil.toValue(initialAvailability));
187186

188187
m.put(key.getColumnFamily(), cq, val);
189188

test/src/main/java/org/apache/accumulo/test/ImportExportIT.java

+22-19
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
import org.apache.accumulo.core.client.TableNotFoundException;
5050
import org.apache.accumulo.core.client.admin.ImportConfiguration;
5151
import org.apache.accumulo.core.client.admin.NewTableConfiguration;
52-
import org.apache.accumulo.core.client.admin.TabletHostingGoal;
52+
import org.apache.accumulo.core.client.admin.TabletAvailability;
5353
import org.apache.accumulo.core.data.Key;
5454
import org.apache.accumulo.core.data.Mutation;
5555
import org.apache.accumulo.core.data.Range;
@@ -96,18 +96,19 @@ protected Duration defaultTimeout() {
9696
}
9797

9898
/**
99-
* Test that we can override a hosting goal when importing a table.
99+
* Test that we can override a tablet availability when importing a table.
100100
*/
101101
@Test
102-
public void importChangeHostingGoal() throws Exception {
102+
public void overrideAvailabilityOnImport() throws Exception {
103103
try (AccumuloClient client = Accumulo.newClient().from(getClientProps()).build()) {
104104

105105
String[] tableNames = getUniqueNames(2);
106106
String srcTable = tableNames[0], destTable = tableNames[1];
107107

108-
// create the source table with the initial hosting goal
109-
TabletHostingGoal srcGoal = TabletHostingGoal.ALWAYS;
110-
NewTableConfiguration ntc = new NewTableConfiguration().withInitialHostingGoal(srcGoal);
108+
// create the source table with the initial tablet availability
109+
TabletAvailability srcAvailability = TabletAvailability.HOSTED;
110+
NewTableConfiguration ntc =
111+
new NewTableConfiguration().withInitialTabletAvailability(srcAvailability);
111112
client.tableOperations().create(srcTable, ntc);
112113

113114
populateTable(client, srcTable);
@@ -121,8 +122,8 @@ public void importChangeHostingGoal() throws Exception {
121122
log.info("Exporting table to {}", exportDir);
122123
log.info("Importing table from {}", Arrays.toString(importDirs));
123124

124-
// ensure the table is the hosting goal we expect
125-
waitForHostingGoal(client, srcTable, srcGoal);
125+
// ensure the table has the tablet availability we expect
126+
waitForAvailability(client, srcTable, srcAvailability);
126127

127128
// Offline the table
128129
client.tableOperations().offline(srcTable, true);
@@ -132,16 +133,16 @@ public void importChangeHostingGoal() throws Exception {
132133
copyExportedFilesToImportDirs(fs, exportDir, importDirs);
133134

134135
// Import the exported data into a new table
135-
final TabletHostingGoal newHostingGoal = TabletHostingGoal.NEVER;
136-
assertNotEquals(srcGoal, newHostingGoal,
137-
"New hosting goal should be different from the old one in order to test override.");
136+
final TabletAvailability newAvailability = TabletAvailability.UNHOSTED;
137+
assertNotEquals(srcAvailability, newAvailability,
138+
"New tablet availability should be different from the old one in order to test we can override.");
138139

139140
ImportConfiguration importConfig =
140-
ImportConfiguration.builder().setInitialHostingGoal(newHostingGoal).build();
141+
ImportConfiguration.builder().setInitialAvailability(newAvailability).build();
141142
client.tableOperations().importTable(destTable,
142143
Arrays.stream(importDirs).map(Path::toString).collect(Collectors.toSet()), importConfig);
143144

144-
waitForHostingGoal(client, destTable, newHostingGoal);
145+
waitForAvailability(client, destTable, newAvailability);
145146
}
146147
}
147148

@@ -451,17 +452,19 @@ private void copyExportedFilesToImportDirs(FileSystem fs, Path exportDir, Path[]
451452
}
452453
}
453454

454-
private static void waitForHostingGoal(AccumuloClient client, String tableName,
455-
TabletHostingGoal goal) {
455+
private static void waitForAvailability(AccumuloClient client, String tableName,
456+
TabletAvailability expectedAvailability) {
456457
Wait.waitFor(() -> client.tableOperations().getTabletInformation(tableName, new Range())
457458
.allMatch(tabletInformation -> {
458-
TabletHostingGoal currentGoal = tabletInformation.getHostingGoal();
459-
boolean goalReached = currentGoal == goal;
459+
TabletAvailability currentAvailability = tabletInformation.getTabletAvailability();
460+
boolean goalReached = currentAvailability == expectedAvailability;
460461
if (!goalReached) {
461-
log.info("Current hosting goal: " + currentGoal + ". Waiting for " + goal);
462+
log.info("Current tablet availability: " + currentAvailability + ". Waiting for "
463+
+ expectedAvailability);
462464
}
463465
return goalReached;
464-
}), 30_000L, 1_000L, "Timed out waiting for hosting goal " + goal + " on " + tableName);
466+
}), 30_000L, 1_000L,
467+
"Timed out waiting for tablet availability " + expectedAvailability + " on " + tableName);
465468
}
466469

467470
}

0 commit comments

Comments
 (0)