Package org.apache.beam.examples.common
Class ExampleUtils
- java.lang.Object
-
- org.apache.beam.examples.common.ExampleUtils
-
public class ExampleUtils extends java.lang.ObjectThe utility class that sets up and tears down external resources, and cancels the streaming pipelines once the program terminates.It is used to run Beam examples.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringTOKENIZER_PATTERN\p{L} denotes the category of Unicode letters, so this pattern will match on everything that is not a letter.
-
Constructor Summary
Constructors Constructor Description ExampleUtils(org.apache.beam.sdk.options.PipelineOptions options)Do resources and runner options setup.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidsetup()Sets up external resources that are required by the example, such as Pub/Sub topics and BigQuery tables.voidsetupBigQueryTable()Sets up the BigQuery table with the given schema.voidsetupPubsub()Sets up the Google Cloud Pub/Sub topic.voidwaitToFinish(org.apache.beam.sdk.PipelineResult result)Waits for the pipeline to finish and cancels it before the program exists.
-
-
-
Field Detail
-
TOKENIZER_PATTERN
public static final java.lang.String TOKENIZER_PATTERN
\p{L} denotes the category of Unicode letters, so this pattern will match on everything that is not a letter.It is used for tokenizing strings in the wordcount examples.
- See Also:
- Constant Field Values
-
-
Method Detail
-
setup
public void setup() throws java.io.IOExceptionSets up external resources that are required by the example, such as Pub/Sub topics and BigQuery tables.- Throws:
java.io.IOException- if there is a problem setting up the resources
-
setupPubsub
public void setupPubsub() throws java.io.IOExceptionSets up the Google Cloud Pub/Sub topic.If the topic doesn't exist, a new topic with the given name will be created.
- Throws:
java.io.IOException- if there is a problem setting up the Pub/Sub topic
-
setupBigQueryTable
public void setupBigQueryTable() throws java.io.IOExceptionSets up the BigQuery table with the given schema.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.
- Throws:
java.io.IOException- if there is a problem setting up the BigQuery table
-
waitToFinish
public void waitToFinish(org.apache.beam.sdk.PipelineResult result)
Waits for the pipeline to finish and cancels it before the program exists.
-
-