コード例 #1
0
  /**
   * Executes ETL based on a specified configuration.
   *
   * @param indicator progress indicator to use.
   * @return execution statistics for ETL execution.
   * @throws EtlExecutorException if ETL fails.
   */
  @ThreadSafe
  public ExecutionStatistics execute(final ProgressIndicator indicator)
      throws EtlExecutorException {
    EtlContext ctx = null;
    JmxEtlManager etlManager = null;

    try {
      ctx = prepare(indicator);
      if (jmxEnabled) {
        etlManager = new JmxEtlManager(ctx);
        etlManager.register();
      }
      execute(ctx);
      ctx.getProgressCallback().step(5, "Commiting transactions");
      commitAll(ctx);
    } catch (Throwable e) {
      if (ctx != null) {
        rollbackAll(ctx);
      }
      throw new EtlExecutorException(e);
    } finally {
      if (ctx != null) {
        closeAll(ctx);
        ctx.getStatisticsBuilder().etlComplete();
        ctx.getProgressCallback().complete();
      }
      if (etlManager != null) {
        etlManager.unregister();
      }
    }

    return ctx.getStatisticsBuilder().getStatistics();
  }
コード例 #2
0
  /**
   * Prepares the scripts context.
   *
   * @param indicator progress indicator to use.
   * @return prepared scripts context.
   */
  protected EtlContext prepare(final ProgressIndicator indicator) {
    EtlContext ctx = new EtlContext(!suppressStatistics);
    ctx.getStatisticsBuilder().etlStarted();
    ctx.setBaseURL(configuration.getDocumentUrl());
    ctx.setProgressCallback(new ProgressCallback(100, indicator));

    final ProgressCallback progress = ctx.getProgressCallback();
    progress.step(1, "Initializing properties");
    ctx.setProperties(configuration.getParameters());
    ctx.setProgressCallback(progress.fork(9, 100));
    ctx.session = new Session(configuration, ctx);
    ctx.getProgressCallback().complete();
    ctx.setProgressCallback(progress); // Restoring

    return ctx;
  }