简体   繁体   English

Flink 无法访问 JAR 中的文件

[英]Flink can't access files in JAR

I tried to run a JAR in a flink cluster but I get this FileNotFound Exception.我试图在 flink 集群中运行一个 JAR,但我得到了这个 FileNotFound Exception。

Caused by: java.io.FileNotFoundException: File file:/tmp/flink-web-88bf3f41-94fc-40bd-a865-bb0e6d5ac95c/flink-web-upload/82227475-523d-4607-8ab2-09bae8602248-tutorial-1.0-jar-with-dependencies.jar!/ldbc_sample/edges.csv does not exist or the user running Flink ('userA') has insufficient permissions to access it.
    at org.apache.flink.core.fs.local.LocalFileSystem.getFileStatus(LocalFileSystem.java:106)

The csv files are located in a folder in the resources directory of the project. csv 文件位于项目资源目录中的文件夹中。

I access the file path by:我通过以下方式访问文件路径:

URL resource = Helper.class.getClassLoader().getResource("ldbc_sample");
return resource.getPath();

I opened the jar and made sure that the files definitely exist, and I also run it locally, and it worked.我打开 jar 并确保文件确实存在,并且我也在本地运行它,它工作。 What do I have to do, to make sure that flink can access my csv?我该怎么做才能确保 flink 可以访问我的 csv?

Maybe you want to pass your .csv as an argument to your program ?也许您想将您的.csv作为参数传递给您的程序? Something like:就像是:

def main(args: Array[String]): Unit = {
  val ldbcSample = ParameterTool.fromArgs(args).getRequired("ldbc_sample")
  ...
}

or you can make your .properties file with different arguments:或者您可以使用不同的参数制作.properties文件:

ldbc_sample: /ldbc_sample/edges.csv
topic_source: TOPIC_NAME
val jobParams = ParameterTool.fromArgs(args)
val jobArgs = ParameterTool.fromPropertiesFile(jobParams.getRequired("properties_file_path"))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM