Search in sources :

Example 1 with DynamicSparkCompute

use of co.cask.cdap.etl.spark.streaming.function.DynamicSparkCompute in project cdap by caskdata.

the class DStreamCollection method compute.

@Override
public <U> SparkCollection<U> compute(final StageInfo stageInfo, SparkCompute<T, U> compute) throws Exception {
    final SparkCompute<T, U> wrappedCompute = new DynamicSparkCompute<>(new DynamicDriverContext(stageInfo, sec), compute);
    Transactionals.execute(sec, new TxRunnable() {

        @Override
        public void run(DatasetContext datasetContext) throws Exception {
            SparkExecutionPluginContext sparkPluginContext = new BasicSparkExecutionPluginContext(sec, JavaSparkContext.fromSparkContext(stream.context().sparkContext()), datasetContext, stageInfo);
            wrappedCompute.initialize(sparkPluginContext);
        }
    }, Exception.class);
    return wrap(stream.transform(new ComputeTransformFunction<>(sec, stageInfo, wrappedCompute)));
}
Also used : DynamicSparkCompute(co.cask.cdap.etl.spark.streaming.function.DynamicSparkCompute) BasicSparkExecutionPluginContext(co.cask.cdap.etl.spark.batch.BasicSparkExecutionPluginContext) SparkExecutionPluginContext(co.cask.cdap.etl.api.batch.SparkExecutionPluginContext) BasicSparkExecutionPluginContext(co.cask.cdap.etl.spark.batch.BasicSparkExecutionPluginContext) ComputeTransformFunction(co.cask.cdap.etl.spark.streaming.function.ComputeTransformFunction) TxRunnable(co.cask.cdap.api.TxRunnable) DatasetContext(co.cask.cdap.api.data.DatasetContext) TransactionFailureException(org.apache.tephra.TransactionFailureException)

Aggregations

TxRunnable (co.cask.cdap.api.TxRunnable)1 DatasetContext (co.cask.cdap.api.data.DatasetContext)1 SparkExecutionPluginContext (co.cask.cdap.etl.api.batch.SparkExecutionPluginContext)1 BasicSparkExecutionPluginContext (co.cask.cdap.etl.spark.batch.BasicSparkExecutionPluginContext)1 ComputeTransformFunction (co.cask.cdap.etl.spark.streaming.function.ComputeTransformFunction)1 DynamicSparkCompute (co.cask.cdap.etl.spark.streaming.function.DynamicSparkCompute)1 TransactionFailureException (org.apache.tephra.TransactionFailureException)1