コード例 #1
0
ファイル: SQLServerManager.java プロジェクト: mapr/sqoop
  /** {@inheritDoc} */
  @Override
  public void importTable(com.cloudera.sqoop.manager.ImportJobContext context)
      throws IOException, ImportException {
    // We're the correct connection manager
    context.setConnManager(this);

    // Propagate table hints to job
    Configuration configuration = context.getOptions().getConf();
    if (tableHints != null) {
      configuration.set(TABLE_HINTS_PROP, tableHints);
    }
    if (!isNonResilientOperation()) {
      // Enable connection recovery only if split column is provided
      SqoopOptions opts = context.getOptions();
      String splitCol = getSplitColumn(opts, context.getTableName());
      if (splitCol != null) {
        // Configure SQLServer table import jobs for connection recovery
        configureConnectionRecoveryForImport(context);
      } else {
        // Set our own input format
        context.setInputFormat(SqlServerInputFormat.class);
      }
    } else {
      context.setInputFormat(SqlServerInputFormat.class);
    }
    super.importTable(context);
  }
コード例 #2
0
  @Override
  /** {@inheritDoc} */
  public void configureDbOutputColumns(SqoopOptions options) {
    // In case that we're running upsert, we do not want to change column order
    // as we're actually going to use INSERT INTO ... ON DUPLICATE KEY UPDATE
    // clause.
    if (options.getUpdateMode() == SqoopOptions.UpdateMode.AllowInsert) {
      return;
    }

    super.configureDbOutputColumns(options);
  }
コード例 #3
0
ファイル: SQLServerManager.java プロジェクト: mapr/sqoop
 /**
  * Launch a MapReduce job via DataDrivenImportJob to read the table with SQLServerDBInputFormat
  * which handles connection failures while using free-form query importer.
  */
 public void importQuery(com.cloudera.sqoop.manager.ImportJobContext context)
     throws IOException, ImportException {
   if (!isNonResilientOperation()) {
     // Enable connection recovery only if split column is provided
     SqoopOptions opts = context.getOptions();
     String splitCol = getSplitColumn(opts, context.getTableName());
     if (splitCol != null) {
       // Configure SQLServer query import jobs for connection recovery
       configureConnectionRecoveryForImport(context);
     }
   }
   super.importQuery(context);
 }
コード例 #4
0
ファイル: SQLServerManager.java プロジェクト: mapr/sqoop
 @Override
 /** {@inheritDoc} */
 public void updateTable(com.cloudera.sqoop.manager.ExportJobContext context)
     throws IOException, ExportException {
   if (isNonResilientOperation()) {
     super.updateTable(context);
   } else {
     context.setConnManager(this);
     JdbcUpdateExportJob exportJob =
         new JdbcUpdateExportJob(context, null, null, SQLServerResilientUpdateOutputFormat.class);
     configureConnectionRecoveryForUpdate(context);
     exportJob.runExport();
   }
 }
コード例 #5
0
  @Override
  public void importTable(com.cloudera.sqoop.manager.ImportJobContext context)
      throws IOException, ImportException {

    // Check that we're not doing a MapReduce from localhost. If we are, point
    // out that we could use mysqldump.
    if (!MySQLManager.warningPrinted) {
      String connectString = context.getOptions().getConnectString();

      if (null != connectString) {
        // DirectMySQLManager will probably be faster.
        LOG.warn("It looks like you are importing from mysql.");
        LOG.warn("This transfer can be faster! Use the --direct");
        LOG.warn("option to exercise a MySQL-specific fast path.");

        MySQLManager.markWarningPrinted(); // don't display this twice.
      }
    }

    checkDateTimeBehavior(context);

    // Then run the normal importTable() method.
    super.importTable(context);
  }