All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.beam.runners.twister2.Twister2LegacyRunner Maven / Gradle / Ivy

Go to download

Twister2 Big Data Hosting Environment: A composable framework for high-performance data analytics

There is a newer version: 0.8.0
Show newest version
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.beam.runners.twister2;

import java.util.logging.Logger;

import org.apache.beam.sdk.Pipeline;
import org.apache.beam.sdk.PipelineResult;
import org.apache.beam.sdk.PipelineRunner;
import org.apache.beam.sdk.options.PipelineOptions;
import org.apache.beam.sdk.options.PipelineOptionsValidator;

/**
 * A {@link PipelineRunner} that executes the operations in the pipeline by first translating them
 * to a Twister2 Plan and then executing them either locally or on a Twister2 cluster, depending on
 * the configuration.
 */
public class Twister2LegacyRunner extends PipelineRunner {

  private static final Logger LOG = Logger.getLogger(Twister2LegacyRunner.class.getName());

  /**
   * Provided options.
   */
  private final Twister2PipelineOptions options;

  public Twister2LegacyRunner(Twister2PipelineOptions options) {
    this.options = options;
  }

  public static Twister2LegacyRunner fromOptions(PipelineOptions options) {
    Twister2PipelineOptions pipelineOptions =
        PipelineOptionsValidator.validate(Twister2PipelineOptions.class, options);
    return new Twister2LegacyRunner(pipelineOptions);
  }

  @Override
  public PipelineResult run(Pipeline pipeline) {
    // create a worker and pass in the pipeline and then do the translation
    Twister2PiplineExecutionEnvironment env = new Twister2PiplineExecutionEnvironment(options);
    LOG.info("Translating pipeline to Twister2 program.");
    env.translate(pipeline);
    env.execute();
    return null;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy