gpt4 book ai didi

google-cloud-dataflow - 用于暂存位置的 GCS URI 无效

转载 作者:行者123 更新时间:2023-12-04 15:17:54 26 4
gpt4 key购买 nike

当通过包含所有依赖项的 jar 启动数据流作业 (v.2.4.0) 时,而不是使用提供的 GCS 路径,似乎在本地创建了一个 gs:/文件夹,因此数据流工作人员尝试访问<localjarfolderpath>/gs:/...而不是真正的 GCS 路径 gs://...如果我是对的,这不是数据流 1.x.x 的情况。

示例命令:
java -cp 0.1-1.0-SNAPSHOT-jar-with-dependencies.jar Main --stagingLocation=gs://test/staging/
云控制台错误:
Staged package 0.1-1.0-SNAPSHOT-jar-with-dependencies-89nvLkMzfT53iBBXlpW_oA.jar at location <localjarfolderpath>/gs:/test/staging/ is inaccessible. ... The pattern must be of the form "gs://<bucket>/path/to/file".

最佳答案

我设法解决了它,不使用 maven-assembly-plugin用于构建具有依赖项的 jar。使用 maven-dependency-plugin 时与 maven-jar-plugin要创建 jar-with-dependencies,请正确构建暂存路径并且 Dataflow 成功启 Action 业。作为引用,这是我的 Maven jar 构建:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.package.main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>

由于 jar 包含类路径的 list 条目,您可以使用以下命令启 Action 业:
java -jar my-dataflow-job.jar
请注意 jar 和 lib包含所有依赖项必须在同一目录中。

更新:
我注意到 java -jar命令并不总是正确设置类路径,即使它是在 list 中定义的。如果您在使用 java -jar 时遇到问题,以下命令应该可以工作命令:
java -cp "my-dataflow-job.jar:lib/*" org.company.dataflow.Main
更新 2:
连同 @IvanPlantevin ,我发现了真正的问题是什么。触发我们的是这个 post .问题是方式 maven-assembly-plugin打包 jar 。在 list 中,在服务下,不是所有 FileSystemRegistrars被包含在内。在我们的例子中,它错过了 GcsFileSystemRegistrar .我们已经通过使用 maven-shade-plugin 解决了这个问题。与 ServicesResourceTransformer .下面的解决方案真正解决了问题。上述解决方案只是一种解决方法。这是我们当前的构建:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<!-- NOTE! Don't forget the ServicesResourceTransformer, otherwise other file system registrars are not added to the jar! -->
<transformer
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.package.main</mainClass>
</transformer>
</transformers>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>runner</shadedClassifierName>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

最后,您可以以常规方式启动它: java -jar my-dataflow-job.jar

关于google-cloud-dataflow - 用于暂存位置的 GCS URI 无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49654762/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com