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

标签 apache-spark sparkcore

我的项目 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/

相关文章:

java - 线程 "main"java.lang.NoSuchMethodError : scala. Predef$.refArrayOps(

swift - nsMutableUrl addvalue 在 key 周围添加引号 ""

apache-spark - Apache Spark : Difference between parallelize and broadcast

java - 在独立模式下使用 spark 在 elasticsearch 中建立索引

c++ - 尝试使用 String 正确子串

rest - 使用 Gobot.io 和 sleepy RESTful Framework for Go 执行 SparkCore 函数

apache-spark - Spark 本地模式和独立模式之间的确切区别是什么?

apache-spark - Spark 窗口函数最后一个非空值

apache-spark - Spark Client 和 Spark Driver 有什么区别?

java - 如何在 Java 中检索唯一的 Spark 作业 ID?