sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject svn commit: r1195852 [2/7] - in /incubator/sqoop/trunk/src/java: com/cloudera/sqoop/orm/ com/cloudera/sqoop/tool/ org/apache/sqoop/orm/ org/apache/sqoop/tool/
Date Tue, 01 Nov 2011 07:10:14 GMT
Modified: incubator/sqoop/trunk/src/java/com/cloudera/sqoop/tool/BaseSqoopTool.java
URL: http://svn.apache.org/viewvc/incubator/sqoop/trunk/src/java/com/cloudera/sqoop/tool/BaseSqoopTool.java?rev=1195852&r1=1195851&r2=1195852&view=diff
==============================================================================
--- incubator/sqoop/trunk/src/java/com/cloudera/sqoop/tool/BaseSqoopTool.java (original)
+++ incubator/sqoop/trunk/src/java/com/cloudera/sqoop/tool/BaseSqoopTool.java Tue Nov  1 07:10:13 2011
@@ -1,6 +1,4 @@
 /**
- * Copyright 2011 The Apache Software Foundation
- *
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -17,162 +15,188 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package com.cloudera.sqoop.tool;
 
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.sql.SQLException;
-import java.util.Arrays;
-import java.util.Properties;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.OptionBuilder;
-import org.apache.commons.cli.OptionGroup;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.hadoop.util.StringUtils;
-import org.apache.log4j.Category;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-
-import com.cloudera.sqoop.ConnFactory;
-import com.cloudera.sqoop.Sqoop;
-import com.cloudera.sqoop.SqoopOptions;
-import com.cloudera.sqoop.SqoopOptions.InvalidOptionsException;
-import com.cloudera.sqoop.cli.RelatedOptions;
-import com.cloudera.sqoop.cli.ToolOptions;
-import com.cloudera.sqoop.lib.DelimiterSet;
-import com.cloudera.sqoop.manager.ConnManager;
-import com.cloudera.sqoop.metastore.JobData;
-
 /**
- * Layer on top of SqoopTool that provides some basic common code
- * that most SqoopTool implementations will use.
- *
- * Subclasses should call init() at the top of their run() method,
- * and call destroy() at the end in a finally block.
+ * @deprecated Moving to use org.apache.sqoop namespace.
  */
