【问题标题】:Unable to read gs:// dirs from local Dataflow pipeline无法从本地 Dataflow 管道读取 gs:// 目录
【发布时间】:2021-02-08 18:10:54
【问题描述】:

我刚刚在 Java 中登陆了我的第一个管道,并弹出以下错误。

Exception in thread "main" java.lang.IllegalArgumentException: No filesystem found for scheme gs

有以下代码。

        pipeline.apply("ReadLines", TextIO.read().from(options.getInputFile()))
            .apply(MapElements.via(new SampleFn()))
            .apply("WriteLines", TextIO
                .write()
                .to(options.getOutputDir())
                .withSuffix(".txt"));

https://github.com/apache/beam/tree/master/examples/java 中的示例开始了一个临时项目,但似乎我可能缺少一些与 Maven 的依赖关系。

以下 .pom 提取是与 Beam 和 GCP 相关的依赖项。我错过了什么?

    <dependency>
      <groupId>org.apache.beam</groupId>
      <artifactId>beam-sdks-java-core</artifactId>
      <version>2.19.0</version>
    </dependency>
    <dependency>
      <groupId>org.apache.beam</groupId>
      <artifactId>beam-sdks-java-io-google-cloud-platform</artifactId>
      <version>2.19.0</version>
      <exclusions>
        <exclusion>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
        </exclusion>
        <exclusion>
          <groupId>com.google.cloud.bigtable</groupId>
          <artifactId>bigtable-client-core</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <version>${guava.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.beam</groupId>
      <artifactId>beam-vendor-guava-20_0</artifactId>
      <version>${beam-vendor-guava.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.beam</groupId>
      <artifactId>beam-sdks-java-extensions-google-cloud-platform-core</artifactId>
      <version>2.19.0</version>
    </dependency>
    <dependency>
      <groupId>org.apache.beam</groupId>
      <artifactId>beam-sdks-java-extensions-protobuf</artifactId>
      <version>2.19.0</version>
    </dependency>
    <dependency>
      <groupId>org.apache.beam</groupId>
      <artifactId>beam-runners-google-cloud-dataflow-java</artifactId>
      <version>2.19.0</version>
    </dependency>

编辑:阴影已经在执行。

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>${maven-shade-plugin.version}</version>
        <executions>
          <execution>
            <id>sample-pipeline-build</id>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
            <configuration>
              <finalName>sample-pipeline-bundled</finalName>
              <filters>
                <filter>
                  <artifact>*:*</artifact>
                  <excludes>
                    <exclude>META-INF/LICENSE</exclude>
                    <exclude>META-INF/*.SF</exclude>
                    <exclude>META-INF/*.DSA</exclude>
                    <exclude>META-INF/*.RSA</exclude>
                  </excludes>
                </filter>
              </filters>
              <transformers>
                <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                  <mainClass>my.project.SamplePipeline</mainClass>
                </transformer>
              </transformers>
            </configuration>
          </execution>
        </executions>
      </plugin>

编辑 2:捆绑 jar 中 META-INF/services/org.apache.beam.sdk.io.FileSystemRegistrar 的内容。

org.apache.beam.sdk.io.LocalFileSystemRegistrar
org.apache.beam.sdk.extensions.gcp.storage.GcsFileSystemRegistrar

【问题讨论】:

    标签: google-cloud-dataflow apache-beam


    【解决方案1】:

    这通常发生在构建包含所有依赖项的单个 jar 而没有正确着色的情况下。请参阅"java.lang.IllegalArgumentException: No filesystem found for scheme gs" when running dataflow in google cloud platformGoogle Dataflow "No filesystem found for scheme gs" 了解如何正确配置您的 pom 文件。

    【讨论】:

    • 感谢您的回复。奇怪的是,我已经以第一个问题所暗示的方式隐藏了依赖关系。我将编辑我的问题,向您展示我是如何做到的。它不应该直接在本地工作吗?比如,从 IDE 运行它?目前不尝试执行jar,仅在本地调试。
    • 你能分享你捆绑的jar中META-INF/services/org.apache.beam.sdk.io.FileSystemRegistrar的内容吗?
    • 编辑内容@KennKnowles
    • 又一次更新(@KennKnowles 和@danielm)。它仅在尝试写入时发生。我能够读取文件内容。可能是项目本身的角色有问题,只是在抱怨 gs FS?
    • 很奇怪。您的服务加载器配置看起来不错。如果您可以读取似乎可以正常工作的文件。我想知道堆栈跟踪中是否还有另一个错误?
    猜你喜欢
    • 1970-01-01
    • 2020-05-28
    • 1970-01-01
    • 1970-01-01
    • 2018-06-05
    • 2014-12-13
    • 2019-04-08
    • 1970-01-01
    • 2015-07-03
    相关资源
    最近更新 更多