Skip to content

Commit

Permalink
Fix ImportConfiguration.builder().setKeepOffline() (#4115)
Browse files Browse the repository at this point in the history
* fixes a bug where `setKeepOffline` would never transition a table from the NEW state to OFFLINE
  • Loading branch information
DomGarguilo authored Jan 5, 2024
1 parent 08628c0 commit df26864
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -607,10 +607,9 @@ public void executeFateOperation(TInfo tinfo, TCredentials c, long opid, FateOpe

goalMessage += "Import table with new name: " + tableName + " from " + exportDirs;
manager.fate()
.seedTransaction(
op.toString(), opid, new TraceRepo<>(new ImportTable(c.getPrincipal(), tableName,
exportDirs, namespaceId, keepMappings, !keepOffline)),
autoCleanup, goalMessage);
.seedTransaction(op.toString(), opid, new TraceRepo<>(new ImportTable(c.getPrincipal(),
tableName, exportDirs, namespaceId, keepMappings, keepOffline)), autoCleanup,
goalMessage);
break;
}
case TABLE_EXPORT: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@ public Repo<Manager> call(long tid, Manager env) throws Exception {
}
}

if (tableInfo.onlineTable) {
env.getTableManager().transitionTableState(tableInfo.tableId, TableState.ONLINE);
}
final TableState newState = tableInfo.keepOffline ? TableState.OFFLINE : TableState.ONLINE;
env.getTableManager().transitionTableState(tableInfo.tableId, newState);

Utils.unreserveNamespace(env, tableInfo.namespaceId, tid, false);
Utils.unreserveTable(env, tableInfo.tableId, tid, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ public class ImportTable extends ManagerRepo {
private final ImportedTableInfo tableInfo;

public ImportTable(String user, String tableName, Set<String> exportDirs, NamespaceId namespaceId,
boolean keepMappings, boolean onlineTable) {
boolean keepMappings, boolean keepOffline) {
tableInfo = new ImportedTableInfo();
tableInfo.tableName = tableName;
tableInfo.user = user;
tableInfo.namespaceId = namespaceId;
tableInfo.directories = parseExportDir(exportDirs);
tableInfo.keepMappings = keepMappings;
tableInfo.onlineTable = onlineTable;
tableInfo.keepOffline = keepOffline;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ImportedTableInfo implements Serializable {
public List<DirectoryMapping> directories;
public String exportFile;
public boolean keepMappings;
public boolean onlineTable;
public boolean keepOffline;

static class DirectoryMapping implements Serializable {
private static final long serialVersionUID = 1L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import org.apache.accumulo.core.data.Mutation;
import org.apache.accumulo.core.data.TableId;
import org.apache.accumulo.core.data.Value;
import org.apache.accumulo.core.manager.state.tables.TableState;
import org.apache.accumulo.core.metadata.MetadataTable;
import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection;
import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.DataFileColumnFamily;
Expand Down Expand Up @@ -294,6 +295,7 @@ public void testExportImportOffline() throws Exception {

// verify the new table is offline
assertFalse(client.tableOperations().isOnline(destTable), "Table should have been offline.");
assertEquals(getServerContext().getTableState(TableId.of(tableId)), TableState.OFFLINE);
client.tableOperations().online(destTable, true);

// Get all `file` colfams from the metadata table for the new table
Expand Down

0 comments on commit df26864

Please sign in to comment.