我们在谷歌云数据流中运行我们的 Apache Beam 代码,我们需要将一些 JVM 参数传递给我们的程序。我们找到了与执行参数相关的链接,但没有与 JVM 参数相关的链接。如何将 JVM 参数传递给 Google Cloud 数据流?
我正在构建一个 Apache Beam 管道,以从 Kafka 读取作为无界源。
我能够使用直接运行器在本地运行它。
但是,在云上使用 Google Cloud Dataflow 运行器运行时,管道会因附加的异常堆栈跟踪而失败。
似乎最终是Conscrypt Java 库抛出了javax.net.ssl.SSLException: Unable to parse TLS packet header. 我不确定如何解决这个问题。
java.io.IOException: Failed to start reading from source: org.apache.beam.sdk.io.kafka.KafkaUnboundedSource@33b5ff70
com.google.cloud.dataflow.worker.WorkerCustomSources$UnboundedReaderIterator.start(WorkerCustomSources.java:783)
com.google.cloud.dataflow.worker.util.common.worker.ReadOperation$SynchronizedReaderIterator.start(ReadOperation.java:360)
com.google.cloud.dataflow.worker.util.common.worker.ReadOperation.runReadLoop(ReadOperation.java:193)
com.google.cloud.dataflow.worker.util.common.worker.ReadOperation.start(ReadOperation.java:158)
com.google.cloud.dataflow.worker.util.common.worker.MapTaskExecutor.execute(MapTaskExecutor.java:75)
com.google.cloud.dataflow.worker.StreamingDataflowWorker.process(StreamingDataflowWorker.java:1227)
com.google.cloud.dataflow.worker.StreamingDataflowWorker.access$1000(StreamingDataflowWorker.java:135)
com.google.cloud.dataflow.worker.StreamingDataflowWorker$6.run(StreamingDataflowWorker.java:966)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: java.util.concurrent.ExecutionException: org.apache.kafka.common.errors.SslAuthenticationException: SSL handshake failed
org.apache.beam.sdk.io.kafka.KafkaUnboundedReader.start(KafkaUnboundedReader.java:126)
com.google.cloud.dataflow.worker.WorkerCustomSources$UnboundedReaderIterator.start(WorkerCustomSources.java:778)
com.google.cloud.dataflow.worker.util.common.worker.ReadOperation$SynchronizedReaderIterator.start(ReadOperation.java:360)
com.google.cloud.dataflow.worker.util.common.worker.ReadOperation.runReadLoop(ReadOperation.java:193)
com.google.cloud.dataflow.worker.util.common.worker.ReadOperation.start(ReadOperation.java:158)
com.google.cloud.dataflow.worker.util.common.worker.MapTaskExecutor.execute(MapTaskExecutor.java:75)
com.google.cloud.dataflow.worker.StreamingDataflowWorker.process(StreamingDataflowWorker.java:1227)
com.google.cloud.dataflow.worker.StreamingDataflowWorker.access$1000(StreamingDataflowWorker.java:135)
com.google.cloud.dataflow.worker.StreamingDataflowWorker$6.run(StreamingDataflowWorker.java:966)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
java.lang.Thread.run(Thread.java:745)
Caused by: java.util.concurrent.ExecutionException: org.apache.kafka.common.errors.SslAuthenticationException: SSL handshake failed
java.util.concurrent.FutureTask.report(FutureTask.java:122)
java.util.concurrent.FutureTask.get(FutureTask.java:206)
org.apache.beam.sdk.io.kafka.KafkaUnboundedReader.start(KafkaUnboundedReader.java:112)
com.google.cloud.dataflow.worker.WorkerCustomSources$UnboundedReaderIterator.start(WorkerCustomSources.java:778)
com.google.cloud.dataflow.worker.util.common.worker.ReadOperation$SynchronizedReaderIterator.start(ReadOperation.java:360)
com.google.cloud.dataflow.worker.util.common.worker.ReadOperation.runReadLoop(ReadOperation.java:193)
com.google.cloud.dataflow.worker.util.common.worker.ReadOperation.start(ReadOperation.java:158)
com.google.cloud.dataflow.worker.util.common.worker.MapTaskExecutor.execute(MapTaskExecutor.java:75) …Run Code Online (Sandbox Code Playgroud) 我正在尝试执行 Google Dataflow 应用程序,但它抛出此异常
java.lang.IllegalArgumentException: No filesystem found for scheme gs
at org.apache.beam.sdk.io.FileSystems.getFileSystemInternal(FileSystems.java:459)
at org.apache.beam.sdk.io.FileSystems.matchNewResource(FileSystems.java:529)
at org.apache.beam.sdk.io.FileBasedSink.convertToFileResourceIfPossible(FileBasedSink.java:213)
at org.apache.beam.sdk.io.TextIO$TypedWrite.to(TextIO.java:700)
at org.apache.beam.sdk.io.TextIO$Write.to(TextIO.java:1028)
at br.com.sulamerica.mecsas.ExportacaoDadosPipeline.main(ExportacaoDadosPipeline.java:52)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:282)
at java.lang.Thread.run(Thread.java:748)
Run Code Online (Sandbox Code Playgroud)
这是我的流水线代码的一部分
Pipeline.create()
.apply(PubsubIO.readStrings().fromSubscription(subscription))
.apply(new KeyExportacaoDadosToEntityTransform())
.apply(new ListKeyEmpresaSelecionadasTransform())
.apply(ParDo.of(new DoFn<List<Entity>, String>() {
@ProcessElement
public void processElement(ProcessContext c){
c.output(
c.element().stream()
.map(e-> e.getString("dscRazaoSocial"))
.collect(Collectors.joining("\r\n"))
);
}
}))
.apply(TextIO.write().to("gs://<my bucket>"))
.getPipeline()
.run();
Run Code Online (Sandbox Code Playgroud)
这是用于执行我的管道的命令
mvn -Pdataflow-runner compile exec:java \
-Dexec.mainClass=br.com.xpto.foo.ExportacaoDadosPipeline \
-Dexec.args="--project=<projectID>\
--stagingLocation=gs://dataflow-xpto/exportacao/staging \
--output=gs://dataflow-xpto/exportacao/output \
--runner=DataflowRunner"
Run Code Online (Sandbox Code Playgroud) java exception google-cloud-storage google-cloud-platform google-cloud-dataflow
我正在使用如下所示的过程从 Beam 中的 Google Storage 读取文件:
data = pipeline | beam.Create(['gs://my/file.pkl']) | beam.ParDo(LoadFileDoFn)
Run Code Online (Sandbox Code Playgroud)
WhereLoadFileDoFn加载文件并从中创建对象的 Python 列表,ParDo然后以PCollection.
我知道我可能会实现一个自定义源来实现类似的功能,但是这个答案和 Beam自己的文档表明这种使用伪数据集读取的ParDo方法并不少见,并且自定义源可能有点矫枉过正。
它也有效 - 我得到了PCollection正确数量的元素,我可以随心所欲地处理它!然而..
结果PCollection在 Cloud Dataflow 上根本不会自动缩放。我首先必须通过以下方式对其进行转换:
shuffled_data = data | beam.Shuffle()
Run Code Online (Sandbox Code Playgroud)
我知道我也在上面链接的这个答案几乎解释了这个过程 - 但它没有提供任何关于为什么这是必要的见解。就我在 Beam 非常高的抽象级别所看到的而言,我PCollection在洗牌之前有 N 个元素,在洗牌PCollection之后有一个类似的元素。为什么一个可以缩放,而另一个不缩放?
在这种情况下,文档不是很有帮助(或者一般来说,但这是另一回事)。第一个PCollection有什么隐藏属性可以防止它被分发给另一个没有的多个工作人员?
目标是存储来自不同应用程序/作业的审计日志,并能够通过一些 id 聚合它们。为此,我们选择了 BigQuery,因此我们需要从日志中获取结构化信息到 BigQuery。
我们成功地使用了部署在 kubernetes 引擎中的应用程序,该应用程序将输出日志作为 json 字符串记录到 stdout 并对其进行解析,其结构可以在 stackdriver 中看到为jsonPayload. 我们从本教程中获取了它。
但是,当我在数据流作业中使用相同的日志附加程序时,它不会被视为结构化消息,而是被视为jsonPayload.message字段中的字符串。
我需要两件事的结构:
实现这一目标的最简单方法是什么?
logback google-cloud-dataflow apache-beam google-cloud-stackdriver
我有一个管道,它生成的数据流图(序列化 JSON 表示)超出了 API 的允许限制,因此无法像通常那样通过 apache beam 的数据流运行器启动。并且使用指示参数运行数据流运行--experiments=upload_graph器不起作用,并且失败并说没有指定步骤。
通过错误收到有关此尺寸问题的通知时,会提供以下信息:
the size of the serialized JSON representation of the pipeline exceeds the allowable limit for the API.
Use experiment 'upload_graph' (--experiments=upload_graph)
to direct the runner to upload the JSON to your
GCS staging bucket instead of embedding in the API request.
Run Code Online (Sandbox Code Playgroud)
现在使用此参数,确实会导致数据流运行器将附加dataflow_graph.pb文件上传到通常的 pipeline.pb 文件旁边的暂存位置。我证实它确实存在于 gcp 存储中。
但是,gcp 数据流中的作业在启动后立即失败,并出现以下错误:
Runnable workflow has no steps specified.
Run Code Online (Sandbox Code Playgroud)
我已经用各种管道尝试过这个标志,甚至是 apache 梁示例管道,并看到了相同的行为。
这可以通过使用字数示例来重现:
mvn archetype:generate \
-DarchetypeGroupId=org.apache.beam \
-DarchetypeArtifactId=beam-sdks-java-maven-archetypes-examples \
-DarchetypeVersion=2.11.0 \ …Run Code Online (Sandbox Code Playgroud) 我最近看到 GCP 中有一个名为 Data Fusion 的新工具,在查看它时,与 Dataflow 相比,它似乎是创建 ETL 管道的一种更简单的方法。那么我们可以假设它是 Dataflow 的替代品吗?
我正在尝试将包含 proto 定义 (_pb2) 的 Apache Beam 作业部署到 Google Dataflow,但是我收到了一个酸洗错误:
_pickle.PicklingError: Can't pickle <class 'test_pb2.Example'>: import of module 'test_pb2' failed [while running 'Convert to Proto']
Run Code Online (Sandbox Code Playgroud)
我的项目结构遵循本文档中建议的方法和juliaset 示例:
root/
main.py
setup.py
pipeline/
__init__.py
pipeline.py
test_pb2.py
input.txt
proto/
test.proto
Run Code Online (Sandbox Code Playgroud)
test_pb2 是使用 test.proto 中的 protoc 生成的,用于转换,将 dict 转换为 proto。
main.py 的内容:
import logging
from pipeline import pipeline
if __name__ == '__main__':
logging.getLogger().setLevel(logging.INFO)
pipeline.run()
Run Code Online (Sandbox Code Playgroud)
pipeline.py 的内容:
from __future__ import absolute_import
import apache_beam as beam
import argparse
from apache_beam.options.pipeline_options import PipelineOptions …Run Code Online (Sandbox Code Playgroud) python protocol-buffers python-3.x google-cloud-dataflow apache-beam
我有一个 Dataflow 工作没有取得进展 - 或者进展非常缓慢,我不知道为什么。我如何开始调查工作缓慢/卡住的原因?
我们在 Dataflow 作业部署期间遇到了问题。
我们正在使用 CustomCommands 在 worker 上安装私有 repo,但现在worker-startup我们的作业日志中出现错误:
Running command: ['pip', 'install', 'git+ssh://git@github.com/my_private_repo.git@v1.0.0']
Command output: b'Traceback (most recent call last):
File "/usr/local/bin/pip", line 6, in <module>
from pip._internal import main\nModuleNotFoundError: No module named \'pip\'\n'
Run Code Online (Sandbox Code Playgroud)
这段代码是有效的,但自从我们上次在周五部署该服务以来,它就没有了。
setup.py在工作人员启动期间运行的自定义命令。(来自官方仓库的代码示例在这里)pip install git+ssh://git@github.com/my_private_repo.git@v1.0.0(请参阅下面的命令)Running command: ['pip', 'install', 'git+ssh://git@github.com/my_private_repo.git@v1.0.0']
Command output: b'Traceback (most recent call last):
File "/usr/local/bin/pip", …Run Code Online (Sandbox Code Playgroud)apache-beam ×7
python ×3
apache-kafka ×1
dataflow ×1
exception ×1
java ×1
logback ×1
python-3.x ×1
ssl ×1