-public abstract class BaseSqoopTool extends SqoopTool {
-
-  public static final Log LOG = LogFactory.getLog(
-      BaseSqoopTool.class.getName());
+public abstract class BaseSqoopTool
+    extends org.apache.sqoop.tool.BaseSqoopTool {
 
-  public static final String HELP_STR = "\nTry --help for usage instructions.";
-
-  // Here are all the arguments that are used by the standard sqoop tools.
-  // Their names are recorded here so that tools can share them and their
-  // use consistently. The argument parser applies the leading '--' to each
-  // string.
-  public static final String CONNECT_STRING_ARG = "connect";
+  public static final String HELP_STR =
+          org.apache.sqoop.tool.BaseSqoopTool.HELP_STR;
+  public static final String CONNECT_STRING_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.CONNECT_STRING_ARG;
   public static final String CONN_MANAGER_CLASS_NAME =
-      "connection-manager";
-  public static final String CONNECT_PARAM_FILE = "connection-param-file";
-  public static final String DRIVER_ARG = "driver";
-  public static final String USERNAME_ARG = "username";
-  public static final String PASSWORD_ARG = "password";
-  public static final String PASSWORD_PROMPT_ARG = "P";
-  public static final String DIRECT_ARG = "direct";
-  public static final String BATCH_ARG = "batch";
-  public static final String TABLE_ARG = "table";
-  public static final String STAGING_TABLE_ARG = "staging-table";
-  public static final String CLEAR_STAGING_TABLE_ARG = "clear-staging-table";
-  public static final String COLUMNS_ARG = "columns";
-  public static final String SPLIT_BY_ARG = "split-by";
-  public static final String WHERE_ARG = "where";
-  public static final String HADOOP_HOME_ARG = "hadoop-home";
-  public static final String HIVE_HOME_ARG = "hive-home";
-  public static final String WAREHOUSE_DIR_ARG = "warehouse-dir";
-  public static final String TARGET_DIR_ARG = "target-dir";
-  public static final String APPEND_ARG = "append";
-  public static final String NULL_STRING = "null-string";
-  public static final String INPUT_NULL_STRING = "input-null-string";
-  public static final String NULL_NON_STRING = "null-non-string";
-  public static final String INPUT_NULL_NON_STRING = "input-null-non-string";
-  public static final String MAP_COLUMN_JAVA = "map-column-java";
-  public static final String MAP_COLUMN_HIVE = "map-column-hive";
-
-  public static final String FMT_SEQUENCEFILE_ARG = "as-sequencefile";
-  public static final String FMT_TEXTFILE_ARG = "as-textfile";
-  public static final String FMT_AVRODATAFILE_ARG = "as-avrodatafile";
-  public static final String HIVE_IMPORT_ARG = "hive-import";
-  public static final String HIVE_TABLE_ARG = "hive-table";
-  public static final String HIVE_OVERWRITE_ARG = "hive-overwrite";
-  public static final String HIVE_DROP_DELIMS_ARG = "hive-drop-import-delims";
+          org.apache.sqoop.tool.BaseSqoopTool.CONN_MANAGER_CLASS_NAME;
+  public static final String CONNECT_PARAM_FILE =
+          org.apache.sqoop.tool.BaseSqoopTool.CONNECT_PARAM_FILE;
+  public static final String DRIVER_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.DRIVER_ARG;
+  public static final String USERNAME_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.USERNAME_ARG;
+  public static final String PASSWORD_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.PASSWORD_ARG;
+  public static final String PASSWORD_PROMPT_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.PASSWORD_PROMPT_ARG;
+  public static final String DIRECT_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.DIRECT_ARG;
+  public static final String BATCH_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.BATCH_ARG;
+  public static final String TABLE_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.TABLE_ARG;
+  public static final String STAGING_TABLE_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.STAGING_TABLE_ARG;
+  public static final String CLEAR_STAGING_TABLE_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.CLEAR_STAGING_TABLE_ARG;
+  public static final String COLUMNS_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.COLUMNS_ARG;
+  public static final String SPLIT_BY_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.SPLIT_BY_ARG;
+  public static final String WHERE_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.WHERE_ARG;
+  public static final String HADOOP_HOME_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.HADOOP_HOME_ARG;
+  public static final String HIVE_HOME_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.HIVE_HOME_ARG;
+  public static final String WAREHOUSE_DIR_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.WAREHOUSE_DIR_ARG;
+  public static final String TARGET_DIR_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.TARGET_DIR_ARG;
+  public static final String APPEND_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.APPEND_ARG;
+  public static final String NULL_STRING =
+          org.apache.sqoop.tool.BaseSqoopTool.NULL_STRING;
+  public static final String INPUT_NULL_STRING =
+          org.apache.sqoop.tool.BaseSqoopTool.INPUT_NULL_STRING;
+  public static final String NULL_NON_STRING =
+          org.apache.sqoop.tool.BaseSqoopTool.NULL_NON_STRING;
+  public static final String INPUT_NULL_NON_STRING =
+          org.apache.sqoop.tool.BaseSqoopTool.INPUT_NULL_NON_STRING;
+  public static final String MAP_COLUMN_JAVA =
+          org.apache.sqoop.tool.BaseSqoopTool.MAP_COLUMN_JAVA;
+  public static final String MAP_COLUMN_HIVE =
+          org.apache.sqoop.tool.BaseSqoopTool.MAP_COLUMN_HIVE;
+  public static final String FMT_SEQUENCEFILE_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.FMT_SEQUENCEFILE_ARG;
+  public static final String FMT_TEXTFILE_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.FMT_TEXTFILE_ARG;
+  public static final String FMT_AVRODATAFILE_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.FMT_AVRODATAFILE_ARG;
+  public static final String HIVE_IMPORT_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.HIVE_IMPORT_ARG;
+  public static final String HIVE_TABLE_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.HIVE_TABLE_ARG;
+  public static final String HIVE_OVERWRITE_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.HIVE_OVERWRITE_ARG;
+  public static final String HIVE_DROP_DELIMS_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.HIVE_DROP_DELIMS_ARG;
   public static final String HIVE_DELIMS_REPLACEMENT_ARG =
-          "hive-delims-replacement";
-  public static final String HIVE_PARTITION_KEY_ARG = "hive-partition-key";
-  public static final String HIVE_PARTITION_VALUE_ARG = "hive-partition-value";
+          org.apache.sqoop.tool.BaseSqoopTool.HIVE_DELIMS_REPLACEMENT_ARG;
+  public static final String HIVE_PARTITION_KEY_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.HIVE_PARTITION_KEY_ARG;
+  public static final String HIVE_PARTITION_VALUE_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.HIVE_PARTITION_VALUE_ARG;
   public static final String CREATE_HIVE_TABLE_ARG =
-      "create-hive-table";
-  public static final String NUM_MAPPERS_ARG = "num-mappers";
-  public static final String NUM_MAPPERS_SHORT_ARG = "m";
-  public static final String COMPRESS_ARG = "compress";
-  public static final String COMPRESSION_CODEC_ARG = "compression-codec";
-  public static final String COMPRESS_SHORT_ARG = "z";
-  public static final String DIRECT_SPLIT_SIZE_ARG = "direct-split-size";
-  public static final String INLINE_LOB_LIMIT_ARG = "inline-lob-limit";
-  public static final String FETCH_SIZE_ARG = "fetch-size";
-  public static final String EXPORT_PATH_ARG = "export-dir";
-  public static final String FIELDS_TERMINATED_BY_ARG = "fields-terminated-by";
-  public static final String LINES_TERMINATED_BY_ARG = "lines-terminated-by";
+          org.apache.sqoop.tool.BaseSqoopTool.CREATE_HIVE_TABLE_ARG;
+  public static final String NUM_MAPPERS_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.NUM_MAPPERS_ARG;
+  public static final String NUM_MAPPERS_SHORT_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.NUM_MAPPERS_SHORT_ARG;
+  public static final String COMPRESS_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.COMPRESS_ARG;
+  public static final String COMPRESSION_CODEC_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.COMPRESSION_CODEC_ARG;
+  public static final String COMPRESS_SHORT_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.COMPRESS_SHORT_ARG;
+  public static final String DIRECT_SPLIT_SIZE_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.DIRECT_SPLIT_SIZE_ARG;
+  public static final String INLINE_LOB_LIMIT_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.INLINE_LOB_LIMIT_ARG;
+  public static final String FETCH_SIZE_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.FETCH_SIZE_ARG;
+  public static final String EXPORT_PATH_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.EXPORT_PATH_ARG;
+  public static final String FIELDS_TERMINATED_BY_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.FIELDS_TERMINATED_BY_ARG;
+  public static final String LINES_TERMINATED_BY_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.LINES_TERMINATED_BY_ARG;
   public static final String OPTIONALLY_ENCLOSED_BY_ARG =
-      "optionally-enclosed-by";
-  public static final String ENCLOSED_BY_ARG = "enclosed-by";
-  public static final String ESCAPED_BY_ARG = "escaped-by";
-  public static final String MYSQL_DELIMITERS_ARG = "mysql-delimiters";
+          org.apache.sqoop.tool.BaseSqoopTool.OPTIONALLY_ENCLOSED_BY_ARG;
+  public static final String ENCLOSED_BY_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.ENCLOSED_BY_ARG;
+  public static final String ESCAPED_BY_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.ESCAPED_BY_ARG;
+  public static final String MYSQL_DELIMITERS_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.MYSQL_DELIMITERS_ARG;
   public static final String INPUT_FIELDS_TERMINATED_BY_ARG =
-      "input-fields-terminated-by";
+          org.apache.sqoop.tool.BaseSqoopTool.INPUT_FIELDS_TERMINATED_BY_ARG;
   public static final String INPUT_LINES_TERMINATED_BY_ARG =
-      "input-lines-terminated-by";
+          org.apache.sqoop.tool.BaseSqoopTool.INPUT_LINES_TERMINATED_BY_ARG;
   public static final String INPUT_OPTIONALLY_ENCLOSED_BY_ARG =
-      "input-optionally-enclosed-by";
-  public static final String INPUT_ENCLOSED_BY_ARG = "input-enclosed-by";
-  public static final String INPUT_ESCAPED_BY_ARG = "input-escaped-by";
-  public static final String CODE_OUT_DIR_ARG = "outdir";
-  public static final String BIN_OUT_DIR_ARG = "bindir";
-  public static final String PACKAGE_NAME_ARG = "package-name";
-  public static final String CLASS_NAME_ARG = "class-name";
-  public static final String JAR_FILE_NAME_ARG = "jar-file";
-  public static final String SQL_QUERY_ARG = "query";
-  public static final String SQL_QUERY_BOUNDARY = "boundary-query";
-  public static final String SQL_QUERY_SHORT_ARG = "e";
-  public static final String VERBOSE_ARG = "verbose";
-  public static final String HELP_ARG = "help";
-  public static final String UPDATE_KEY_ARG = "update-key";
-  public static final String UPDATE_MODE_ARG = "update-mode";
-
-  // Arguments for incremental imports.
-  public static final String INCREMENT_TYPE_ARG = "incremental";
-  public static final String INCREMENT_COL_ARG = "check-column";
-  public static final String INCREMENT_LAST_VAL_ARG = "last-value";
-
-  // HBase arguments.
-  public static final String HBASE_TABLE_ARG = "hbase-table";
-  public static final String HBASE_COL_FAM_ARG = "column-family";
-  public static final String HBASE_ROW_KEY_ARG = "hbase-row-key";
-  public static final String HBASE_CREATE_TABLE_ARG = "hbase-create-table";
-
-
-  // Arguments for the saved job management system.
-  public static final String STORAGE_METASTORE_ARG = "meta-connect";
-  public static final String JOB_CMD_CREATE_ARG = "create";
-  public static final String JOB_CMD_DELETE_ARG = "delete";
-  public static final String JOB_CMD_EXEC_ARG = "exec";
-  public static final String JOB_CMD_LIST_ARG = "list";
-  public static final String JOB_CMD_SHOW_ARG = "show";
-
-  // Arguments for the metastore.
-  public static final String METASTORE_SHUTDOWN_ARG = "shutdown";
-
-
-  // Arguments for merging datasets.
-  public static final String NEW_DATASET_ARG = "new-data";
-  public static final String OLD_DATASET_ARG = "onto";
-  public static final String MERGE_KEY_ARG = "merge-key";
+          org.apache.sqoop.tool.BaseSqoopTool.INPUT_OPTIONALLY_ENCLOSED_BY_ARG;
+  public static final String INPUT_ENCLOSED_BY_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.INPUT_ENCLOSED_BY_ARG;
+  public static final String INPUT_ESCAPED_BY_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.INPUT_ESCAPED_BY_ARG;
+  public static final String CODE_OUT_DIR_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.CODE_OUT_DIR_ARG;
+  public static final String BIN_OUT_DIR_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.BIN_OUT_DIR_ARG;
+  public static final String PACKAGE_NAME_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.PACKAGE_NAME_ARG;
+  public static final String CLASS_NAME_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.CLASS_NAME_ARG;
+  public static final String JAR_FILE_NAME_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.JAR_FILE_NAME_ARG;
+  public static final String SQL_QUERY_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.SQL_QUERY_ARG;
+  public static final String SQL_QUERY_BOUNDARY =
+          org.apache.sqoop.tool.BaseSqoopTool.SQL_QUERY_BOUNDARY;
+  public static final String SQL_QUERY_SHORT_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.SQL_QUERY_SHORT_ARG;
+  public static final String VERBOSE_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.VERBOSE_ARG;
+  public static final String HELP_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.HELP_ARG;
+  public static final String UPDATE_KEY_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.UPDATE_KEY_ARG;
+  public static final String UPDATE_MODE_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.UPDATE_MODE_ARG;
+  public static final String INCREMENT_TYPE_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.INCREMENT_TYPE_ARG;
+  public static final String INCREMENT_COL_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.INCREMENT_COL_ARG;
+  public static final String INCREMENT_LAST_VAL_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.INCREMENT_LAST_VAL_ARG;
+  public static final String HBASE_TABLE_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.HBASE_TABLE_ARG;
+  public static final String HBASE_COL_FAM_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.HBASE_COL_FAM_ARG;
+  public static final String HBASE_ROW_KEY_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.HBASE_ROW_KEY_ARG;
+  public static final String HBASE_CREATE_TABLE_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.HBASE_CREATE_TABLE_ARG;
+  public static final String STORAGE_METASTORE_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.STORAGE_METASTORE_ARG;
+  public static final String JOB_CMD_CREATE_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.JOB_CMD_CREATE_ARG;
+  public static final String JOB_CMD_DELETE_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.JOB_CMD_DELETE_ARG;
+  public static final String JOB_CMD_EXEC_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.JOB_CMD_EXEC_ARG;
+  public static final String JOB_CMD_LIST_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.JOB_CMD_LIST_ARG;
+  public static final String JOB_CMD_SHOW_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.JOB_CMD_SHOW_ARG;
+  public static final String METASTORE_SHUTDOWN_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.METASTORE_SHUTDOWN_ARG;
+  public static final String NEW_DATASET_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.NEW_DATASET_ARG;
+  public static final String OLD_DATASET_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.OLD_DATASET_ARG;
+  public static final String MERGE_KEY_ARG =
+          org.apache.sqoop.tool.BaseSqoopTool.MERGE_KEY_ARG;
 
   public BaseSqoopTool() {
   }
@@ -181,793 +205,4 @@ public abstract class BaseSqoopTool exte
     super(toolName);
   }
 
-  protected ConnManager manager;
-
-  public ConnManager getManager() {
-    return manager;
-  }
-
-  public void setManager(ConnManager mgr) {
-    this.manager = mgr;
-  }
-
-  /**
-   * 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().
-   * @return true on success, false on failure.
-   */
-  protected boolean init(SqoopOptions sqoopOpts) {
-    // Get the connection to the database.
-    try {
-      JobData data = new JobData(sqoopOpts, this);
-      this.manager = new ConnFactory(sqoopOpts.getConf()).getManager(data);
-      return true;
-    } catch (Exception e) {
-      LOG.error("Got error creating database manager: "
-          + StringUtils.stringifyException(e));
-      if (System.getProperty(Sqoop.SQOOP_RETHROW_PROPERTY) != null) {
-        throw new RuntimeException(e);
-      }
-    }
-
-    return false;
-  }
-
-  /**
-   * Should be called in a 'finally' block at the end of the run() method.
-   */
-  protected void destroy(SqoopOptions sqoopOpts) {
-    if (null != manager) {
-      try {
-        manager.close();
-      } catch (SQLException sqlE) {
-        LOG.warn("Error while closing connection: " + sqlE);
-      }
-    }
-  }
-
-  /**
-   * Examines a subset of the arrray presented, and determines if it
-   * contains any non-empty arguments. If so, logs the arguments
-   * and returns true.
-   *
-   * @param argv an array of strings to check.
-   * @param offset the first element of the array to check
-   * @param len the number of elements to check
-   * @return true if there are any non-null, non-empty argument strings
-   * present.
-   */
-  protected boolean hasUnrecognizedArgs(String [] argv, int offset, int len) {
-    if (argv == null) {
-      return false;
-    }
-
-    boolean unrecognized = false;
-    boolean printedBanner = false;
-    for (int i = offset; i < Math.min(argv.length, offset + len); i++) {
-      if (argv[i] != null && argv[i].length() > 0) {
-        if (!printedBanner) {
-          LOG.error("Error parsing arguments for " + getToolName() + ":");
-          printedBanner = true;
-        }
-        LOG.error("Unrecognized argument: " + argv[i]);
-        unrecognized = true;
-      }
-    }
-
-    return unrecognized;
-  }
-
-  protected boolean hasUnrecognizedArgs(String [] argv) {
-    if (null == argv) {
-      return false;
-    }
-    return hasUnrecognizedArgs(argv, 0, argv.length);
-  }
-
-
-  /**
-   * If argv contains an entry "--", return an array containing all elements
-   * after the "--" separator. Otherwise, return null.
-   * @param argv a set of arguments to scan for the subcommand arguments.
-   */
-  protected String [] getSubcommandArgs(String [] argv) {
-    if (null == argv) {
-      return null;
-    }
-
-    for (int i = 0; i < argv.length; i++) {
-      if (argv[i].equals("--")) {
-        return Arrays.copyOfRange(argv, i + 1, argv.length);
-      }
-    }
-
-    return null;
-  }
-
-  /**
-   * @return RelatedOptions used by job management tools.
-   */
-  protected RelatedOptions getJobOptions() {
-    RelatedOptions relatedOpts = new RelatedOptions(
-        "Job management arguments");
-    relatedOpts.addOption(OptionBuilder.withArgName("jdbc-uri")
-        .hasArg()
-        .withDescription("Specify JDBC connect string for the metastore")
-        .withLongOpt(STORAGE_METASTORE_ARG)
-        .create());
-
-    // Create an option-group surrounding the operations a user
-    // can perform on jobs.
-    OptionGroup group = new OptionGroup();
-    group.addOption(OptionBuilder.withArgName("job-id")
-        .hasArg()
-        .withDescription("Create a new saved job")
-        .withLongOpt(JOB_CMD_CREATE_ARG)
-        .create());
-    group.addOption(OptionBuilder.withArgName("job-id")
-        .hasArg()
-        .withDescription("Delete a saved job")
-        .withLongOpt(JOB_CMD_DELETE_ARG)
-        .create());
-    group.addOption(OptionBuilder.withArgName("job-id")
-        .hasArg()
-        .withDescription("Show the parameters for a saved job")
-        .withLongOpt(JOB_CMD_SHOW_ARG)
-        .create());
-
-    Option execOption = OptionBuilder.withArgName("job-id")
-        .hasArg()
-        .withDescription("Run a saved job")
-        .withLongOpt(JOB_CMD_EXEC_ARG)
-        .create();
-    group.addOption(execOption);
-
-    group.addOption(OptionBuilder
-        .withDescription("List saved jobs")
-        .withLongOpt(JOB_CMD_LIST_ARG)
-        .create());
-
-    relatedOpts.addOptionGroup(group);
-
-    // Since the "common" options aren't used in the job tool,
-    // add these settings here.
-    relatedOpts.addOption(OptionBuilder
-        .withDescription("Print more information while working")
-        .withLongOpt(VERBOSE_ARG)
-        .create());
-    relatedOpts.addOption(OptionBuilder
-        .withDescription("Print usage instructions")
-        .withLongOpt(HELP_ARG)
-        .create());
-
-    return relatedOpts;
-  }
-
-  /**
-   * @return RelatedOptions used by most/all Sqoop tools.
-   */
-  protected RelatedOptions getCommonOptions() {
-    // Connection args (common)
-    RelatedOptions commonOpts = new RelatedOptions("Common arguments");
-    commonOpts.addOption(OptionBuilder.withArgName("jdbc-uri")
-        .hasArg().withDescription("Specify JDBC connect string")
-        .withLongOpt(CONNECT_STRING_ARG)
-        .create());
-    commonOpts.addOption(OptionBuilder.withArgName("class-name")
-        .hasArg().withDescription("Specify connection manager class name")
-        .withLongOpt(CONN_MANAGER_CLASS_NAME)
-        .create());
-    commonOpts.addOption(OptionBuilder.withArgName("properties-file")
-        .hasArg().withDescription("Specify connection parameters file")
-        .withLongOpt(CONNECT_PARAM_FILE)
-        .create());
-    commonOpts.addOption(OptionBuilder.withArgName("class-name")
-        .hasArg().withDescription("Manually specify JDBC driver class to use")
-        .withLongOpt(DRIVER_ARG)
-        .create());
-    commonOpts.addOption(OptionBuilder.withArgName("username")
-        .hasArg().withDescription("Set authentication username")
-        .withLongOpt(USERNAME_ARG)
-        .create());
-    commonOpts.addOption(OptionBuilder.withArgName("password")
-        .hasArg().withDescription("Set authentication password")
-        .withLongOpt(PASSWORD_ARG)
-        .create());
-    commonOpts.addOption(OptionBuilder
-        .withDescription("Read password from console")
-        .create(PASSWORD_PROMPT_ARG));
-
-    commonOpts.addOption(OptionBuilder.withArgName("dir")
-        .hasArg().withDescription("Override $HADOOP_HOME")
-        .withLongOpt(HADOOP_HOME_ARG)
-        .create());
-
-    // misc (common)
-    commonOpts.addOption(OptionBuilder
-        .withDescription("Print more information while working")
-        .withLongOpt(VERBOSE_ARG)
-        .create());
-    commonOpts.addOption(OptionBuilder
-        .withDescription("Print usage instructions")
-        .withLongOpt(HELP_ARG)
-        .create());
-
-    return commonOpts;
-  }
-
-  /**
-   * @param explicitHiveImport true if the user has an explicit --hive-import
-   * available, or false if this is implied by the tool.
-   * @return options governing interaction with Hive
-   */
-  protected RelatedOptions getHiveOptions(boolean explicitHiveImport) {
-    RelatedOptions hiveOpts = new RelatedOptions("Hive arguments");
-    if (explicitHiveImport) {
-      hiveOpts.addOption(OptionBuilder
-          .withDescription("Import tables into Hive "
-          + "(Uses Hive's default delimiters if none are set.)")
-          .withLongOpt(HIVE_IMPORT_ARG)
-          .create());
-    }
-
-    hiveOpts.addOption(OptionBuilder.withArgName("dir")
-        .hasArg().withDescription("Override $HIVE_HOME")
-        .withLongOpt(HIVE_HOME_ARG)
-        .create());
-    hiveOpts.addOption(OptionBuilder
-        .withDescription("Overwrite existing data in the Hive table")
-        .withLongOpt(HIVE_OVERWRITE_ARG)
-        .create());
-    hiveOpts.addOption(OptionBuilder
-        .withDescription("Fail if the target hive table exists")
-        .withLongOpt(CREATE_HIVE_TABLE_ARG)
-        .create());
-    hiveOpts.addOption(OptionBuilder.withArgName("table-name")
-        .hasArg()
-        .withDescription("Sets the table name to use when importing to hive")
-        .withLongOpt(HIVE_TABLE_ARG)
-        .create());
-    hiveOpts.addOption(OptionBuilder
-        .withDescription("Drop Hive record \\0x01 and row delimiters "
-            + "(\\n\\r) from imported string fields")
-        .withLongOpt(HIVE_DROP_DELIMS_ARG)
-        .create());
-    hiveOpts.addOption(OptionBuilder
-        .hasArg()
-        .withDescription("Replace Hive record \\0x01 and row delimiters "
-            + "(\\n\\r) from imported string fields with user-defined string")
-        .withLongOpt(HIVE_DELIMS_REPLACEMENT_ARG)
-        .create());
-    hiveOpts.addOption(OptionBuilder.withArgName("partition-key")
-        .hasArg()
-        .withDescription("Sets the partition key to use when importing to hive")
-        .withLongOpt(HIVE_PARTITION_KEY_ARG)
-        .create());
-    hiveOpts.addOption(OptionBuilder.withArgName("partition-value")
-        .hasArg()
-        .withDescription("Sets the partition value to use when importing "
-            + "to hive")
-        .withLongOpt(HIVE_PARTITION_VALUE_ARG)
-        .create());
-    hiveOpts.addOption(OptionBuilder
-        .hasArg()
-        .withDescription("Override mapping for specific column to hive"
-          + " types.")
-        .withLongOpt(MAP_COLUMN_HIVE)
-        .create());
-
-    return hiveOpts;
-  }
-
-  /**
-   * @return options governing output format delimiters
-   */
-  protected RelatedOptions getOutputFormatOptions() {
-    RelatedOptions formatOpts = new RelatedOptions(
-        "Output line formatting arguments");
-    formatOpts.addOption(OptionBuilder.withArgName("char")
-        .hasArg()
-        .withDescription("Sets the field separator character")
-        .withLongOpt(FIELDS_TERMINATED_BY_ARG)
-        .create());
-    formatOpts.addOption(OptionBuilder.withArgName("char")
-        .hasArg()
-        .withDescription("Sets the end-of-line character")
-        .withLongOpt(LINES_TERMINATED_BY_ARG)
-        .create());
-    formatOpts.addOption(OptionBuilder.withArgName("char")
-        .hasArg()
-        .withDescription("Sets a field enclosing character")
-        .withLongOpt(OPTIONALLY_ENCLOSED_BY_ARG)
-        .create());
-    formatOpts.addOption(OptionBuilder.withArgName("char")
-        .hasArg()
-        .withDescription("Sets a required field enclosing character")
-        .withLongOpt(ENCLOSED_BY_ARG)
-        .create());
-    formatOpts.addOption(OptionBuilder.withArgName("char")
-        .hasArg()
-        .withDescription("Sets the escape character")
-        .withLongOpt(ESCAPED_BY_ARG)
-        .create());
-    formatOpts.addOption(OptionBuilder
-        .withDescription("Uses MySQL's default delimiter set: "
-        + "fields: ,  lines: \\n  escaped-by: \\  optionally-enclosed-by: '")
-        .withLongOpt(MYSQL_DELIMITERS_ARG)
-        .create());
-
-    return formatOpts;
-  }
-
-  /**
-   * @return options governing input format delimiters.
-   */
-  protected RelatedOptions getInputFormatOptions() {
-    RelatedOptions inputFormatOpts =
-        new RelatedOptions("Input parsing arguments");
-    inputFormatOpts.addOption(OptionBuilder.withArgName("char")
-        .hasArg()
-        .withDescription("Sets the input field separator")
-        .withLongOpt(INPUT_FIELDS_TERMINATED_BY_ARG)
-        .create());
-    inputFormatOpts.addOption(OptionBuilder.withArgName("char")
-        .hasArg()
-        .withDescription("Sets the input end-of-line char")
-        .withLongOpt(INPUT_LINES_TERMINATED_BY_ARG)
-        .create());
-    inputFormatOpts.addOption(OptionBuilder.withArgName("char")
-        .hasArg()
-        .withDescription("Sets a field enclosing character")
-        .withLongOpt(INPUT_OPTIONALLY_ENCLOSED_BY_ARG)
-        .create());
-    inputFormatOpts.addOption(OptionBuilder.withArgName("char")
-        .hasArg()
-        .withDescription("Sets a required field encloser")
-        .withLongOpt(INPUT_ENCLOSED_BY_ARG)
-        .create());
-    inputFormatOpts.addOption(OptionBuilder.withArgName("char")
-        .hasArg()
-        .withDescription("Sets the input escape character")
-        .withLongOpt(INPUT_ESCAPED_BY_ARG)
-        .create());
-
-    return inputFormatOpts;
-  }
-
-  /**
-   * @param multiTable true if these options will be used for bulk code-gen.
-   * @return options related to code generation.
-   */
-  protected RelatedOptions getCodeGenOpts(boolean multiTable) {
-    RelatedOptions codeGenOpts =
-        new RelatedOptions("Code generation arguments");
-    codeGenOpts.addOption(OptionBuilder.withArgName("dir")
-        .hasArg()
-        .withDescription("Output directory for generated code")
-        .withLongOpt(CODE_OUT_DIR_ARG)
-        .create());
-    codeGenOpts.addOption(OptionBuilder.withArgName("dir")
-        .hasArg()
-        .withDescription("Output directory for compiled objects")
-        .withLongOpt(BIN_OUT_DIR_ARG)
-        .create());
-    codeGenOpts.addOption(OptionBuilder.withArgName("name")
-        .hasArg()
-        .withDescription("Put auto-generated classes in this package")
-        .withLongOpt(PACKAGE_NAME_ARG)
-        .create());
-    codeGenOpts.addOption(OptionBuilder.withArgName("null-str")
-        .hasArg()
-        .withDescription("Null string representation")
-        .withLongOpt(NULL_STRING)
-        .create());
-    codeGenOpts.addOption(OptionBuilder.withArgName("null-str")
-        .hasArg()
-        .withDescription("Input null string representation")
-        .withLongOpt(INPUT_NULL_STRING)
-        .create());
-    codeGenOpts.addOption(OptionBuilder.withArgName("null-str")
-        .hasArg()
-        .withDescription("Null non-string representation")
-        .withLongOpt(NULL_NON_STRING)
-        .create());
-    codeGenOpts.addOption(OptionBuilder.withArgName("null-str")
-        .hasArg()
-        .withDescription("Input null non-string representation")
-        .withLongOpt(INPUT_NULL_NON_STRING)
-        .create());
-    codeGenOpts.addOption(OptionBuilder
-        .hasArg()
-        .withDescription("Override mapping for specific columns to java types")
-        .withLongOpt(MAP_COLUMN_JAVA)
-        .create());
-
-    if (!multiTable) {
-      codeGenOpts.addOption(OptionBuilder.withArgName("name")
-          .hasArg()
-          .withDescription("Sets the generated class name. "
-          + "This overrides --" + PACKAGE_NAME_ARG + ". When combined "
-          + "with --" + JAR_FILE_NAME_ARG + ", sets the input class.")
-          .withLongOpt(CLASS_NAME_ARG)
-          .create());
-    }
-    return codeGenOpts;
-  }
-
-  protected RelatedOptions getHBaseOptions() {
-    RelatedOptions hbaseOpts =
-        new RelatedOptions("HBase arguments");
-    hbaseOpts.addOption(OptionBuilder.withArgName("table")
-        .hasArg()
-        .withDescription("Import to <table> in HBase")
-        .withLongOpt(HBASE_TABLE_ARG)
-        .create());
-    hbaseOpts.addOption(OptionBuilder.withArgName("family")
-        .hasArg()
-        .withDescription("Sets the target column family for the import")
-        .withLongOpt(HBASE_COL_FAM_ARG)
-        .create());
-    hbaseOpts.addOption(OptionBuilder.withArgName("col")
-        .hasArg()
-        .withDescription("Specifies which input column to use as the row key")
-        .withLongOpt(HBASE_ROW_KEY_ARG)
-        .create());
-    hbaseOpts.addOption(OptionBuilder
-        .withDescription("If specified, create missing HBase tables")
-        .withLongOpt(HBASE_CREATE_TABLE_ARG)
-        .create());
-
-    return hbaseOpts;
-  }
-
-
-
-  /**
-   * Apply common command-line to the state.
-   */
-  protected void applyCommonOptions(CommandLine in, SqoopOptions out)
-      throws InvalidOptionsException {
-
-    // common options.
-    if (in.hasOption(VERBOSE_ARG)) {
-      // Immediately switch into DEBUG logging.
-      Category sqoopLogger = Logger.getLogger(
-          Sqoop.class.getName()).getParent();
-      sqoopLogger.setLevel(Level.DEBUG);
-      LOG.debug("Enabled debug logging.");
-    }
-
-    if (in.hasOption(HELP_ARG)) {
-      ToolOptions toolOpts = new ToolOptions();
-      configureOptions(toolOpts);
-      printHelp(toolOpts);
-      throw new InvalidOptionsException("");
-    }
-
-    if (in.hasOption(CONNECT_STRING_ARG)) {
-      out.setConnectString(in.getOptionValue(CONNECT_STRING_ARG));
-    }
-
-    if (in.hasOption(CONN_MANAGER_CLASS_NAME)) {
-        out.setConnManagerClassName(in.getOptionValue(CONN_MANAGER_CLASS_NAME));
-    }
-
-    if (in.hasOption(CONNECT_PARAM_FILE)) {
-      File paramFile = new File(in.getOptionValue(CONNECT_PARAM_FILE));
-      if (!paramFile.exists()) {
-        throw new InvalidOptionsException(
-                "Specified connection parameter file not found: " + paramFile);
-      }
-      InputStream inStream = null;
-      Properties connectionParams = new Properties();
-      try {
-        inStream = new FileInputStream(
-                      new File(in.getOptionValue(CONNECT_PARAM_FILE)));
-        connectionParams.load(inStream);
-      } catch (IOException ex) {
-        LOG.warn("Failed to load connection parameter file", ex);
-        throw new InvalidOptionsException(
-                "Error while loading connection parameter file: "
-                + ex.getMessage());
-      } finally {
-        if (inStream != null) {
-          try {
-            inStream.close();
-          } catch (IOException ex) {
-            LOG.warn("Failed to close input stream", ex);
-          }
-        }
-      }
-      LOG.debug("Loaded connection parameters: " + connectionParams);
-      out.setConnectionParams(connectionParams);
-    }
-
-    if (in.hasOption(NULL_STRING)) {
-        out.setNullStringValue(in.getOptionValue(NULL_STRING));
-    }
-
-    if (in.hasOption(INPUT_NULL_STRING)) {
-        out.setInNullStringValue(in.getOptionValue(INPUT_NULL_STRING));
-    }
-
-    if (in.hasOption(NULL_NON_STRING)) {
-        out.setNullNonStringValue(in.getOptionValue(NULL_NON_STRING));
-    }
-
-    if (in.hasOption(INPUT_NULL_NON_STRING)) {
-        out.setInNullNonStringValue(in.getOptionValue(INPUT_NULL_NON_STRING));
-    }
-
-    if (in.hasOption(DRIVER_ARG)) {
-      out.setDriverClassName(in.getOptionValue(DRIVER_ARG));
-    }
-
-    if (in.hasOption(USERNAME_ARG)) {
-      out.setUsername(in.getOptionValue(USERNAME_ARG));
-      if (null == out.getPassword()) {
-        // Set password to empty if the username is set first,
-        // to ensure that they're either both null or neither is.
-        out.setPassword("");
-      }
-    }
-
-    if (in.hasOption(PASSWORD_ARG)) {
-      LOG.warn("Setting your password on the command-line is insecure. "
-          + "Consider using -" + PASSWORD_PROMPT_ARG + " instead.");
-      out.setPassword(in.getOptionValue(PASSWORD_ARG));
-    }
-
-    if (in.hasOption(PASSWORD_PROMPT_ARG)) {
-      out.setPasswordFromConsole();
-    }
-
-    if (in.hasOption(HADOOP_HOME_ARG)) {
-      out.setHadoopHome(in.getOptionValue(HADOOP_HOME_ARG));
-    }
-
-  }
-
-  protected void applyHiveOptions(CommandLine in, SqoopOptions out)
-      throws InvalidOptionsException {
-
-    if (in.hasOption(HIVE_HOME_ARG)) {
-      out.setHiveHome(in.getOptionValue(HIVE_HOME_ARG));
-    }
-
-    if (in.hasOption(HIVE_IMPORT_ARG)) {
-      out.setHiveImport(true);
-    }
-
-    if (in.hasOption(HIVE_OVERWRITE_ARG)) {
-      out.setOverwriteHiveTable(true);
-    }
-
-    if (in.hasOption(CREATE_HIVE_TABLE_ARG)) {
-      out.setFailIfHiveTableExists(true);
-    }
-
-    if (in.hasOption(HIVE_TABLE_ARG)) {
-      out.setHiveTableName(in.getOptionValue(HIVE_TABLE_ARG));
-    }
-
-    if (in.hasOption(HIVE_DROP_DELIMS_ARG)) {
-      out.setHiveDropDelims(true);
-    }
-
-    if (in.hasOption(HIVE_DELIMS_REPLACEMENT_ARG)) {
-      out.setHiveDelimsReplacement(
-              in.getOptionValue(HIVE_DELIMS_REPLACEMENT_ARG));
-    }
-
-    if (in.hasOption(HIVE_PARTITION_KEY_ARG)) {
-      out.setHivePartitionKey(in.getOptionValue(HIVE_PARTITION_KEY_ARG));
-    }
-
-    if (in.hasOption(HIVE_PARTITION_VALUE_ARG)) {
-      out.setHivePartitionValue(in.getOptionValue(HIVE_PARTITION_VALUE_ARG));
-    }
-
-   if (in.hasOption(MAP_COLUMN_HIVE)) {
-      out.setMapColumnHive(in.getOptionValue(MAP_COLUMN_HIVE));
-    }
-  }
-
-  protected void applyOutputFormatOptions(CommandLine in, SqoopOptions out)
-      throws InvalidOptionsException {
-    if (in.hasOption(FIELDS_TERMINATED_BY_ARG)) {
-      out.setFieldsTerminatedBy(SqoopOptions.toChar(
-          in.getOptionValue(FIELDS_TERMINATED_BY_ARG)));
-      out.setExplicitDelims(true);
-    }
-
-    if (in.hasOption(LINES_TERMINATED_BY_ARG)) {
-      out.setLinesTerminatedBy(SqoopOptions.toChar(
-          in.getOptionValue(LINES_TERMINATED_BY_ARG)));
-      out.setExplicitDelims(true);
-    }
-
-    if (in.hasOption(OPTIONALLY_ENCLOSED_BY_ARG)) {
-      out.setEnclosedBy(SqoopOptions.toChar(
-          in.getOptionValue(OPTIONALLY_ENCLOSED_BY_ARG)));
-      out.setOutputEncloseRequired(false);
-      out.setExplicitDelims(true);
-    }
-
-    if (in.hasOption(ENCLOSED_BY_ARG)) {
-      out.setEnclosedBy(SqoopOptions.toChar(
-          in.getOptionValue(ENCLOSED_BY_ARG)));
-      out.setOutputEncloseRequired(true);
-      out.setExplicitDelims(true);
-    }
-
-    if (in.hasOption(ESCAPED_BY_ARG)) {
-      out.setEscapedBy(SqoopOptions.toChar(
-          in.getOptionValue(ESCAPED_BY_ARG)));
-      out.setExplicitDelims(true);
-    }
-
-    if (in.hasOption(MYSQL_DELIMITERS_ARG)) {
-      out.setOutputEncloseRequired(false);
-      out.setFieldsTerminatedBy(',');
-      out.setLinesTerminatedBy('\n');
-      out.setEscapedBy('\\');
-      out.setEnclosedBy('\'');
-      out.setExplicitDelims(true);
-    }
-  }
-
-  protected void applyInputFormatOptions(CommandLine in, SqoopOptions out)
-      throws InvalidOptionsException {
-    if (in.hasOption(INPUT_FIELDS_TERMINATED_BY_ARG)) {
-      out.setInputFieldsTerminatedBy(SqoopOptions.toChar(
-          in.getOptionValue(INPUT_FIELDS_TERMINATED_BY_ARG)));
-    }
-
-    if (in.hasOption(INPUT_LINES_TERMINATED_BY_ARG)) {
-      out.setInputLinesTerminatedBy(SqoopOptions.toChar(
-          in.getOptionValue(INPUT_LINES_TERMINATED_BY_ARG)));
-    }
-
-    if (in.hasOption(INPUT_OPTIONALLY_ENCLOSED_BY_ARG)) {
-      out.setInputEnclosedBy(SqoopOptions.toChar(
-          in.getOptionValue(INPUT_OPTIONALLY_ENCLOSED_BY_ARG)));
-      out.setInputEncloseRequired(false);
-    }
-
-    if (in.hasOption(INPUT_ENCLOSED_BY_ARG)) {
-      out.setInputEnclosedBy(SqoopOptions.toChar(
-          in.getOptionValue(INPUT_ENCLOSED_BY_ARG)));
-      out.setInputEncloseRequired(true);
-    }
-
-    if (in.hasOption(INPUT_ESCAPED_BY_ARG)) {
-      out.setInputEscapedBy(SqoopOptions.toChar(
-          in.getOptionValue(INPUT_ESCAPED_BY_ARG)));
-    }
-  }
-
-  protected void applyCodeGenOptions(CommandLine in, SqoopOptions out,
-      boolean multiTable) throws InvalidOptionsException {
-    if (in.hasOption(CODE_OUT_DIR_ARG)) {
-      out.setCodeOutputDir(in.getOptionValue(CODE_OUT_DIR_ARG));
-    }
-
-    if (in.hasOption(BIN_OUT_DIR_ARG)) {
-      out.setJarOutputDir(in.getOptionValue(BIN_OUT_DIR_ARG));
-    }
-
-    if (in.hasOption(PACKAGE_NAME_ARG)) {
-      out.setPackageName(in.getOptionValue(PACKAGE_NAME_ARG));
-    }
-
-    if (in.hasOption(MAP_COLUMN_JAVA)) {
-      out.setMapColumn(in.getOptionValue(MAP_COLUMN_JAVA));
-    }
-
-    if (!multiTable && in.hasOption(CLASS_NAME_ARG)) {
-      out.setClassName(in.getOptionValue(CLASS_NAME_ARG));
-    }
-  }
-
-  protected void applyHBaseOptions(CommandLine in, SqoopOptions out) {
-    if (in.hasOption(HBASE_TABLE_ARG)) {
-      out.setHBaseTable(in.getOptionValue(HBASE_TABLE_ARG));
-    }
-
-    if (in.hasOption(HBASE_COL_FAM_ARG)) {
-      out.setHBaseColFamily(in.getOptionValue(HBASE_COL_FAM_ARG));
-    }
-
-    if (in.hasOption(HBASE_ROW_KEY_ARG)) {
-      out.setHBaseRowKeyColumn(in.getOptionValue(HBASE_ROW_KEY_ARG));
-    }
-
-    if (in.hasOption(HBASE_CREATE_TABLE_ARG)) {
-      out.setCreateHBaseTable(true);
-    }
-  }
-
-  protected void validateCommonOptions(SqoopOptions options)
-      throws InvalidOptionsException {
-    if (options.getConnectString() == null) {
-      throw new InvalidOptionsException(
-          "Error: Required argument --connect is missing."
-          + HELP_STR);
-    }
-  }
-
-  protected void validateCodeGenOptions(SqoopOptions options)
-      throws InvalidOptionsException {
-    if (options.getClassName() != null && options.getPackageName() != null) {
-      throw new InvalidOptionsException(
-          "--class-name overrides --package-name. You cannot use both."
-          + HELP_STR);
-    }
-  }
-
-  protected void validateOutputFormatOptions(SqoopOptions options)
-      throws InvalidOptionsException {
-    if (options.doHiveImport()) {
-      if (!options.explicitDelims()) {
-        // user hasn't manually specified delimiters, and wants to import
-        // straight to Hive. Use Hive-style delimiters.
-        LOG.info("Using Hive-specific delimiters for output. You can override");
-        LOG.info("delimiters with --fields-terminated-by, etc.");
-        options.setOutputDelimiters(DelimiterSet.HIVE_DELIMITERS);
-      }
-
-      if (options.getOutputEscapedBy() != DelimiterSet.NULL_CHAR) {
-        LOG.warn("Hive does not support escape characters in fields;");
-        LOG.warn("parse errors in Hive may result from using --escaped-by.");
-      }
-
-      if (options.getOutputEnclosedBy() != DelimiterSet.NULL_CHAR) {
-        LOG.warn("Hive does not support quoted strings; parse errors");
-        LOG.warn("in Hive may result from using --enclosed-by.");
-      }
-    }
-  }
-
-  protected void validateHiveOptions(SqoopOptions options)
-      throws InvalidOptionsException {
-    // Empty; this method is present to maintain API consistency, and
-    // is reserved for future constraints on Hive options.
-    if (options.getHiveDelimsReplacement() != null
-            && options.doHiveDropDelims()) {
-      throw new InvalidOptionsException("The " + HIVE_DROP_DELIMS_ARG
-              + " option conflicts with the " + HIVE_DELIMS_REPLACEMENT_ARG
-              + " option." + HELP_STR);
-    }
-  }
-
-  protected void validateHBaseOptions(SqoopOptions options)
-      throws InvalidOptionsException {
-    if ((options.getHBaseColFamily() != null && options.getHBaseTable() == null)
-        || (options.getHBaseColFamily() == null
-        && options.getHBaseTable() != null)) {
-      throw new InvalidOptionsException(
-          "Both --hbase-table and --column-family must be set together."
-          + HELP_STR);
-    }
-  }
-
-  /**
-   * Given an array of extra arguments (usually populated via
-   * this.extraArguments), determine the offset of the first '--'
-   * argument in the list. Return 'extra.length' if there is none.
-   */
-  protected int getDashPosition(String [] extra) {
-    int dashPos = extra.length;
-    for (int i = 0; i < extra.length; i++) {
-      if (extra[i].equals("--")) {
-        dashPos = i;
-        break;
-      }
-    }
-
-    return dashPos;
-  }
 }
