简体   繁体   English

使用java.io.File.mkdirs()将File写入目录,然后访问它在Spark Cluster模式下不起作用

[英]Writing File to a directory using java.io.File.mkdirs() and then accessing it not working in spark cluster mode

When i try to run the same code in client mode, the code runs successfully. 当我尝试在客户端模式下运行相同的代码时,代码将成功运行。 But when run on cluster mode it fails to create the file and prompts with error No such File or Directory. 但是,在群集模式下运行时,它无法创建文件,并提示错误No No File / Directory。

Below is the code sample: 下面是代码示例:

new File("UnexistingLocation").mkdirs()

---> Directories created in client mode --->在客户端模式下创建的目录

---> Code do not give error in cluster mode but i cannot see directory created. --->代码在群集模式下不会出错,但是我看不到目录已创建。 Also while creating File inside the directory gives error No such file or Directory. 同样,在目录内创建File时,给出错误No no file or Directory。

Is there a workaround by which i could create files on driver node local filesystem? 有没有解决方法,我可以在驱动程序节点本地文件系统上创建文件?

due to your error analysis I assume this is run in driver-scoped code. 由于您的错误分析,我认为这是在驱动程序作用域的代码中运行的。 If you submit using --deploy-mode cluster your driver will be started on an arbitrary node which means that's where your directory will be. 如果您使用--deploy-mode cluster提交,则驱动程序将在任意节点上启动,这意味着目录将位于该节点上。 It won't be on the node where you do your spark-submit from 它不会在您执行spark-submit的节点上

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

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