public class DataflowExampleUtils extends Object
It is used to run Dataflow examples, such as TrafficMaxLaneFlow and TrafficRoutes.
| Constructor and Description |
|---|
DataflowExampleUtils(DataflowPipelineOptions options) |
| Modifier and Type | Method and Description |
|---|---|
void |
runInjectorPipeline(Pipeline injectorPipeline)
Runs the provided injector pipeline for the streaming pipeline.
|
void |
runInjectorPipeline(String inputFile,
String topic)
Runs the batch injector for the streaming pipeline.
|
void |
setup()
Sets up external resources that are required by the example,
such as Pub/Sub topics and BigQuery tables.
|
void |
setupBigQueryTable()
Sets up the Google Cloud Pub/Sub topic.
|
void |
setupPubsubTopic()
Sets up the BigQuery table with the given schema.
|
void |
waitToFinish(PipelineResult result)
If DataflowPipelineRunner or BlockingDataflowPipelineRunner is used,
waits for the pipeline to finish and cancels it (and the injector) before the program exists.
|
public DataflowExampleUtils(DataflowPipelineOptions options)
public void setup()
throws IOException
IOException - if there is a problem setting up the resourcespublic void setupPubsubTopic()
throws IOException
If the table already exists, the schema has to match the given one. Otherwise, the example will throw a RuntimeException. If the table doesn't exist, a new table with the given schema will be created.
IOException - if there is a problem setting up the BigQuery tablepublic void setupBigQueryTable()
throws IOException
If the topic doesn't exist, a new topic with the given name will be created.
IOException - if there is a problem setting up the Pub/Sub topicpublic void runInjectorPipeline(String inputFile, String topic)
The injector pipeline will read from the given text file, and inject data into the Google Cloud Pub/Sub topic.
public void runInjectorPipeline(Pipeline injectorPipeline)
public void waitToFinish(PipelineResult result)