-

Modified: incubator/sqoop/trunk/src/java/com/cloudera/sqoop/tool/CodeGenTool.java
URL: http://svn.apache.org/viewvc/incubator/sqoop/trunk/src/java/com/cloudera/sqoop/tool/CodeGenTool.java?rev=1195852&r1=1195851&r2=1195852&view=diff
==============================================================================
--- incubator/sqoop/trunk/src/java/com/cloudera/sqoop/tool/CodeGenTool.java (original)
+++ incubator/sqoop/trunk/src/java/com/cloudera/sqoop/tool/CodeGenTool.java Tue Nov  1 07:10:13 2011
@@ -1,6 +1,4 @@
 /**
- * Copyright 2011 The Apache Software Foundation
- *
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -17,177 +15,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package com.cloudera.sqoop.tool;
 
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.OptionBuilder;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.hadoop.util.StringUtils;
-
-import com.cloudera.sqoop.Sqoop;
-import com.cloudera.sqoop.SqoopOptions;
-import com.cloudera.sqoop.SqoopOptions.InvalidOptionsException;
-import com.cloudera.sqoop.cli.RelatedOptions;
-import com.cloudera.sqoop.cli.ToolOptions;
-import com.cloudera.sqoop.hive.HiveImport;
-import com.cloudera.sqoop.orm.ClassWriter;
-import com.cloudera.sqoop.orm.CompilationManager;
-
 /**
- * Tool that generates code from a database schema.
+ * @deprecated Moving to use org.apache.sqoop namespace.
  */
