gpt4 book ai didi

apache-spark - Spark : Determine the driver address from within a task

转载 作者:行者123 更新时间:2023-12-02 20:59:46 25 4
gpt4 key购买 nike

出于调试目的,我想从 Spark 任务(在执行程序中运行)向驱动程序计算机发送消息。 docs声称 spark.driver.host 包含此信息,但我不知道如何从工作人员(或从驱动程序,就此而言......)访问它

最佳答案

sc.getConf.get("spark.driver.host")

但是驱动程序不是您所需要的。你需要一个 worker 。因此,请在 rdd.mapPartitions block 中尝试类似以下代码:

val localhost = java.net.InetAddress.getLocalHost
val ip = java.net.NetworkInterface.getByInetAddress(localhost)

检查this以获得更精确的方法。

关于apache-spark - Spark : Determine the driver address from within a task,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38882453/

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