/** {@inheritDoc} */
  @Override
  public void upsertTable(com.cloudera.sqoop.manager.ExportJobContext context)
      throws IOException, ExportException {
    context.setConnManager(this);
    LOG.warn("MySQL Connector upsert functionality is using INSERT ON");
    LOG.warn("DUPLICATE KEY UPDATE clause that relies on table's unique key.");
    LOG.warn("Insert/update distinction is therefore independent on column");
    LOG.warn("names specified in --update-key parameter. Please see MySQL");
    LOG.warn("documentation for additional limitations.");

    JdbcUpsertExportJob exportJob = new JdbcUpsertExportJob(context, MySQLUpsertOutputFormat.class);
    exportJob.runExport();
  }
Example #2
0
 @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();
   }
 }
Example #3
0
  /** Export data stored in HDFS into a table in a database. */
  @Override
  public void exportTable(com.cloudera.sqoop.manager.ExportJobContext context)
      throws IOException, ExportException {
    context.setConnManager(this);

    // Propagate table hints to job
    Configuration configuration = context.getOptions().getConf();
    if (tableHints != null) {
      configuration.set(TABLE_HINTS_PROP, tableHints);
    }

    // Propagate whether to allow identity inserts to job
    configuration.setBoolean(IDENTITY_INSERT_PROP, identityInserts);

    JdbcExportJob exportJob;
    if (isNonResilientOperation()) {
      exportJob = new JdbcExportJob(context, null, null, SqlServerExportBatchOutputFormat.class);
    } else {
      exportJob =
          new JdbcExportJob(context, null, null, SQLServerResilientExportOutputFormat.class);
      configureConnectionRecoveryForExport(context);
    }
    exportJob.runExport();
  }
Example #4
0
  /**
   * Configure SQLServer Sqoop Update Jobs to recover connection failures by using
   * SQLServerConnectionFailureHandler by default.
   */
  protected void configureConnectionRecoveryForUpdate(
      com.cloudera.sqoop.manager.ExportJobContext context) {

    Configuration conf = context.getOptions().getConf();

    // Set connection failure handler and recovery settings
    // Default settings can be overridden if provided as Configuration
    // properties by the user
    String clsFailureHandler =
        conf.get(SQLServerResilientExportOutputFormat.EXPORT_FAILURE_HANDLER_CLASS);
    if (clsFailureHandler == null) {
      conf.set(
          SQLServerResilientExportOutputFormat.EXPORT_FAILURE_HANDLER_CLASS,
          SQLServerConnectionFailureHandler.class.getName());
    }
  }
Example #5
0
 public void exportTable(ExportJobContext context) throws IOException, ExportException {
   context.setConnManager(this);
   PostgreSQLCopyExportJob job =
       new PostgreSQLCopyExportJob(context, null, ExportInputFormat.class, NullOutputFormat.class);
   job.runExport();
 }