-public class CodeGenTool extends BaseSqoopTool {
-
-  public static final Log LOG = LogFactory.getLog(CodeGenTool.class.getName());
-
-  private List<String> generatedJarFiles;
-
-  public CodeGenTool() {
-    super("codegen");
-    generatedJarFiles = new ArrayList<String>();
-  }
-
-  /**
-   * @return a list of jar files generated as part of this import process
-   */
-  public List<String> getGeneratedJarFiles() {
-    ArrayList<String> out = new ArrayList<String>(generatedJarFiles);
-    return out;
-  }
-
-  /**
-   * Generate the .class and .jar files.
-   * @return the filename of the emitted jar file.
-   * @throws IOException
-   */
-  public String generateORM(SqoopOptions options, String tableName)
-      throws IOException {
-    String existingJar = options.getExistingJarName();
-    if (existingJar != null) {
-      // This code generator is being invoked as part of an import or export
-      // process, and the user has pre-specified a jar and class to use.
-      // Don't generate.
-      LOG.info("Using existing jar: " + existingJar);
-      return existingJar;
-    }
-
-    LOG.info("Beginning code generation");
-    CompilationManager compileMgr = new CompilationManager(options);
-    ClassWriter classWriter = new ClassWriter(options, manager, tableName,
-        compileMgr);
-    classWriter.generate();
-    compileMgr.compile();
-    compileMgr.jar();
-    String jarFile = compileMgr.getJarFilename();
-    this.generatedJarFiles.add(jarFile);
-    return jarFile;
-  }
-
-
-  @Override
-  /** {@inheritDoc} */
-  public int run(SqoopOptions options) {
-    if (!init(options)) {
-      return 1;
-    }
-
-    try {
-      generateORM(options, options.getTableName());
-
-      // If the user has also specified Hive import code generation,
-      // use a HiveImport to generate the DDL statements and write
-      // them to files (but don't actually perform the import -- thus
-      // the generateOnly=true in the constructor).
-      if (options.doHiveImport()) {
-        HiveImport hiveImport = new HiveImport(options, manager,
-            options.getConf(), true);
-        hiveImport.importTable(options.getTableName(),
-            options.getHiveTableName(), true);
-      }
-
-    } catch (IOException ioe) {
-      LOG.error("Encountered IOException running codegen job: "
-          + StringUtils.stringifyException(ioe));
-      if (System.getProperty(Sqoop.SQOOP_RETHROW_PROPERTY) != null) {
-        throw new RuntimeException(ioe);
-      } else {
-        return 1;
-      }
-    } finally {
-      destroy(options);
-    }
-
-    return 0;
-  }
-
-  @Override
-  /** Configure the command-line arguments we expect to receive */
-  public void configureOptions(ToolOptions toolOptions) {
-
-    toolOptions.addUniqueOptions(getCommonOptions());
-
-    RelatedOptions codeGenOpts = getCodeGenOpts(false);
-    codeGenOpts.addOption(OptionBuilder.withArgName("table-name")
-        .hasArg()
-        .withDescription("Table to generate code for")
-        .withLongOpt(TABLE_ARG)
-        .create());
-    toolOptions.addUniqueOptions(codeGenOpts);
-
-    toolOptions.addUniqueOptions(getOutputFormatOptions());
-    toolOptions.addUniqueOptions(getInputFormatOptions());
-    toolOptions.addUniqueOptions(getHiveOptions(true));
-  }
-
-  @Override
-  /** {@inheritDoc} */
-  public void printHelp(ToolOptions toolOptions) {
-    super.printHelp(toolOptions);
-    System.out.println("");
-    System.out.println(
-        "At minimum, you must specify --connect and --table");
-  }
-
-  @Override
-  /** {@inheritDoc} */
-  public void applyOptions(CommandLine in, SqoopOptions out)
-      throws InvalidOptionsException {
-
-    if (in.hasOption(TABLE_ARG)) {
-      out.setTableName(in.getOptionValue(TABLE_ARG));
-    }
-
-    applyCommonOptions(in, out);
-    applyOutputFormatOptions(in, out);
-    applyInputFormatOptions(in, out);
-    applyCodeGenOptions(in, out, false);
-    applyHiveOptions(in, out);
-  }
-
-  @Override
-  /** {@inheritDoc} */
-  public void validateOptions(SqoopOptions options)
-      throws InvalidOptionsException {
-
-    if (hasUnrecognizedArgs(extraArguments)) {
-      throw new InvalidOptionsException(HELP_STR);
-    }
-
-    validateCommonOptions(options);
-    validateCodeGenOptions(options);
-    validateOutputFormatOptions(options);
-    validateHiveOptions(options);
-
-    if (options.getTableName() == null) {
-      throw new InvalidOptionsException(
-          "--table is required for code generation." + HELP_STR);
-    }
-  }
+public class CodeGenTool 
+    extends org.apache.sqoop.tool.CodeGenTool {
 }
-

Modified: incubator/sqoop/trunk/src/java/com/cloudera/sqoop/tool/CreateHiveTableTool.java
URL: http://svn.apache.org/viewvc/incubator/sqoop/trunk/src/java/com/cloudera/sqoop/tool/CreateHiveTableTool.java?rev=1195852&r1=1195851&r2=1195852&view=diff
==============================================================================
--- incubator/sqoop/trunk/src/java/com/cloudera/sqoop/tool/CreateHiveTableTool.java (original)
+++ incubator/sqoop/trunk/src/java/com/cloudera/sqoop/tool/CreateHiveTableTool.java Tue Nov  1 07:10:13 2011
@@ -1,6 +1,4 @@
 /**
- * Copyright 2011 The Apache Software Foundation
- *
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -17,122 +15,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package com.cloudera.sqoop.tool;
 
-import java.io.IOException;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.OptionBuilder;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.hadoop.util.StringUtils;
-
-import com.cloudera.sqoop.Sqoop;
-import com.cloudera.sqoop.SqoopOptions;
-import com.cloudera.sqoop.SqoopOptions.InvalidOptionsException;
-import com.cloudera.sqoop.cli.RelatedOptions;
-import com.cloudera.sqoop.cli.ToolOptions;
-import com.cloudera.sqoop.hive.HiveImport;
-
 /**
- * Tool that creates a Hive table definition.
+ * @deprecated Moving to use org.apache.sqoop namespace.
  */
-public class CreateHiveTableTool extends BaseSqoopTool {
-
-  public static final Log LOG = LogFactory.getLog(
-      CreateHiveTableTool.class.getName());
-
-  public CreateHiveTableTool() {
-    super("create-hive-table");
-  }
-
-  @Override
-  /** {@inheritDoc} */
-  public int run(SqoopOptions options) {
-    if (!init(options)) {
-      return 1;
-    }
-
-    try {
-      HiveImport hiveImport = new HiveImport(options, manager,
-          options.getConf(), false);
-      hiveImport.importTable(options.getTableName(),
-          options.getHiveTableName(), true);
-    } catch (IOException ioe) {
-      LOG.error("Encountered IOException running create table job: "
-          + StringUtils.stringifyException(ioe));
-      if (System.getProperty(Sqoop.SQOOP_RETHROW_PROPERTY) != null) {
-        throw new RuntimeException(ioe);
-      } else {
-        return 1;
-      }
-    } finally {
-      destroy(options);
-    }
-
-    return 0;
-  }
-
-  @Override
-  /** Configure the command-line arguments we expect to receive */
-  public void configureOptions(ToolOptions toolOptions) {
-
-    toolOptions.addUniqueOptions(getCommonOptions());
-
-    RelatedOptions hiveOpts = getHiveOptions(false);
-    hiveOpts.addOption(OptionBuilder.withArgName("table-name")
-        .hasArg()
-        .withDescription("The db table to read the definition from")
-        .withLongOpt(TABLE_ARG)
-        .create());
-    toolOptions.addUniqueOptions(hiveOpts);
-
-    toolOptions.addUniqueOptions(getOutputFormatOptions());
-  }
-
-  @Override
-  /** {@inheritDoc} */
-  public void printHelp(ToolOptions toolOptions) {
-    super.printHelp(toolOptions);
-    System.out.println("");
-    System.out.println(
-        "At minimum, you must specify --connect and --table");
-  }
-
-  @Override
-  /** {@inheritDoc} */
-  public void applyOptions(CommandLine in, SqoopOptions out)
-      throws InvalidOptionsException {
-
-    if (in.hasOption(TABLE_ARG)) {
-      out.setTableName(in.getOptionValue(TABLE_ARG));
-    }
-
-    out.setHiveImport(true);
-
-    applyCommonOptions(in, out);
-    applyHiveOptions(in, out);
-    applyOutputFormatOptions(in, out);
-  }
-
-  @Override
-  /** {@inheritDoc} */
-  public void validateOptions(SqoopOptions options)
-      throws InvalidOptionsException {
-
-    if (hasUnrecognizedArgs(extraArguments)) {
-      throw new InvalidOptionsException(HELP_STR);
-    }
-
-    validateCommonOptions(options);
-    validateOutputFormatOptions(options);
-    validateHiveOptions(options);
-
-    if (options.getTableName() == null) {
-      throw new InvalidOptionsException(
-          "--table is required for table definition importing." + HELP_STR);
-    }
-  }
+public class CreateHiveTableTool
+    extends org.apache.sqoop.tool.CreateHiveTableTool {
 }
-

Modified: incubator/sqoop/trunk/src/java/com/cloudera/sqoop/tool/EvalSqlTool.java
URL: http://svn.apache.org/viewvc/incubator/sqoop/trunk/src/java/com/cloudera/sqoop/tool/EvalSqlTool.java?rev=1195852&r1=1195851&r2=1195852&view=diff
==============================================================================
--- incubator/sqoop/trunk/src/java/com/cloudera/sqoop/tool/EvalSqlTool.java (original)
+++ incubator/sqoop/trunk/src/java/com/cloudera/sqoop/tool/EvalSqlTool.java Tue Nov  1 07:10:13 2011
@@ -1,6 +1,4 @@
 /**
- * Copyright 2011 The Apache Software Foundation
- *
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -17,159 +15,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package com.cloudera.sqoop.tool;
 
-import java.io.IOException;
-import java.io.PrintWriter;
-
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.OptionBuilder;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.apache.hadoop.util.StringUtils;
-
-import com.cloudera.sqoop.SqoopOptions;
-import com.cloudera.sqoop.SqoopOptions.InvalidOptionsException;
-import com.cloudera.sqoop.cli.RelatedOptions;
-import com.cloudera.sqoop.cli.ToolOptions;
-import com.cloudera.sqoop.util.ResultSetPrinter;
-
 /**
- * Tool that evaluates a SQL statement and displays the results.
+ * @deprecated Moving to use org.apache.sqoop namespace.
  */
-public class EvalSqlTool extends BaseSqoopTool {
-
-  public static final Log LOG = LogFactory.getLog(EvalSqlTool.class.getName());
-
-  public EvalSqlTool() {
-    super("eval");
-  }
-
-  @Override
-  /** {@inheritDoc} */
-  public int run(SqoopOptions options) {
-    if (!init(options)) {
-      return 1;
-    }
-
-    PreparedStatement stmt = null;
-    ResultSet rs = null;
-    PrintWriter pw = null;
-    try {
-      Connection c = manager.getConnection();
-      String query = options.getSqlQuery();
-      LOG.debug("SQL query: " + query);
-      stmt = c.prepareStatement(query);
-      boolean resultType = stmt.execute();
-      // Iterate over all the results from this statement.
-      while (true) {
-        LOG.debug("resultType=" + resultType);
-        if (!resultType) {
-          // This result was an update count.
-          int updateCount = stmt.getUpdateCount();
-          LOG.debug("updateCount=" + updateCount);
-          if (updateCount == -1) {
-            // We are done iterating over results from this statement.
-            c.commit();
-            break;
-          } else {
-            LOG.info(updateCount + " row(s) updated.");
-          }
-        } else {
-          // This yields a ResultSet.
-          rs = stmt.getResultSet();
-          pw = new PrintWriter(System.out, true);
-          new ResultSetPrinter().printResultSet(pw, rs);
-          pw.close();
-          pw = null;
-        }
-
-        resultType = stmt.getMoreResults();
-      }
-    } catch (IOException ioe) {
-      LOG.warn("IOException formatting results: "
-          + StringUtils.stringifyException(ioe));
-      return 1;
-    } catch (SQLException sqlE) {
-      LOG.warn("SQL exception executing statement: "
-          + StringUtils.stringifyException(sqlE));
-      return 1;
-    } finally {
-      if (null != pw) {
-        pw.close();
-      }
-      if (null != rs) {
-        try {
-          rs.close();
-        } catch (SQLException sqlE) {
-          LOG.warn("SQL exception closing ResultSet: "
-              + StringUtils.stringifyException(sqlE));
-        }
-      }
-      if (null != stmt) {
-        try {
-          stmt.close();
-        } catch (SQLException sqlE) {
-          LOG.warn("SQL exception closing statement: "
-              + StringUtils.stringifyException(sqlE));
-        }
-      }
-      destroy(options);
-    }
-
-    return 0;
-  }
-
-  @Override
-  /** Configure the command-line arguments we expect to receive */
-  public void configureOptions(ToolOptions toolOptions) {
-    toolOptions.addUniqueOptions(getCommonOptions());
-
-    RelatedOptions evalOpts = new RelatedOptions("SQL evaluation arguments");
-    evalOpts.addOption(OptionBuilder.withArgName("statement")
-        .hasArg()
-        .withDescription("Execute 'statement' in SQL and exit")
-        .withLongOpt(SQL_QUERY_ARG)
-        .create(SQL_QUERY_SHORT_ARG));
-
-    toolOptions.addUniqueOptions(evalOpts);
-  }
-
-  @Override
-  /** {@inheritDoc} */
-  public void applyOptions(CommandLine in, SqoopOptions out)
-      throws InvalidOptionsException {
-
-    applyCommonOptions(in, out);
-    if (in.hasOption(SQL_QUERY_ARG)) {
-      out.setSqlQuery(in.getOptionValue(SQL_QUERY_ARG));
-    }
-  }
-
-  @Override
-  /** {@inheritDoc} */
-  public void validateOptions(SqoopOptions options)
-      throws InvalidOptionsException {
-
-    if (hasUnrecognizedArgs(extraArguments)) {
-      throw new InvalidOptionsException(HELP_STR);
-    }
-
-    String sqlCmd = options.getSqlQuery();
-    if (null == sqlCmd || sqlCmd.length() == 0) {
-      throw new InvalidOptionsException(
-          "This command requires the " + SQL_QUERY_ARG + " argument."
-          + HELP_STR);
-    }
-
-    validateCommonOptions(options);
-  }
+public class EvalSqlTool
+    extends org.apache.sqoop.tool.EvalSqlTool {
 }
-

Modified: incubator/sqoop/trunk/src/java/com/cloudera/sqoop/tool/ExportTool.java
URL: http://svn.apache.org/viewvc/incubator/sqoop/trunk/src/java/com/cloudera/sqoop/tool/ExportTool.java?rev=1195852&r1=1195851&r2=1195852&view=diff
==============================================================================
--- incubator/sqoop/trunk/src/java/com/cloudera/sqoop/tool/ExportTool.java (original)
+++ incubator/sqoop/trunk/src/java/com/cloudera/sqoop/tool/ExportTool.java Tue Nov  1 07:10:13 2011
@@ -1,6 +1,4 @@
 /**
- * Copyright 2011 The Apache Software Foundation
- *
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -17,336 +15,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package com.cloudera.sqoop.tool;
 
-import java.io.IOException;
-import java.util.List;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.OptionBuilder;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import com.cloudera.sqoop.Sqoop;
-import com.cloudera.sqoop.SqoopOptions;
-import com.cloudera.sqoop.SqoopOptions.InvalidOptionsException;
-import com.cloudera.sqoop.SqoopOptions.UpdateMode;
-import com.cloudera.sqoop.cli.RelatedOptions;
-import com.cloudera.sqoop.cli.ToolOptions;
-import com.cloudera.sqoop.manager.ExportJobContext;
-import com.cloudera.sqoop.util.ExportException;
-
 /**
- * Tool that performs HDFS exports to databases.
+ * @deprecated Moving to use org.apache.sqoop namespace.
  */
-public class ExportTool extends BaseSqoopTool {
-
-  public static final Log LOG = LogFactory.getLog(ExportTool.class.getName());
-
-  private CodeGenTool codeGenerator;
-
-  public ExportTool() {
-    super("export");
-    this.codeGenerator = new CodeGenTool();
-  }
-
-  /**
-   * @return a list of jar files generated as part of this im/export process
-   */
-  public List<String> getGeneratedJarFiles() {
-    return codeGenerator.getGeneratedJarFiles();
-  }
-
-  private void exportTable(SqoopOptions options, String tableName)
-      throws ExportException, IOException {
-    String jarFile = null;
-
-    // Generate the ORM code for the tables.
-    jarFile = codeGenerator.generateORM(options, tableName);
-
-    ExportJobContext context = new ExportJobContext(tableName, jarFile,
-        options);
-    if (options.getUpdateKeyCol() != null) {
-      if (options.getUpdateMode() == UpdateMode.UpdateOnly) {
-        // UPDATE-based export.
-        manager.updateTable(context);
-      } else {
-        // Mixed update/insert export
-        manager.upsertTable(context);
-      }
-    } else {
-      // INSERT-based export.
-      manager.exportTable(context);
-    }
-  }
-
-  @Override
-  /** {@inheritDoc} */
-  public int run(SqoopOptions options) {
-
-    if (!init(options)) {
-      return 1;
-    }
-
-    codeGenerator.setManager(manager);
-
-    if (options.getUpdateKeyCol() != null) {
-      manager.configureDbOutputColumns(options);
-    }
-
-    try {
-      exportTable(options, options.getTableName());
-    } catch (IOException ioe) {
-      LOG.error("Encountered IOException running export job: "
-          + ioe.toString());
-      if (System.getProperty(Sqoop.SQOOP_RETHROW_PROPERTY) != null) {
-        throw new RuntimeException(ioe);
-      } else {
-        return 1;
-      }
-    } catch (ExportException ee) {
-      LOG.error("Error during export: " + ee.toString());
-      if (System.getProperty(Sqoop.SQOOP_RETHROW_PROPERTY) != null) {
-        throw new RuntimeException(ee);
-      } else {
-        return 1;
-      }
-    } finally {
-      destroy(options);
-    }
-
-    return 0;
-  }
-
-  /**
-   * Construct the set of options that control exports.
-   * @return the RelatedOptions that can be used to parse the export
-   * arguments.
-   */
-  protected RelatedOptions getExportOptions() {
-    RelatedOptions exportOpts = new RelatedOptions("Export control arguments");
-
-    exportOpts.addOption(OptionBuilder
-        .withDescription("Use direct export fast path")
-        .withLongOpt(DIRECT_ARG)
-        .create());
-    exportOpts.addOption(OptionBuilder.withArgName("table-name")
-        .hasArg().withDescription("Table to populate")
-        .withLongOpt(TABLE_ARG)
-        .create());
-    exportOpts.addOption(OptionBuilder.withArgName("n")
-        .hasArg().withDescription("Use 'n' map tasks to export in parallel")
-        .withLongOpt(NUM_MAPPERS_ARG)
-        .create(NUM_MAPPERS_SHORT_ARG));
-    exportOpts.addOption(OptionBuilder.withArgName("dir")
-        .hasArg()
-        .withDescription("HDFS source path for the export")
-        .withLongOpt(EXPORT_PATH_ARG)
-        .create());
-    exportOpts.addOption(OptionBuilder.withArgName("key")
-        .hasArg()
-        .withDescription("Update records by specified key column")
-        .withLongOpt(UPDATE_KEY_ARG)
-        .create());
-    exportOpts.addOption(OptionBuilder.withArgName("table-name")
-        .hasArg().withDescription("Intermediate staging table")
-        .withLongOpt(STAGING_TABLE_ARG)
-        .create());
-    exportOpts.addOption(OptionBuilder
-        .withDescription("Indicates that any data in "
-        + "staging table can be deleted")
-        .withLongOpt(CLEAR_STAGING_TABLE_ARG)
-        .create());
-    exportOpts.addOption(OptionBuilder
-        .withDescription("Indicates underlying statements "
-        + "to be executed in batch mode")
-        .withLongOpt(BATCH_ARG)
-        .create());
-    exportOpts.addOption(OptionBuilder
-        .withArgName("mode")
-        .hasArg()
-        .withDescription("Specifies how updates are performed when "
-            + "new rows are found with non-matching keys in database")
-        .withLongOpt(UPDATE_MODE_ARG)
-        .create());
-
-    return exportOpts;
-  }
-
-  @Override
-  /** Configure the command-line arguments we expect to receive */
-  public void configureOptions(ToolOptions toolOptions) {
-
-    toolOptions.addUniqueOptions(getCommonOptions());
-    toolOptions.addUniqueOptions(getExportOptions());
-
-    // Input parsing delimiters
-    toolOptions.addUniqueOptions(getInputFormatOptions());
-
-    // Used when sending data to a direct-mode export.
-    toolOptions.addUniqueOptions(getOutputFormatOptions());
-
-    // get common codegen opts.
-    RelatedOptions codeGenOpts = getCodeGenOpts(false);
-
-    // add export-specific codegen opts:
-    codeGenOpts.addOption(OptionBuilder.withArgName("file")
-        .hasArg()
-        .withDescription("Disable code generation; use specified jar")
-        .withLongOpt(JAR_FILE_NAME_ARG)
-        .create());
-
-    toolOptions.addUniqueOptions(codeGenOpts);
-  }
-
-  @Override
-  /** {@inheritDoc} */
-  public void printHelp(ToolOptions toolOptions) {
-    super.printHelp(toolOptions);
-    System.out.println("");
-    System.out.println(
-        "At minimum, you must specify --connect, --export-dir, and --table");
-  }
-
-  @Override
-  /** {@inheritDoc} */
-  public void applyOptions(CommandLine in, SqoopOptions out)
-      throws InvalidOptionsException {
-
-    try {
-      applyCommonOptions(in, out);
-
-      if (in.hasOption(DIRECT_ARG)) {
-        out.setDirectMode(true);
-      }
-
-      if (in.hasOption(BATCH_ARG)) {
-        out.setBatchMode(true);
-      }
-
-      if (in.hasOption(TABLE_ARG)) {
-        out.setTableName(in.getOptionValue(TABLE_ARG));
-      }
-
-      if (in.hasOption(NUM_MAPPERS_ARG)) {
-        out.setNumMappers(Integer.parseInt(in.getOptionValue(NUM_MAPPERS_ARG)));
-      }
-
-      if (in.hasOption(EXPORT_PATH_ARG)) {
-        out.setExportDir(in.getOptionValue(EXPORT_PATH_ARG));
-      }
-
-      if (in.hasOption(JAR_FILE_NAME_ARG)) {
-        out.setExistingJarName(in.getOptionValue(JAR_FILE_NAME_ARG));
-      }
-
-      if (in.hasOption(UPDATE_KEY_ARG)) {
-        out.setUpdateKeyCol(in.getOptionValue(UPDATE_KEY_ARG));
-      }
-
-      if (in.hasOption(STAGING_TABLE_ARG)) {
-        out.setStagingTableName(in.getOptionValue(STAGING_TABLE_ARG));
-      }
-
-      if (in.hasOption(CLEAR_STAGING_TABLE_ARG)) {
-        out.setClearStagingTable(true);
-      }
-
-      applyNewUpdateOptions(in, out);
-      applyInputFormatOptions(in, out);
-      applyOutputFormatOptions(in, out);
-      applyOutputFormatOptions(in, out);
-      applyCodeGenOptions(in, out, false);
-    } catch (NumberFormatException nfe) {
-      throw new InvalidOptionsException("Error: expected numeric argument.\n"
-          + "Try --help for usage.");
-    }
-  }
-
-  /**
-   * Validate export-specific arguments.
-   * @param options the configured SqoopOptions to check
-   */
-  protected void validateExportOptions(SqoopOptions options)
-      throws InvalidOptionsException {
-    if (options.getTableName() == null) {
-      throw new InvalidOptionsException("Export requires a --table argument."
-          + HELP_STR);
-    } else if (options.getExportDir() == null) {
-      throw new InvalidOptionsException(
-          "Export requires an --export-dir argument."
-          + HELP_STR);
-    } else if (options.getExistingJarName() != null
-        && options.getClassName() == null) {
-      throw new InvalidOptionsException("Jar specified with --jar-file, but no "
-          + "class specified with --class-name." + HELP_STR);
-    } else if (options.getExistingJarName() != null
-        && options.getUpdateKeyCol() != null) {
-      // We need to regenerate the class with the output column order set
-      // correctly for the update-based export. So we can't use a premade
-      // class.
-      throw new InvalidOptionsException("Jar cannot be specified with "
-          + "--jar-file when export is running in update mode.");
-    } else if (options.getStagingTableName() != null
-        && options.getUpdateKeyCol() != null) {
-      // Staging table may not be used when export is running in update mode
-      throw new InvalidOptionsException("Staging table cannot be used when "
-          + "export is running in update mode.");
-    } else if (options.getStagingTableName() != null
-        && options.getStagingTableName().equalsIgnoreCase(
-            options.getTableName())) {
-      // Name of staging table and destination table cannot be the same
-      throw new InvalidOptionsException("Staging table cannot be the same as "
-          + "the destination table. Name comparison used is case-insensitive.");
-    } else if (options.doClearStagingTable()
-        && options.getStagingTableName() == null) {
-      // Option to clear staging table specified but not the staging table name
-      throw new InvalidOptionsException("Option to clear the staging table is "
-          + "specified but the staging table name is not.");
-    }
-  }
-
-  @Override
-  /** {@inheritDoc} */
-  public void validateOptions(SqoopOptions options)
-      throws InvalidOptionsException {
-
-    // If extraArguments is full, check for '--' followed by args for
-    // mysqldump or other commands we rely on.
-    options.setExtraArgs(getSubcommandArgs(extraArguments));
-    int dashPos = extraArguments.length;
-    for (int i = 0; i < extraArguments.length; i++) {
-      if (extraArguments[i].equals("--")) {
-        dashPos = i;
-        break;
-      }
-    }
-
-    if (hasUnrecognizedArgs(extraArguments, 0, dashPos)) {
-      throw new InvalidOptionsException(HELP_STR);
-    }
-
-    validateExportOptions(options);
-    validateOutputFormatOptions(options);
-    validateCommonOptions(options);
-    validateCodeGenOptions(options);
-  }
-
-  private void applyNewUpdateOptions(CommandLine in, SqoopOptions out)
-      throws InvalidOptionsException {
-    if (in.hasOption(UPDATE_MODE_ARG)) {
-      String updateTypeStr = in.getOptionValue(UPDATE_MODE_ARG);
-      if ("updateonly".equals(updateTypeStr)) {
-        out.setUpdateMode(UpdateMode.UpdateOnly);
-      } else if ("allowinsert".equals(updateTypeStr)) {
-        out.setUpdateMode(UpdateMode.AllowInsert);
-      } else {
-        throw new InvalidOptionsException("Unknown new update mode: "
-            + updateTypeStr + ". Use 'updateonly' or 'allowinsert'."
-            + HELP_STR);
-      }
-    }
-  }
+public class ExportTool
+    extends org.apache.sqoop.tool.ExportTool {
 }
-

Modified: incubator/sqoop/trunk/src/java/com/cloudera/sqoop/tool/HelpTool.java
URL: http://svn.apache.org/viewvc/incubator/sqoop/trunk/src/java/com/cloudera/sqoop/tool/HelpTool.java?rev=1195852&r1=1195851&r2=1195852&view=diff
==============================================================================
--- incubator/sqoop/trunk/src/java/com/cloudera/sqoop/tool/HelpTool.java (original)
+++ incubator/sqoop/trunk/src/java/com/cloudera/sqoop/tool/HelpTool.java Tue Nov  1 07:10:13 2011
@@ -1,6 +1,4 @@
 /**
- * Copyright 2011 The Apache Software Foundation
- *
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -17,96 +15,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package com.cloudera.sqoop.tool;
 
-import java.util.Set;
-
-import com.cloudera.sqoop.SqoopOptions;
-import com.cloudera.sqoop.cli.ToolOptions;
-
 /**
- * Tool that explains the usage of Sqoop.
+ * @deprecated Moving to use org.apache.sqoop namespace.
  */
-public class HelpTool extends BaseSqoopTool {
-
-  public HelpTool() {
-    super("help");
-  }
-
-  /**
-   * @param str the string to right-side pad
-   * @param num the minimum number of characters to return
-   * @return 'str' with enough right padding to make it num characters long.
-   */
-  private static String padRight(String str, int num) {
-    StringBuilder sb = new StringBuilder();
-    sb.append(str);
-    for (int count = str.length(); count < num; count++) {
-      sb.append(" ");
-    }
-
-    return sb.toString();
-  }
-
-  /**
-   * Print out a list of all SqoopTool implementations and their
-   * descriptions.
-   */
-  private void printAvailableTools() {
-    System.out.println("usage: sqoop COMMAND [ARGS]");
-    System.out.println("");
-    System.out.println("Available commands:");
-
-    Set<String> toolNames = getToolNames();
-
-    int maxWidth = 0;
-    for (String tool : toolNames) {
-      maxWidth = Math.max(maxWidth, tool.length());
-    }
-
-    for (String tool : toolNames) {
-      System.out.println("  " + padRight(tool, maxWidth+2)
-          + getToolDescription(tool));
-    }
-
-    System.out.println("");
-    System.out.println(
-        "See 'sqoop help COMMAND' for information on a specific command.");
-  }
-
-
-  @Override
-  /** {@inheritDoc} */
-  public int run(SqoopOptions options) {
-
-    if (this.extraArguments != null && this.extraArguments.length > 0) {
-      if (hasUnrecognizedArgs(extraArguments, 1, extraArguments.length)) {
-        return 1;
-      }
-
-      SqoopTool subTool = SqoopTool.getTool(extraArguments[0]);
-      if (null == subTool) {
-        System.out.println("No such tool: " + extraArguments[0]);
-        System.out.println(
-            "Try 'sqoop help' for a list of available commands.");
-        return 1;
-      } else {
-        ToolOptions toolOpts = new ToolOptions();
-        subTool.configureOptions(toolOpts);
-        subTool.printHelp(toolOpts);
-        return 0;
-      }
-    } else {
-      printAvailableTools();
-    }
-
-    return 0;
-  }
-
-  @Override
-  public void printHelp(ToolOptions opts) {
-    System.out.println("usage: sqoop " + getToolName() + " [COMMAND]");
-  }
+public class HelpTool
+    extends org.apache.sqoop.tool.HelpTool {
 }
-

Modified: incubator/sqoop/trunk/src/java/com/cloudera/sqoop/tool/ImportAllTablesTool.java
URL: http://svn.apache.org/viewvc/incubator/sqoop/trunk/src/java/com/cloudera/sqoop/tool/ImportAllTablesTool.java?rev=1195852&r1=1195851&r2=1195852&view=diff
==============================================================================
--- incubator/sqoop/trunk/src/java/com/cloudera/sqoop/tool/ImportAllTablesTool.java (original)
+++ incubator/sqoop/trunk/src/java/com/cloudera/sqoop/tool/ImportAllTablesTool.java Tue Nov  1 07:10:13 2011
@@ -1,6 +1,4 @@
 /**
- * Copyright 2011 The Apache Software Foundation
- *
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -17,76 +15,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package com.cloudera.sqoop.tool;
 
-import java.io.IOException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import com.cloudera.sqoop.Sqoop;
-import com.cloudera.sqoop.SqoopOptions;
-import com.cloudera.sqoop.hive.HiveImport;
-import com.cloudera.sqoop.util.ImportException;
-
 /**
- * Tool that performs database imports of all tables in a database to HDFS.
+ * @deprecated Moving to use org.apache.sqoop namespace.
  */
-public class ImportAllTablesTool extends ImportTool {
-
-  public static final Log LOG = LogFactory.getLog(
-      ImportAllTablesTool.class.getName());
-
-  public ImportAllTablesTool() {
-    super("import-all-tables", true);
-  }
-
-  @Override
-  /** {@inheritDoc} */
-  public int run(SqoopOptions options) {
-    HiveImport hiveImport = null;
-
-    if (!init(options)) {
-      return 1;
-    }
-
-    try {
-      if (options.doHiveImport()) {
-        hiveImport = new HiveImport(options, manager, options.getConf(), false);
-      }
-
-      String [] tables = manager.listTables();
-      if (null == tables) {
-        System.err.println("Could not retrieve tables list from server");
-        LOG.error("manager.listTables() returned null");
-        return 1;
-      } else {
-        for (String tableName : tables) {
-          importTable(options, tableName, hiveImport);
-        }
-      }
-    } catch (IOException ioe) {
-      LOG.error("Encountered IOException running import job: "
-          + ioe.toString());
-      if (System.getProperty(Sqoop.SQOOP_RETHROW_PROPERTY) != null) {
-        throw new RuntimeException(ioe);
-      } else {
-        return 1;
-      }
-    } catch (ImportException ie) {
-      LOG.error("Error during import: " + ie.toString());
-      if (System.getProperty(Sqoop.SQOOP_RETHROW_PROPERTY) != null) {
-        throw new RuntimeException(ie);
-      } else {
-        return 1;
-      }
-    } finally {
-      destroy(options);
-    }
-
-    return 0;
-  }
-
+public class ImportAllTablesTool
+    extends org.apache.sqoop.tool.ImportAllTablesTool {
 }
-



Mime
View raw message