【问题标题】:Unable to run GCP DataflowTemplates locally无法在本地运行 GCP DataflowTemplates
【发布时间】:2019-06-15 17:43:42
【问题描述】:

我正在尝试使用 https://github.com/GoogleCloudPlatform/DataflowTemplates 和直接运行器在本地运行 PubSubToBigQuery.java。但是我收到错误消息

Exception in thread "main" java.lang.IllegalArgumentException: Class interface com.google.cloud.teleport.templates.PubSubToBigQuery$Options missing a property named 'gcs-location'.
    at org.apache.beam.sdk.options.PipelineOptionsFactory.parseObjects(PipelineOptionsFactory.java:1518)
    at org.apache.beam.sdk.options.PipelineOptionsFactory.access$400(PipelineOptionsFactory.java:111)
    at org.apache.beam.sdk.options.PipelineOptionsFactory$Builder.as(PipelineOptionsFactory.java:294)
    at com.google.cloud.teleport.templates.PubSubToBigQuery.main(PubSubToBigQuery.java:165)

但我已经在运行过程中通过了--gcs-location=gs://xxx-templates/dataflow/pipelines/pubsub-to-bigquery

正是在这一行引发了错误。 https://github.com/GoogleCloudPlatform/DataflowTemplates/blob/master/src/main/java/com/google/cloud/teleport/templates/PubSubToBigQuery.java#L176

https://beam.apache.org/documentation/runners/direct/

【问题讨论】:

    标签: java google-bigquery apache-beam google-cloud-pubsub dataflow


    【解决方案1】:

    您将传递给 Java 应用程序的参数与传递给通过 CLI 运行模板化管道的参数混淆了。

    --gcs-location 是您在 CLI 上传递给 gcloud dataflow jobs run 的内容。当您运行 Java 应用程序时,Dataflow 在 GCS(模板)上暂存您的管道,但不会立即运行该管道。 --gcs-location 告诉 gcloud dataflow.. 要运行的模板的位置。

    您无法在本地执行模板化管道。您只需通过 Java 应用程序在本地运行模板的暂存。

    https://cloud.google.com/dataflow/docs/guides/templates/executing-templates

     * # Set the runner
     * RUNNER=DataflowRunner
     *
     * # Build the template <--NOTE THIS
     * mvn compile exec:java \
     * -Dexec.mainClass=com.google.cloud.teleport.templates.PubSubToBigQuery \
     * -Dexec.cleanupDaemonThreads=false \
     * -Dexec.args=" \
     * --project=${PROJECT_ID} \
     * --stagingLocation=${PIPELINE_FOLDER}/staging \
     * --tempLocation=${PIPELINE_FOLDER}/temp \
     * --templateLocation=${PIPELINE_FOLDER}/template \
     * --runner=${RUNNER}"
     *
     * # Execute the template <--NOTE THIS
     * JOB_NAME=pubsub-to-bigquery-$USER-`date +"%Y%m%d-%H%M%S%z"`
     *
     * gcloud dataflow jobs run ${JOB_NAME} \
     * --gcs-location=${PIPELINE_FOLDER}/template \
     * --zone=us-east1-d \
     * --parameters \
     * "inputTopic=projects/data-analytics-pocs/topics/teleport-pubsub-to-bigquery,\
     * outputTableSpec=data-analytics-pocs:demo.pubsub_to_bigquery,\
     * outputDeadletterTable=data-analytics-pocs:demo.pubsub_to_bigquery_deadletter"
     * </pre>
     */
    

    【讨论】:

    • 感谢您的回复。我如何能够在本地运行模板的暂存?我无法使用 DirectRunner 构建模板。
    • 您只需像在本地运行任何其他应用程序一样运行 Java 应用程序,它就会在 GCS 上暂存模板。
    • 据我所知,模板是Dataflow独有的概念,因此Dataflow是唯一可以生成模板的运行器,并且模板始终必须暂存到GCS。没有将模板暂存到本地文件系统的概念,Dataflow 将无法访问本地暂存的模板。
    猜你喜欢
    • 2019-01-23
    • 1970-01-01
    • 2021-07-17
    • 1970-01-01
    • 2018-08-20
    • 1970-01-01
    • 1970-01-01
    • 2020-07-24
    • 1970-01-01
    相关资源
    最近更新 更多