diff --git a/core/src/main/scala/spark/executor/Executor.scala b/core/src/main/scala/spark/executor/Executor.scala index 9e0356a711beb6d5372b3e37010622e11690d776..25f55b391b9d96fa554173f38356a2cb48afc75f 100644 --- a/core/src/main/scala/spark/executor/Executor.scala +++ b/core/src/main/scala/spark/executor/Executor.scala @@ -119,15 +119,12 @@ private[spark] class Executor( // Hadoop 0.23 and 2.x have different Environment variable names for the // local dirs, so lets check both. We assume one of the 2 is set. // LOCAL_DIRS => 2.X, YARN_LOCAL_DIRS => 0.23.X - var localDirs = System.getenv("LOCAL_DIRS") - val yarnLocalSysDirs = Option(System.getenv("YARN_LOCAL_DIRS")) - yarnLocalSysDirs match { - case Some(s) => localDirs = s - case None => { - if ((localDirs == null) || (localDirs.isEmpty())) { - throw new Exception("Yarn Local dirs can't be empty") - } - } + val localDirs = Option(System.getenv("YARN_LOCAL_DIRS")) + .getOrElse(Option(System.getenv("LOCAL_DIRS")) + .getOrElse("")) + + if (localDirs.isEmpty()) { + throw new Exception("Yarn Local dirs can't be empty") } return localDirs } diff --git a/yarn/src/main/scala/spark/deploy/yarn/ApplicationMaster.scala b/yarn/src/main/scala/spark/deploy/yarn/ApplicationMaster.scala index 33e6293a6b69f401d81fdec760f55f33b26c5be2..0f3b6bc1a65d0c77e6d84d330529705ff5fd1238 100644 --- a/yarn/src/main/scala/spark/deploy/yarn/ApplicationMaster.scala +++ b/yarn/src/main/scala/spark/deploy/yarn/ApplicationMaster.scala @@ -98,15 +98,12 @@ class ApplicationMaster(args: ApplicationMasterArguments, conf: Configuration) e // Hadoop 0.23 and 2.x have different Environment variable names for the // local dirs, so lets check both. We assume one of the 2 is set. // LOCAL_DIRS => 2.X, YARN_LOCAL_DIRS => 0.23.X - var localDirs = System.getenv("LOCAL_DIRS") - val yarnLocalSysDirs = Option(System.getenv("YARN_LOCAL_DIRS")) - yarnLocalSysDirs match { - case Some(s) => localDirs = s - case None => { - if ((localDirs == null) || (localDirs.isEmpty())) { - throw new Exception("Yarn Local dirs can't be empty") - } - } + val localDirs = Option(System.getenv("YARN_LOCAL_DIRS")) + .getOrElse(Option(System.getenv("LOCAL_DIRS")) + .getOrElse("")) + + if (localDirs.isEmpty()) { + throw new Exception("Yarn Local dirs can't be empty") } return localDirs }