Java Code Examples for com.google.cloud.dataflow.sdk.options.PipelineOptionsFactory#as()

The following examples show how to use com.google.cloud.dataflow.sdk.options.PipelineOptionsFactory#as() . 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: DataflowFactory.java    From dockerflow with Apache License 2.0 6 votes vote down vote up
/**
 * Create Dataflow Pipeline options from the standard command-line options, "--project=",
 * "--runner=" and "--stagingLocation="
 *
 * @param args
 * @return
 * @throws IOException
 */
public static DataflowPipelineOptions pipelineOptions(String[] args) throws IOException {
  LOG.info("Set up Dataflow options");
  DataflowPipelineOptions o = PipelineOptionsFactory.as(DataflowPipelineOptions.class);

  Map<String, String> m = StringUtils.parseArgs(args);
  o.setProject(m.get(PROJECT));
  if (m.containsKey(STAGING)) {
    o.setStagingLocation(m.get(STAGING));
  } else if (m.containsKey(STAGING_LOCATION)) {
    o.setStagingLocation(m.get(STAGING_LOCATION));
  } else if (m.containsKey(WORKSPACE)) {
    o.setStagingLocation(m.get(WORKSPACE) + "/staging");
  }
  o.setRunner(runner(m.get(RUNNER)));
  o.setMaxNumWorkers(m.get(MAX_WORKERS) == null ? 1 : Integer.parseInt(m.get(MAX_WORKERS)));
  if (m.containsKey(MACHINE_TYPE)) {
    o.setWorkerMachineType(m.get(MACHINE_TYPE));
  } else {
    o.setWorkerMachineType(DEFAULT_MACHINE_TYPE);
  }
  return o;
}
 
Example 2
Source File: LiveStateCheckerApp.java    From policyscanner with Apache License 2.0 5 votes vote down vote up
private PipelineOptions getCloudExecutionOptions(String stagingLocation) {
  DataflowPipelineOptions options = PipelineOptionsFactory.as(DataflowPipelineOptions.class);
  options.setProject(Constants.PROJECT_ID);
  options.setStagingLocation(stagingLocation);
  options.setRunner(BlockingDataflowPipelineRunner.class);
  return options;
}
 
Example 3
Source File: UserManagedKeysApp.java    From policyscanner with Apache License 2.0 5 votes vote down vote up
private PipelineOptions getCloudExecutionOptions(String stagingLocation) {
  DataflowPipelineOptions options = PipelineOptionsFactory.as(DataflowPipelineOptions.class);
  options.setProject(SystemProperty.applicationId.get());
  options.setStagingLocation(stagingLocation);
  options.setRunner(BlockingDataflowPipelineRunner.class);
  return options;
}
 
Example 4
Source File: LiveStateCheckerRunner.java    From policyscanner with Apache License 2.0 5 votes vote down vote up
private static PipelineOptions getCloudExecutionOptions(String stagingLocation) {
  DataflowPipelineOptions options = PipelineOptionsFactory.as(DataflowPipelineOptions.class);
  options.setProject(SystemProperty.applicationId.get());
  options.setStagingLocation(stagingLocation);
  options.setRunner(BlockingDataflowPipelineRunner.class);
  return options;
}
 
Example 5
Source File: DesiredStateEnforcerApp.java    From policyscanner with Apache License 2.0 5 votes vote down vote up
private PipelineOptions getCloudExecutionOptions(String stagingLocation) {
  DataflowPipelineOptions options = PipelineOptionsFactory.as(DataflowPipelineOptions.class);
  options.setProject(SystemProperty.applicationId.get());
  options.setStagingLocation(stagingLocation);
  options.setRunner(BlockingDataflowPipelineRunner.class);
  return options;
}
 
Example 6
Source File: FlinkPipelineRunner.java    From flink-dataflow with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a runner with default properties for testing.
 *
 * @return The newly created runner.
 */
public static FlinkPipelineRunner createForTest(boolean streaming) {
	FlinkPipelineOptions options = PipelineOptionsFactory.as(FlinkPipelineOptions.class);
	// we use [auto] for testing since this will make it pick up the Testing
	// ExecutionEnvironment
	options.setFlinkMaster("[auto]");
	options.setStreaming(streaming);
	return new FlinkPipelineRunner(options);
}
 
Example 7
Source File: FXTimeSeriesPipelineSRGTests.java    From data-timeseries-java with Apache License 2.0 4 votes vote down vote up
public static Pipeline setup() {

    FXTimeSeriesPipelineOptions options =
        PipelineOptionsFactory.as(FXTimeSeriesPipelineOptions.class);


    // Setup the windowing variables for the test run
    options.setCandleResolution(BAR_SIZE_SEC);
    options.setCorrelationWindowSize(WINDOW_SIZE_SECS);
    options.setCorrelationWindowPeriod(SLIDING_WINDOW_PERIOD_SECS);

    // Set Runner to use
    options.setRunner(InProcessPipelineRunner.class);

    Pipeline pipeline = Pipeline.create(options);

    // Register all of the coders used within the Pipeline
    TimeSeriesCoders.registerCoders(pipeline);

    // Create WorkPacket SideInput

    return pipeline;
  }