You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by do...@apache.org on 2024/01/05 15:55:35 UTC

(accumulo) branch 2.1 updated: Fix ImportConfiguration.builder().setKeepOffline() (#4115)

This is an automated email from the ASF dual-hosted git repository.

domgarguilo pushed a commit to branch 2.1
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/2.1 by this push:
     new df268644b7 Fix ImportConfiguration.builder().setKeepOffline() (#4115)
df268644b7 is described below

commit df268644b766bbf84e34e7f6fd30a609ab85cc61
Author: Dom G <do...@apache.org>
AuthorDate: Fri Jan 5 10:55:28 2024 -0500

    Fix ImportConfiguration.builder().setKeepOffline() (#4115)
    
    * fixes a bug where `setKeepOffline` would never transition a table from the NEW state to OFFLINE
---
 .../main/java/org/apache/accumulo/manager/FateServiceHandler.java  | 7 +++----
 .../accumulo/manager/tableOps/tableImport/FinishImportTable.java   | 5 ++---
 .../apache/accumulo/manager/tableOps/tableImport/ImportTable.java  | 4 ++--
 .../accumulo/manager/tableOps/tableImport/ImportedTableInfo.java   | 2 +-
 test/src/main/java/org/apache/accumulo/test/ImportExportIT.java    | 2 ++
 5 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/server/manager/src/main/java/org/apache/accumulo/manager/FateServiceHandler.java b/server/manager/src/main/java/org/apache/accumulo/manager/FateServiceHandler.java
index f4d1257128..6c6d0f5a32 100644
--- a/server/manager/src/main/java/org/apache/accumulo/manager/FateServiceHandler.java
+++ b/server/manager/src/main/java/org/apache/accumulo/manager/FateServiceHandler.java
@@ -607,10 +607,9 @@ class FateServiceHandler implements FateService.Iface {
 
         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: {
diff --git a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/tableImport/FinishImportTable.java b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/tableImport/FinishImportTable.java
index 0df0771ecf..e5df722043 100644
--- a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/tableImport/FinishImportTable.java
+++ b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/tableImport/FinishImportTable.java
@@ -52,9 +52,8 @@ class FinishImportTable extends ManagerRepo {
       }
     }
 
-    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);
diff --git a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/tableImport/ImportTable.java b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/tableImport/ImportTable.java
index 49e67f8e83..484db2b963 100644
--- a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/tableImport/ImportTable.java
+++ b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/tableImport/ImportTable.java
@@ -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
diff --git a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/tableImport/ImportedTableInfo.java b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/tableImport/ImportedTableInfo.java
index f3d84a9c22..306c7a38e5 100644
--- a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/tableImport/ImportedTableInfo.java
+++ b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/tableImport/ImportedTableInfo.java
@@ -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;
diff --git a/test/src/main/java/org/apache/accumulo/test/ImportExportIT.java b/test/src/main/java/org/apache/accumulo/test/ImportExportIT.java
index 5e40ea3751..49f01c1b36 100644
--- a/test/src/main/java/org/apache/accumulo/test/ImportExportIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/ImportExportIT.java
@@ -47,6 +47,7 @@ import org.apache.accumulo.core.data.Key;
 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;
@@ -294,6 +295,7 @@ public class ImportExportIT extends AccumuloClusterHarness {
 
       // 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