Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ImportConfiguration.builder().setKeepOffline() #4115

Merged
merged 1 commit into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -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);
DomGarguilo marked this conversation as resolved.
Show resolved Hide resolved
client.tableOperations().online(destTable, true);

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