com.cloudera.sqoop.tool
Class ImportTool

java.lang.Object
  extended by com.cloudera.sqoop.tool.SqoopTool
      extended by com.cloudera.sqoop.tool.BaseSqoopTool
          extended by com.cloudera.sqoop.tool.ImportTool
Direct Known Subclasses:
ImportAllTablesTool

public class ImportTool
extends BaseSqoopTool

Tool that performs database imports to HDFS.


Field Summary
static org.apache.commons.logging.Log LOG
           
 
Fields inherited from class com.cloudera.sqoop.tool.BaseSqoopTool
APPEND_ARG, BIN_OUT_DIR_ARG, CLASS_NAME_ARG, CODE_OUT_DIR_ARG, COLUMNS_ARG, COMPRESS_ARG, COMPRESS_SHORT_ARG, CONNECT_STRING_ARG, DEBUG_SQL_ARG, DEBUG_SQL_SHORT_ARG, DIRECT_ARG, DIRECT_SPLIT_SIZE_ARG, DRIVER_ARG, ENCLOSED_BY_ARG, ESCAPED_BY_ARG, EXPORT_PATH_ARG, FIELDS_TERMINATED_BY_ARG, FMT_SEQUENCEFILE_ARG, FMT_TEXTFILE_ARG, HADOOP_HOME_ARG, HELP_ARG, HELP_STR, HIVE_HOME_ARG, HIVE_IMPORT_ARG, HIVE_OVERWRITE_ARG, HIVE_TABLE_ARG, INLINE_LOB_LIMIT_ARG, INPUT_ENCLOSED_BY_ARG, INPUT_ESCAPED_BY_ARG, INPUT_FIELDS_TERMINATED_BY_ARG, INPUT_LINES_TERMINATED_BY_ARG, INPUT_OPTIONALLY_ENCLOSED_BY_ARG, JAR_FILE_NAME_ARG, LINES_TERMINATED_BY_ARG, manager, MYSQL_DELIMITERS_ARG, NUM_MAPPERS_ARG, NUM_MAPPERS_SHORT_ARG, OPTIONALLY_ENCLOSED_BY_ARG, PACKAGE_NAME_ARG, PASSWORD_ARG, PASSWORD_PROMPT_ARG, SPLIT_BY_ARG, TABLE_ARG, TARGET_DIR_ARG, USERNAME_ARG, VERBOSE_ARG, WAREHOUSE_DIR_ARG, WHERE_ARG
 
Fields inherited from class com.cloudera.sqoop.tool.SqoopTool
extraArguments
 
Constructor Summary
ImportTool()
           
ImportTool(java.lang.String toolName, boolean allTables)
           
 
Method Summary
 void applyOptions(org.apache.commons.cli.CommandLine in, SqoopOptions out)
          Generate the SqoopOptions containing actual argument values from the extracted CommandLine arguments.
 void configureOptions(ToolOptions toolOptions)
          Configure the command-line arguments we expect to receive.
 java.util.List<java.lang.String> getGeneratedJarFiles()
           
protected  RelatedOptions getImportOptions()
          Construct the set of options that control imports, either of one table or a batch of tables.
protected  void importTable(SqoopOptions options, java.lang.String tableName, HiveImport hiveImport)
           
protected  boolean init(SqoopOptions sqoopOpts)
          Should be called at the beginning of the run() method to initialize the connection manager, etc.
 void printHelp(ToolOptions toolOptions)
          Print the help message for this tool.
 int run(SqoopOptions options)
          Main body of code to run the tool.
protected  void validateImportOptions(SqoopOptions options)
          Validate import-specific arguments.
 void validateOptions(SqoopOptions options)
          Validates options and ensures that any required options are present and that any mutually-exclusive options are not selected.
 
Methods inherited from class com.cloudera.sqoop.tool.BaseSqoopTool
applyCodeGenOptions, applyCommonOptions, applyHiveOptions, applyInputFormatOptions, applyOutputFormatOptions, destroy, getCodeGenOpts, getCommonOptions, getHiveOptions, getInputFormatOptions, getManager, getOutputFormatOptions, getSubcommandArgs, hasUnrecognizedArgs, hasUnrecognizedArgs, setManager, validateCodeGenOptions, validateCommonOptions, validateHiveOptions, validateOutputFormatOptions
 
Methods inherited from class com.cloudera.sqoop.tool.SqoopTool
appendArgs, getTool, getToolDescription, getToolName, getToolNames, parseArguments, setToolName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LOG

public static final org.apache.commons.logging.Log LOG
Constructor Detail

ImportTool

public ImportTool()

ImportTool

public ImportTool(java.lang.String toolName,
                  boolean allTables)
Method Detail

init

protected boolean init(SqoopOptions sqoopOpts)
Description copied from class: BaseSqoopTool
Should be called at the beginning of the run() method to initialize the connection manager, etc. If this succeeds (returns true), it should be paired with a call to destroy().

Overrides:
init in class BaseSqoopTool
Returns:
true on success, false on failure.

getGeneratedJarFiles

public java.util.List<java.lang.String> getGeneratedJarFiles()
Returns:
a list of jar files generated as part of this import process

importTable

protected void importTable(SqoopOptions options,
                           java.lang.String tableName,
                           HiveImport hiveImport)
                    throws java.io.IOException,
                           ImportException
Throws:
java.io.IOException
ImportException

run

public int run(SqoopOptions options)
Description copied from class: SqoopTool
Main body of code to run the tool.

Specified by:
run in class SqoopTool
Parameters:
options - the SqoopOptions configured via configureOptions()/applyOptions().
Returns:
an integer return code for external programs to consume. 0 represents success; nonzero means failure.

getImportOptions

protected RelatedOptions getImportOptions()
Construct the set of options that control imports, either of one table or a batch of tables.

Returns:
the RelatedOptions that can be used to parse the import arguments.

configureOptions

public void configureOptions(ToolOptions toolOptions)
Description copied from class: SqoopTool
Configure the command-line arguments we expect to receive.

Overrides:
configureOptions in class SqoopTool
Parameters:
toolOptions - a ToolOptions that should be populated with sets of RelatedOptions for the tool.

printHelp

public void printHelp(ToolOptions toolOptions)
Description copied from class: SqoopTool
Print the help message for this tool.

Overrides:
printHelp in class SqoopTool
Parameters:
toolOptions - the configured tool options

applyOptions

public void applyOptions(org.apache.commons.cli.CommandLine in,
                         SqoopOptions out)
                  throws SqoopOptions.InvalidOptionsException
Description copied from class: SqoopTool
Generate the SqoopOptions containing actual argument values from the extracted CommandLine arguments.

Overrides:
applyOptions in class SqoopTool
Parameters:
in - the CLI CommandLine that contain the user's set Options.
out - the SqoopOptions with all fields applied.
Throws:
SqoopOptions.InvalidOptionsException - if there's a problem.

validateImportOptions

protected void validateImportOptions(SqoopOptions options)
                              throws SqoopOptions.InvalidOptionsException
Validate import-specific arguments.

Parameters:
options - the configured SqoopOptions to check
Throws:
SqoopOptions.InvalidOptionsException

validateOptions

public void validateOptions(SqoopOptions options)
                     throws SqoopOptions.InvalidOptionsException
Description copied from class: SqoopTool
Validates options and ensures that any required options are present and that any mutually-exclusive options are not selected.

Overrides:
validateOptions in class SqoopTool
Throws:
SqoopOptions.InvalidOptionsException - if there's a problem.


Copyright © 2010 Cloudera, Inc.