This is an automated email from the ASF dual-hosted git repository. mmiller pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/main by this push: new 47cdd872d5 Fast fail table export if online check passes (#2877) 47cdd872d5 is described below commit 47cdd872d5ba6a3cdfb47cf15b6fadcd4bfc6fe9 Author: Mike Miller <mmil...@apache.org> AuthorDate: Fri Aug 12 19:16:11 2022 +0000 Fast fail table export if online check passes (#2877) --- .../java/org/apache/accumulo/core/client/admin/TableOperations.java | 3 ++- .../org/apache/accumulo/core/clientImpl/TableOperationsImpl.java | 5 +++++ test/src/main/java/org/apache/accumulo/test/ImportExportIT.java | 5 +++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperations.java b/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperations.java index 09a1b0e3dd..e4bf572eb5 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperations.java +++ b/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperations.java @@ -187,7 +187,8 @@ public interface TableOperations { } /** - * Imports a table exported via exportTable and copied via hadoop distcp. + * Imports a table exported via {@link #exportTable(String, String)} and then copied via hadoop + * distcp. * * @param tableName * Name of a table to create and import into. diff --git a/core/src/main/java/org/apache/accumulo/core/clientImpl/TableOperationsImpl.java b/core/src/main/java/org/apache/accumulo/core/clientImpl/TableOperationsImpl.java index e2cfc4840c..849465f62f 100644 --- a/core/src/main/java/org/apache/accumulo/core/clientImpl/TableOperationsImpl.java +++ b/core/src/main/java/org/apache/accumulo/core/clientImpl/TableOperationsImpl.java @@ -1621,6 +1621,11 @@ public class TableOperationsImpl extends TableOperationsHelper { EXISTING_TABLE_NAME.validate(tableName); checkArgument(exportDir != null, "exportDir is null"); + if (isOnline(tableName)) { + throw new IllegalStateException("The table " + tableName + " is online; exportTable requires" + + " a table to be offline before exporting."); + } + List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableName.getBytes(UTF_8)), ByteBuffer.wrap(exportDir.getBytes(UTF_8))); Map<String,String> opts = Collections.emptyMap(); 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 429fd1bc44..fc481fc655 100644 --- a/test/src/main/java/org/apache/accumulo/test/ImportExportIT.java +++ b/test/src/main/java/org/apache/accumulo/test/ImportExportIT.java @@ -21,6 +21,7 @@ package org.apache.accumulo.test; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; @@ -122,6 +123,10 @@ public class ImportExportIT extends AccumuloClusterHarness { log.info("Exporting table to {}", exportDir); log.info("Importing table from {}", importDirs); + // test fast fail offline check + assertThrows(IllegalStateException.class, + () -> client.tableOperations().exportTable(srcTable, exportDir.toString())); + // Offline the table client.tableOperations().offline(srcTable, true); // Then export it