Skip to content

Commit 088edfe

Browse files
authored
[linkis][spark]optimize Spark parameter acquisition (#944)
* #AI commit# 开发阶段:优化spark参数获取 * #AI commit# 开发阶段:优化spark参数获取
1 parent 424bc67 commit 088edfe

1 file changed

Lines changed: 22 additions & 19 deletions

File tree

linkis-engineconn-plugins/spark/src/main/scala/org/apache/linkis/engineplugin/spark/executor/SparkEngineConnExecutor.scala

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ abstract class SparkEngineConnExecutor(val sc: SparkContext, id: Long)
315315
)
316316

317317
if (!isSpark3) {
318-
logger.warn(s"Spark executor params setting is only supported in Spark3 engine")
318+
logger.info(s"Spark executor params setting is only supported in Spark3 engine")
319319
return
320320
}
321321

@@ -329,26 +329,29 @@ abstract class SparkEngineConnExecutor(val sc: SparkContext, id: Long)
329329
var skippedParams = 0
330330
var successCount = 0
331331
var failCount = 0
332-
logger.info(
333-
s"Spark executor params setting begin"
334-
)
335-
sc.getConf.getAll.foreach { case (key, value) =>
336-
totalParams += 1
337-
if (excludeParams.contains(key)) {
338-
logger.info(
339-
s"Spark executor params $key will be excluded and will not be set."
340-
)
341-
skippedParams += 1
342-
} else {
343-
Utils.tryCatch {
344-
sc.setLocalProperty(key, value)
345-
successCount += 1
346-
} { case e: Exception =>
347-
logger.warn(s"Failed to set spark param: $key, error: ${e.getMessage}", e)
348-
failCount += 1
332+
logger.info(s"Spark executor params setting begin")
333+
this
334+
.asInstanceOf[SparkSqlExecutor]
335+
.getSparkEngineSession
336+
.sparkSession
337+
.sessionState
338+
.conf
339+
.getAllConfs
340+
.foreach { case (key, value) =>
341+
totalParams += 1
342+
if (excludeParams.contains(key)) {
343+
logger.info(s"Spark executor params $key will be excluded and will not be set.")
344+
skippedParams += 1
345+
} else {
346+
Utils.tryCatch {
347+
sc.setLocalProperty(key, value)
348+
successCount += 1
349+
} { case e: Exception =>
350+
logger.warn(s"Failed to set spark param: $key, error: ${e.getMessage}", e)
351+
failCount += 1
352+
}
349353
}
350354
}
351-
}
352355

353356
logger.info(
354357
s"Spark executor params setting completed - total: $totalParams, " +

0 commit comments

Comments
 (0)