gpt4 book ai didi

apache-spark - 通过 SparkConf 以编程方式设置 Spark.executor.extraClassPath 选项

转载 作者:行者123 更新时间:2023-12-02 00:33:28 25 4
gpt4 key购买 nike

我的项目 jar 与 EMR 上的 jar 冲突,因此要解决此问题我已通过引导脚本将所有高级 jar 复制到节点的自定义位置。我已经验证 jar 已复制到所有执行器节点上。

它与spark-submit一起工作正常,我的代码引用了所有节点的自定义文件夹中的新jar。

/usr/bin/spark-submit --conf="spark.driver.extraClassPath=/usr/customJars/*" --conf="spark.executor.extraClassPath=/usr/customJars/*"  

我想通过更新sparkconf对象以编程方式在代码中实现同样的事情。

sparkConf.set("spark.driver.extraClassPath", "/usr/customJars/*");
sparkConf.set("spark.executor.extraClassPath", "/usr/customJars/*");

当我想以编程方式实现时它不起作用。我的代码没有引用自定义位置中更新的jar。

有什么建议吗?

最佳答案

大多数属性无法在 Spark 运行时更改。

您可以查看SparkConf的文档:SparkConf

Once SparkConf is passed to the SparkContext constructor, the values are cloned and cannot be changed. This is a Spark limitation.

您需要确保在测试新的属性更改之前停止并启动 Spark session 。

作为文档中的附加评论:Spark Configuration

对于spark.executor.extraClassPath:

Extra classpath entries to prepend to the classpath of executors. This exists primarily for backwards-compatibility with older versions of Spark. Users typically should not need to set this option.

您可以使用 spark.jars 来影响驱动程序和执行程序:

Comma-separated list of jars to include on the driver and executor classpaths. Globs are allowed.

确保您的 jar 在执行器中可用。

关于apache-spark - 通过 SparkConf 以编程方式设置 Spark.executor.extraClassPath 选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51293805/

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