com.google.cloud.dataflow.sdk.runners.DataflowPipelineRunner Java Examples

The following examples show how to use com.google.cloud.dataflow.sdk.runners.DataflowPipelineRunner. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CoinbaseSource.java    From cloud-bigtable-examples with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
  CloudBigtableOptions options =
      PipelineOptionsFactory.fromArgs(args).withValidation().as(CloudBigtableOptions.class);

  CloudBigtableScanConfiguration config =
      new CloudBigtableScanConfiguration.Builder()
          .withProjectId(options.getBigtableProjectId())
          .withInstanceId(options.getBigtableInstanceId())
          .withTableId(options.getBigtableTableId())
          .build();

  options.setStreaming(true);
  options.setRunner(DataflowPipelineRunner.class);

  Pipeline p = Pipeline.create(options);
  CloudBigtableIO.initializeForWrite(p);

  p.apply(Read.from(new CoinbaseSource()))
      .apply(ParDo.named("DeserializeCoinbase").of(new DeserializeCoinbase()))
      .apply(ParDo.of(new HBaseBigtableWriter()))
      .apply(CloudBigtableIO.writeToTable(config));

  p.run();
}
 
Example #2
Source File: DataflowFactory.java    From dockerflow with Apache License 2.0 5 votes vote down vote up
private static Class<? extends PipelineRunner<?>> runner(String name) {
  Class<? extends PipelineRunner<?>> c = DirectPipelineRunner.class; // default

  if (DEFAULT_RUNNER.equals(name) || name == null) {
    c = DataflowPipelineRunner.class;
  } else if (BLOCKING_RUNNER.equals(name)) {
    c = BlockingDataflowPipelineRunner.class;
  } else if (DIRECT_RUNNER.equals(name)) {
    c = DirectPipelineRunner.class;
  }
  return c;
}
 
Example #3
Source File: FlinkPipelineRunner.java    From flink-dataflow with Apache License 2.0 5 votes vote down vote up
/**
 * Construct a runner from the provided options.
 *
 * @param options Properties which configure the runner.
 * @return The newly created runner.
 */
public static FlinkPipelineRunner fromOptions(PipelineOptions options) {
	FlinkPipelineOptions flinkOptions =
			PipelineOptionsValidator.validate(FlinkPipelineOptions.class, options);
	ArrayList<String> missing = new ArrayList<>();

	if (flinkOptions.getAppName() == null) {
		missing.add("appName");
	}
	if (missing.size() > 0) {
		throw new IllegalArgumentException(
				"Missing required values: " + Joiner.on(',').join(missing));
	}

	if (flinkOptions.getFilesToStage() == null) {
		flinkOptions.setFilesToStage(detectClassPathResourcesToStage(
				DataflowPipelineRunner.class.getClassLoader()));
		LOG.info("PipelineOptions.filesToStage was not specified. "
						+ "Defaulting to files from the classpath: will stage {} files. "
						+ "Enable logging at DEBUG level to see which files will be staged.",
				flinkOptions.getFilesToStage().size());
		LOG.debug("Classpath elements: {}", flinkOptions.getFilesToStage());
	}

	// Set Flink Master to [auto] if no option was specified.
	if (flinkOptions.getFlinkMaster() == null) {
		flinkOptions.setFlinkMaster("[auto]");
	}

	return new FlinkPipelineRunner(flinkOptions);
}