mirror of
https://github.com/apache/sqoop.git
synced 2025-05-04 01:32:20 +08:00
SQOOP-3332: Extend Documentation of --resilient flag and add warning message when detected
(Fero Szabo via Boglarka Egyed)
This commit is contained in:
parent
8e45d2b38d
commit
b790c606af
@ -147,17 +147,32 @@ $ sqoop export ... --export-dir custom_dir --table custom_table -- --identity-in
|
|||||||
Resilient operations
|
Resilient operations
|
||||||
^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
You can override the default and use resilient operations during export.
|
You can override the default and use resilient operations during export or import.
|
||||||
This will retry failed operations, i.e. if the connection gets dropped by
|
This will retry failed operations, i.e. if the connection gets dropped by
|
||||||
SQL Server, the mapper will try to reconnect and continue from where it was before.
|
SQL Server, the mapper will try to reconnect and continue from where it was before.
|
||||||
The split-by column has to be specified and it is also required to be unique
|
|
||||||
and in ascending order.
|
|
||||||
For example:
|
|
||||||
|
|
||||||
|
In case of export, the +\--resilient+ option will ensure that Sqoop will try to recover
|
||||||
|
from connection resets.
|
||||||
|
|
||||||
|
In case of import, however, one has to use both the +\--resilient+ option and specify
|
||||||
|
the +\--split-by+ column to trigger the retry mechanism. An important requirement is
|
||||||
|
that the data must be unique and ordered ascending by the split-by column, otherwise
|
||||||
|
records could be either lost or duplicated.
|
||||||
|
|
||||||
|
Example commands using resilient operations:
|
||||||
----
|
----
|
||||||
$ sqoop export ... --export-dir custom_dir --table custom_table -- --resilient
|
$ sqoop export ... --export-dir custom_dir --table custom_table -- --resilient
|
||||||
----
|
----
|
||||||
|
|
||||||
|
Importing from a table:
|
||||||
|
----
|
||||||
|
$ sqoop import ... --table custom_table --split-by id -- --resilient
|
||||||
|
----
|
||||||
|
|
||||||
|
Importing via a query:
|
||||||
|
----
|
||||||
|
$ sqoop import ... --query "SELECT ... WHERE $CONDITIONS" --split-by ordered_column -- --resilient
|
||||||
|
|
||||||
Schema support
|
Schema support
|
||||||
^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
@ -333,6 +333,11 @@ void parseExtraArgs(String[] args) throws ParseException {
|
|||||||
this.tableHints = hints;
|
this.tableHints = hints;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cmdLine.hasOption(SqlServerManagerContextConfigurator.RESILIENT_OPTION)) {
|
||||||
|
LOG.warn("Sqoop will use resilient operations! In case of import, " +
|
||||||
|
"the split-by column also has to be specified, unique, and in ascending order.");
|
||||||
|
}
|
||||||
|
|
||||||
identityInserts = cmdLine.hasOption(IDENTITY_INSERT);
|
identityInserts = cmdLine.hasOption(IDENTITY_INSERT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -359,6 +364,9 @@ private RelatedOptions getExtraOptions() {
|
|||||||
.withDescription("Allow identity inserts")
|
.withDescription("Allow identity inserts")
|
||||||
.withLongOpt(IDENTITY_INSERT).create());
|
.withLongOpt(IDENTITY_INSERT).create());
|
||||||
|
|
||||||
|
extraOptions.addOption(OptionBuilder
|
||||||
|
.withLongOpt(SqlServerManagerContextConfigurator.RESILIENT_OPTION).create());
|
||||||
|
|
||||||
return extraOptions;
|
return extraOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
public class SqlServerManagerContextConfigurator {
|
public class SqlServerManagerContextConfigurator {
|
||||||
|
|
||||||
private static final String RESILIENT_OPTION = "resilient";
|
public static final String RESILIENT_OPTION = "resilient";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the user has requested the operation to be resilient.
|
* Check if the user has requested the operation to be resilient.
|
||||||
|
@ -28,9 +28,11 @@
|
|||||||
import org.apache.sqoop.manager.SQLServerManager;
|
import org.apache.sqoop.manager.SQLServerManager;
|
||||||
import org.apache.sqoop.testutil.ArgumentArrayBuilder;
|
import org.apache.sqoop.testutil.ArgumentArrayBuilder;
|
||||||
import org.apache.sqoop.testutil.ImportJobTestCase;
|
import org.apache.sqoop.testutil.ImportJobTestCase;
|
||||||
|
import org.apache.sqoop.util.ExpectedLogMessage;
|
||||||
import org.apache.sqoop.util.FileListing;
|
import org.apache.sqoop.util.FileListing;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Parameterized;
|
import org.junit.runners.Parameterized;
|
||||||
@ -129,7 +131,7 @@ public static Iterable<? extends Object> testConfigurations() {
|
|||||||
private final String tableName;
|
private final String tableName;
|
||||||
|
|
||||||
public SQLServerManagerImportTest(ArgumentArrayBuilder builder, String tableName) {
|
public SQLServerManagerImportTest(ArgumentArrayBuilder builder, String tableName) {
|
||||||
this.builder = builder;
|
this.builder = new ArgumentArrayBuilder().with(builder);
|
||||||
this.tableName = tableName;
|
this.tableName = tableName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,6 +268,9 @@ public void tearDown() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public ExpectedLogMessage logMessage = new ExpectedLogMessage();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testImportSimple() throws IOException {
|
public void testImportSimple() throws IOException {
|
||||||
doImportAndVerify(builder, tableName);
|
doImportAndVerify(builder, tableName);
|
||||||
@ -285,6 +290,7 @@ public void testImportTableHintsMultiple() throws IOException {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testImportTableResilient() throws IOException {
|
public void testImportTableResilient() throws IOException {
|
||||||
|
logMessage.expectWarn("Sqoop will use resilient operations! In case of import, the split-by column also has to be specified, unique, and in ascending order.");
|
||||||
builder.withToolOption("resilient");
|
builder.withToolOption("resilient");
|
||||||
doImportAndVerify(builder, tableName);
|
doImportAndVerify(builder, tableName);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user