Search in sources :

Example 1 with AbortTransactionResource

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

the class Executors method process.

public static void process(ExecSession exec, int taskIndex, InputPlugin inputPlugin, Schema inputSchema, TaskSource inputTaskSource, List<FilterPlugin> filterPlugins, List<Schema> filterSchemas, List<TaskSource> filterTaskSources, OutputPlugin outputPlugin, Schema outputSchema, TaskSource outputTaskSource, ProcessStateCallback callback) {
    TransactionalPageOutput tran = PluginWrappers.transactionalPageOutput(outputPlugin.open(outputTaskSource, outputSchema, taskIndex));
    callback.started();
    // essential exception.
    try (CloseResource closer = new CloseResource(tran)) {
        try (AbortTransactionResource aborter = new AbortTransactionResource(tran)) {
            PageOutput filtered = Filters.open(filterPlugins, filterTaskSources, filterSchemas, tran);
            closer.closeThis(filtered);
            TaskReport inputTaskReport = inputPlugin.run(inputTaskSource, inputSchema, taskIndex, filtered);
            if (inputTaskReport == null) {
                inputTaskReport = exec.newTaskReport();
            }
            callback.inputCommitted(inputTaskReport);
            TaskReport outputTaskReport = tran.commit();
            aborter.dontAbort();
            if (outputTaskReport == null) {
                outputTaskReport = exec.newTaskReport();
            }
            // TODO check output.finish() is called. wrap or abstract
            callback.outputCommitted(outputTaskReport);
        }
    }
}
Also used : TaskReport(org.embulk.config.TaskReport) TransactionalPageOutput(org.embulk.spi.TransactionalPageOutput) PageOutput(org.embulk.spi.PageOutput) TransactionalPageOutput(org.embulk.spi.TransactionalPageOutput) AbortTransactionResource(org.embulk.spi.AbortTransactionResource) CloseResource(org.embulk.spi.CloseResource)

Aggregations

TaskReport (org.embulk.config.TaskReport)1 AbortTransactionResource (org.embulk.spi.AbortTransactionResource)1 CloseResource (org.embulk.spi.CloseResource)1 PageOutput (org.embulk.spi.PageOutput)1 TransactionalPageOutput (org.embulk.spi.TransactionalPageOutput)1