Search in sources :

Example 1 with PipelineExecutionException

use of org.apache.beam.sdk.Pipeline.PipelineExecutionException in project beam by apache.

the class DirectRunner method run.

@Override
public DirectPipelineResult run(Pipeline pipeline) {
    pipeline.replaceAll(defaultTransformOverrides());
    MetricsEnvironment.setMetricsSupported(true);
    DirectGraphVisitor graphVisitor = new DirectGraphVisitor();
    pipeline.traverseTopologically(graphVisitor);
    @SuppressWarnings("rawtypes") KeyedPValueTrackingVisitor keyedPValueVisitor = KeyedPValueTrackingVisitor.create();
    pipeline.traverseTopologically(keyedPValueVisitor);
    DisplayDataValidator.validatePipeline(pipeline);
    DisplayDataValidator.validateOptions(getPipelineOptions());
    DirectGraph graph = graphVisitor.getGraph();
    EvaluationContext context = EvaluationContext.create(getPipelineOptions(), clockSupplier.get(), Enforcement.bundleFactoryFor(enabledEnforcements, graph), graph, keyedPValueVisitor.getKeyedPValues());
    RootProviderRegistry rootInputProvider = RootProviderRegistry.defaultRegistry(context);
    TransformEvaluatorRegistry registry = TransformEvaluatorRegistry.defaultRegistry(context);
    PipelineExecutor executor = ExecutorServiceParallelExecutor.create(options.getTargetParallelism(), graph, rootInputProvider, registry, Enforcement.defaultModelEnforcements(enabledEnforcements), context);
    executor.start(graph.getRootTransforms());
    DirectPipelineResult result = new DirectPipelineResult(executor, context);
    if (options.isBlockOnRun()) {
        try {
            result.waitUntilFinish();
        } catch (UserCodeException userException) {
            throw new PipelineExecutionException(userException.getCause());
        } catch (Throwable t) {
            if (t instanceof RuntimeException) {
                throw (RuntimeException) t;
            }
            throw new RuntimeException(t);
        }
    }
    return result;
}
Also used : DirectPipelineResult(org.apache.beam.runners.direct.DirectRunner.DirectPipelineResult) UserCodeException(org.apache.beam.sdk.util.UserCodeException) PipelineExecutionException(org.apache.beam.sdk.Pipeline.PipelineExecutionException) PTransformOverride(org.apache.beam.sdk.runners.PTransformOverride)

Aggregations

DirectPipelineResult (org.apache.beam.runners.direct.DirectRunner.DirectPipelineResult)1 PipelineExecutionException (org.apache.beam.sdk.Pipeline.PipelineExecutionException)1 PTransformOverride (org.apache.beam.sdk.runners.PTransformOverride)1 UserCodeException (org.apache.beam.sdk.util.UserCodeException)1