Search in sources :

Example 1 with ExecSession

use of org.embulk.spi.ExecSession in project embulk by embulk.

the class EmbulkEmbed method preview.

public PreviewResult preview(ConfigSource config) {
    this.logger.info("Started Embulk v" + EmbulkVersion.VERSION);
    ExecSession exec = newExecSession(config);
    try {
        return previewExecutor.preview(exec, config);
    } finally {
        exec.cleanup();
    }
}
Also used : ExecSession(org.embulk.spi.ExecSession)

Example 2 with ExecSession

use of org.embulk.spi.ExecSession in project embulk by embulk.

the class EmbulkEmbed method guess.

public ConfigDiff guess(ConfigSource config) {
    this.logger.info("Started Embulk v" + EmbulkVersion.VERSION);
    ExecSession exec = newExecSession(config);
    try {
        return guessExecutor.guess(exec, config);
    } finally {
        exec.cleanup();
    }
}
Also used : ExecSession(org.embulk.spi.ExecSession)

Example 3 with ExecSession

use of org.embulk.spi.ExecSession in project embulk by embulk.

the class BulkLoader method resume.

public ExecutionResult resume(final ConfigSource config, final ResumeState resume) {
    try {
        ExecSession exec = ExecSession.builder(injector).fromExecConfig(resume.getExecSessionConfigSource()).build();
        ExecutionResult result = Exec.doWith(exec, new ExecAction<ExecutionResult>() {

            public ExecutionResult run() {
                try (SetCurrentThreadName dontCare = new SetCurrentThreadName("resume")) {
                    return doResume(config, resume);
                }
            }
        });
        exec.cleanup();
        return result;
    } catch (ExecutionException ex) {
        throw Throwables.propagate(ex.getCause());
    }
}
Also used : ExecSession(org.embulk.spi.ExecSession) ExecutionException(java.util.concurrent.ExecutionException)

Example 4 with ExecSession

use of org.embulk.spi.ExecSession in project embulk by embulk.

the class EmbulkEmbed method run.

public ExecutionResult run(ConfigSource config) {
    this.logger.info("Started Embulk v" + EmbulkVersion.VERSION);
    ExecSession exec = newExecSession(config);
    try {
        return bulkLoader.run(exec, config);
    } catch (PartialExecutionException partial) {
        try {
            bulkLoader.cleanup(config, partial.getResumeState());
        } catch (Throwable ex) {
            partial.addSuppressed(ex);
        }
        throw partial;
    } finally {
        try {
            exec.cleanup();
        } catch (Exception ex) {
            // TODO add this exception to ExecutionResult.getIgnoredExceptions
            // or partial.addSuppressed
            ex.printStackTrace(System.err);
        }
    }
}
Also used : PartialExecutionException(org.embulk.exec.PartialExecutionException) ExecSession(org.embulk.spi.ExecSession) PartialExecutionException(org.embulk.exec.PartialExecutionException)

Example 5 with ExecSession

use of org.embulk.spi.ExecSession in project embulk by embulk.

the class EmbulkEmbed method runResumable.

public ResumableResult runResumable(ConfigSource config) {
    this.logger.info("Started Embulk v" + EmbulkVersion.VERSION);
    ExecSession exec = newExecSession(config);
    try {
        ExecutionResult result;
        try {
            result = bulkLoader.run(exec, config);
        } catch (PartialExecutionException partial) {
            return new ResumableResult(partial);
        }
        return new ResumableResult(result);
    } finally {
        try {
            exec.cleanup();
        } catch (Exception ex) {
            // TODO add this exception to ExecutionResult.getIgnoredExceptions
            // or partial.addSuppressed
            ex.printStackTrace(System.err);
        }
    }
}
Also used : PartialExecutionException(org.embulk.exec.PartialExecutionException) ExecutionResult(org.embulk.exec.ExecutionResult) ExecSession(org.embulk.spi.ExecSession) PartialExecutionException(org.embulk.exec.PartialExecutionException)

Aggregations

ExecSession (org.embulk.spi.ExecSession)6 ExecutionException (java.util.concurrent.ExecutionException)2 PartialExecutionException (org.embulk.exec.PartialExecutionException)2 ExecutionResult (org.embulk.exec.ExecutionResult)1