File tree Expand file tree Collapse file tree 2 files changed +5
-5
lines changed
main/scala/org/apache/spark/deploy/yarn
test/scala/org/apache/spark/deploy/yarn Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -101,9 +101,8 @@ class YarnSparkHadoopUtil extends SparkHadoopUtil {
101101 }
102102
103103 private [spark] override def scheduleLoginFromKeytab (): Unit = {
104- val principal = sparkConf.get(" spark.yarn.principal" )
105- val keytab = sparkConf.get(" spark.yarn.keytab" )
106- if (principal != null ) {
104+ sparkConf.getOption(" spark.yarn.principal" ).foreach { principal =>
105+ val keytab = sparkConf.get(" spark.yarn.keytab" )
107106 val delegationTokenRenewerRunnable =
108107 new Runnable {
109108 override def run (): Unit = {
@@ -155,8 +154,7 @@ class YarnSparkHadoopUtil extends SparkHadoopUtil {
155154
156155 override def updateCredentialsIfRequired (): Unit = {
157156 try {
158- val credentialsFile = sparkConf.get(" spark.yarn.credentials.file" )
159- if (credentialsFile != null && ! credentialsFile.isEmpty) {
157+ sparkConf.getOption(" spark.yarn.credentials.file" ).foreach { credentialsFile =>
160158 val credentialsFilePath = new Path (credentialsFile)
161159 val remoteFs = FileSystem .get(conf)
162160 val stagingDirPath = new Path (remoteFs.getHomeDirectory, credentialsFilePath.getParent)
Original file line number Diff line number Diff line change @@ -85,6 +85,7 @@ class YarnClusterSuite extends FunSuite with BeforeAndAfterAll with Matchers wit
8585 tempDir = Utils .createTempDir()
8686 logConfDir = new File (tempDir, " log4j" )
8787 logConfDir.mkdir()
88+ System .setProperty(" SPARK_YARN_MODE" , " true" )
8889
8990 val logConfFile = new File (logConfDir, " log4j.properties" )
9091 Files .write(LOG4J_CONF , logConfFile, UTF_8 )
@@ -124,6 +125,7 @@ class YarnClusterSuite extends FunSuite with BeforeAndAfterAll with Matchers wit
124125
125126 override def afterAll () {
126127 yarnCluster.stop()
128+ System .clearProperty(" SPARK_YARN_MODE" )
127129 super .afterAll()
128130 }
129131
You can’t perform that action at this time.
0 commit comments