【问题标题】:Why does Apache Beam 2.2 fail on writing to GCS?为什么 Apache Beam 2.2 无法写入 GCS?
【发布时间】:2018-03-20 01:01:00
【问题描述】:

我正在使用同事最近迁移到版本 2.2.0 的数据流管道。管道中引发错误的相关步骤如下:

domainOutputBucket = "gs://output/partner/20180311/raw/DomainBatch20180311_"

output.get(domainsOut)
.setCoder(StringUtf8Coder.of())
.apply("WriteDomain" + description, TextIO.write()
.to(domainOutputBucket).withSuffix(".csv")                        // <-- line 109
.withWritableByteChannelFactory(FileBasedSink.CompressionType.GZIP)
.withNumShards(numChunksCustom));

然而,当这段代码被编译时,会出现以下错误和堆栈跟踪:

Exception in thread "main" java.nio.file.InvalidPathException: Illegal char <:> at index 2: gs://output/partner/20180311/raw/DomainBatch20180311_
 at sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182)
 at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153)
 at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
 at sun.nio.fs.WindowsPath.parse(WindowsPath.java:94)
 at sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:255)
 at java.nio.file.Paths.get(Paths.java:84)
 at org.apache.beam.sdk.io.LocalFileSystem.matchNewResource(LocalFileSystem.java:196)
 at org.apache.beam.sdk.io.LocalFileSystem.matchNewResource(LocalFileSystem.java:78)
 at org.apache.beam.sdk.io.FileSystems.matchNewResource(FileSystems.java:544)
 at org.apache.beam.sdk.io.FileBasedSink.convertToFileResourceIfPossible(FileBasedSink.java:213)
 at org.apache.beam.sdk.io.TextIO$TypedWrite.to(TextIO.java:679)
 at org.apache.beam.sdk.io.TextIO$Write.to(TextIO.java:997)
 at com.package.output.Partner.partnerPipeline(Partner.java:109)
 at com.package.output.Output.Export(Output.java:285)
 at com.package.output.Output.main(Output.java:254)

根据这些信息,是否有人看到我上面包含的代码可能存在什么问题?如果我在其他人之前找到答案,我一定会为未来的开发者更新这个问题。

【问题讨论】:

  • @LaraSchmidt 我对在哪里包含“gcpTempLocation”感到有些困惑。这是一个 GCS 函数,还是我应该作为键值对中的键传递给管道的变量?
  • 对不起,我指的是之后的 cmets。您需要确保存储类在您的类路径上。否则系统不知道如何解释 GCP 文件名并尝试将其作为本地文件系统查找。
  • @LaraSchmidt 您可以将您的回复添加为答案而不是评论吗?

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


【解决方案1】:

查看Google Cloud Dataflow: Specifying TempLocation via Command Line Argument 上的评论(如第 6 号之后)。

您需要确保存储类在您的类路径上。否则系统不知道如何解释 GCP 文件名并尝试将其作为本地文件系统查找。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-31
    • 2019-03-26
    • 1970-01-01
    • 1970-01-01
    • 2019-02-27
    相关资源
    最近更新 更多