public class DataflowExampleUtils
extends java.lang.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(java.lang.String inputFile,
java.lang.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)
Waits for the pipeline to finish, and cancels it (and the injector) before the program exists.
|
public DataflowExampleUtils(DataflowPipelineOptions options)
public void setup()
throws java.io.IOException
java.io.IOException - if there is a problem setting up the resourcespublic void setupPubsubTopic()
throws java.io.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.
java.io.IOException - if there is a problem setting up the BigQuery tablepublic void setupBigQueryTable()
throws java.io.IOException
If the topic doesn't exist, a new topic with the given name will be created.
java.io.IOException - if there is a problem setting up the Pub/Sub topicpublic void runInjectorPipeline(java.lang.String inputFile,
java.lang.String topic)
The injector pipeline will read from the given text file, and inject data into the Google Cloud Pub/Sub topic.
public void waitToFinish(PipelineResult result)