代码之家  ›  专栏  ›  技术社区  ›  Gaurav Thakur

在数据流上部署Apache Beam

  •  0
  • Gaurav Thakur  · 技术社区  · 7 年前

    您好,我已经创建了一个apache beam管道,对其进行了测试,并从eclipse内部运行它,包括本地运行和使用dataflow runner运行。我可以在eclipse控制台中看到管道正在运行,我也可以看到详细信息,即控制台上的日志。

    现在,我如何将此管道部署到GCP,以便无论我的机器的状态如何,它都能继续工作。例如,如果我使用mvn compile-exec:java运行它,控制台会显示它正在运行,但我无法使用数据流UI找到作业。

    此外,如果在本地终止进程,会发生什么情况?GCP基础架构上的作业也会停止吗?在GCP基础设施上,我如何知道作业是独立于我的机器状态触发的?

    maven compile exec:java with arguments输出如下:,

     SLF4J: Class path contains multiple SLF4J bindings.
        SLF4J: Found binding in 
        [jar:file:/C:/Users/ThakurG/.m2/repository/org/slf4j/slf4j-
        jdk14/1.7.14/slf4j-jdk14-1.7.14.jar!/org/slf4j/impl/StaticLoggerBinder.class]
        SLF4J: Found binding in [jar:file:/C:/Users/ThakurG/.m2/repository/org/slf4j/slf4j-nop/1.7.25/slf4j-nop-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
        SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
        SLF4J: Actual binding is of type [org.slf4j.impl.JDK14LoggerFactory]
        Jan 08, 2018 5:33:22 PM com.trial.apps.gcp.df.ReceiveAndPersistToBQ main
        INFO: starting the process...
        Jan 08, 2018 5:33:25 PM com.trial.apps.gcp.df.ReceiveAndPersistToBQ 
       createStream
        INFO: pipeline created::Pipeline#73387971
        Jan 08, 2018 5:33:27 PM com.trial.apps.gcp.df.ReceiveAndPersistToBQ main
        INFO: pie crated::Pipeline#73387971
        Jan 08, 2018 5:54:57 PM com.trial.apps.gcp.df.ReceiveAndPersistToBQ$1 apply
        INFO: Message received::1884408,16/09/2017,A,2007156,CLARK RUBBER FRANCHISING PTY LTD,A ,5075,6,Y,296,40467910,-34.868095,138.683535,66 SILKES RD,,,PARADISE,5075,0,7.4,5.6,18/09/2017 2:09,0.22
        Jan 08, 2018 5:54:57 PM com.trial.apps.gcp.df.ReceiveAndPersistToBQ$1 apply
        INFO: Payload from msg::1884408,16/09/2017,A,2007156,CLARK RUBBER FRANCHISING PTY LTD,A ,5075,6,Y,296,40467910,-34.868095,138.683535,66 SILKES RD,,,PARADISE,5075,0,7.4,5.6,18/09/2017 2:09,0.22
        Jan 08, 2018 5:54:57 PM com.trial.apps.gcp.df.ReceiveAndPersistToBQ$1 apply
    

    这是我在cmd提示符下使用的maven命令,

    `mvn compile exec:java -Dexec.mainClass=com.trial.apps.gcp.df.ReceiveAndPersistToBQ -Dexec.args="--project=analyticspoc-XXX --stagingLocation=gs://analytics_poc_staging --runner=DataflowRunner --streaming=true"`
    

    这是我用来创建管道并在管道上设置选项的代码。

    PipelineOptions options = PipelineOptionsFactory.create();
    
    DataflowPipelineOptions dfOptions = options.as(DataflowPipelineOptions.class);
    dfOptions.setRunner(DataflowRunner.class);
    dfOptions.setJobName("gcpgteclipse");
    dfOptions.setStreaming(true);
    
    // Then create the pipeline.
    Pipeline pipeL = Pipeline.create(dfOptions);
    
    2 回复  |  直到 7 年前
        1
  •  3
  •   jkff    7 年前

    您能否澄清“控制台显示它正在运行”和“无法使用数据流UI找到作业”的确切含义?

    如果程序输出打印消息:

    To access the Dataflow monitoring console, please navigate to https://console.developers.google.com/project/.../dataflow/job/....
    

    然后,您的作业正在数据流服务上运行。一旦运行,终止主程序将不会停止作业-主程序所做的只是定期轮询数据流服务以了解作业的状态和新的日志消息。在打印的链接之后,您将进入数据流UI。

    如果未打印此消息,则可能是您的程序在实际启动数据流作业之前被卡住了。如果包含程序的输出,这将有助于调试。

        2
  •  1
  •   Andrew Nguonly    7 年前

    要部署要由数据流执行的管道,请指定 runner project 通过命令行或通过 DataflowPipelineOptions 跑步者 必须设置为 DataflowRunner (Apache Beam 2.x.x)和 项目 设置为您的GCP项目ID。请参阅 Specifying Execution Parameters . 如果在Dataflow作业UI列表中没有看到该作业,那么它肯定没有在Dataflow中运行。

    如果终止将作业部署到数据流的进程,则作业将继续在数据流中运行。它不会停止。

    这很琐碎,但要绝对清楚,您必须调用 run() Pipeline 对象,以便执行它(并因此部署到数据流)。的返回值 运行() 是一个 PipelineResult 对象,其中包含用于确定作业状态的各种方法。例如,您可以调用 pipeline.run().waitUntilFinish(); 强制程序阻止执行,直到作业完成。如果您的程序被阻止,则您知道作业已触发。请参见 管道结果 第节 Apache Beam 所有可用方法的Java SDK文档。