我有一个SparkSession方法,在所有用例中,它都能在群集上正常工作,但是在Jenkins中测试用例失败,通过设置.config(“ spark.driver.bindAddress”,“ 127.0.0.1”),该方法得到了解决。但是此设置在群集上运行时引起问题。因此,在Spark Session方法中,如果Spark仅在本地通过条件检查运行,如何设置此属性。
我在条件检查中进行此设置时遇到问题,请帮助。
下面是存在的工作方法:
@transient private var sparkSession: SparkSession = null
//Creating SparkSession
def getSparkSession: SparkSession = {
val conf = new SparkConf().setAppName("test")
.setIfMissing("spark.master", "local[*]")
if (sparkSession == null)
sparkSession = SparkSession.builder().config(conf).getOrCreate()
sparkSession
}
我想添加如下条件:
@transient private var sparkSession: SparkSession = null
//Creating SparkSession
def getSparkSession: SparkSession = {
val conf = new SparkConf().setAppName("test")
.setIfMissing("spark.master", "local[*]")
if (sparkSession == null)
sparkSession = SparkSession.builder().config(conf).getOrCreate()
if(spark.master = local) {
sparkSession = SparkSession.builder().config(conf).config("spark.driver.bindAddress", "127.0.0.1").getOrCreate()
}
sparkSession
}
在Jenkins中,使用此设置删除该设置后,测试失败。
exception : ERROR SparkContext: Error initializing SparkContext.
java.net.BindException: Cannot assign requested address: Service 'sparkDriver' failed after 16 retries (on a random free port)! Consider explicitly setting the appropriate binding address for the service 'sparkDriver' (for example spark.driver.bindAddress for SparkDriver) to the correct binding address.
我有一个SparkSession方法,在所有用例中,它都可以在群集上正常工作,但是在Jenkins中测试案例失败,通过设置.config(“ spark.driver.bindAddress”,“ 127.0...。
检查下面的代码。