From 9bdfbc0492f2d7408c250ae165763719cf290eeb Mon Sep 17 00:00:00 2001 From: Thomas Graves Date: Thu, 9 Jan 2014 15:45:33 -0600 Subject: Update based on review comments --- .../org/apache/spark/deploy/yarn/ApplicationMaster.scala | 13 ++++++------- .../scala/org/apache/spark/deploy/yarn/WorkerLauncher.scala | 13 ++++++------- 2 files changed, 12 insertions(+), 14 deletions(-) (limited to 'yarn/stable') diff --git a/yarn/stable/src/main/scala/org/apache/spark/deploy/yarn/ApplicationMaster.scala b/yarn/stable/src/main/scala/org/apache/spark/deploy/yarn/ApplicationMaster.scala index 69ae14ce83..4b777d5fa7 100644 --- a/yarn/stable/src/main/scala/org/apache/spark/deploy/yarn/ApplicationMaster.scala +++ b/yarn/stable/src/main/scala/org/apache/spark/deploy/yarn/ApplicationMaster.scala @@ -116,14 +116,13 @@ class ApplicationMaster(args: ApplicationMasterArguments, conf: Configuration, // local dirs, so lets check both. We assume one of the 2 is set. // LOCAL_DIRS => 2.X, YARN_LOCAL_DIRS => 0.23.X 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") + .orElse(Option(System.getenv("LOCAL_DIRS"))) + + localDirs match { + case None => throw new Exception("Yarn Local dirs can't be empty") + case Some(l) => l } - localDirs - } + } private def getApplicationAttemptId(): ApplicationAttemptId = { val envs = System.getenv() diff --git a/yarn/stable/src/main/scala/org/apache/spark/deploy/yarn/WorkerLauncher.scala b/yarn/stable/src/main/scala/org/apache/spark/deploy/yarn/WorkerLauncher.scala index 3e3a4672b4..78353224fa 100644 --- a/yarn/stable/src/main/scala/org/apache/spark/deploy/yarn/WorkerLauncher.scala +++ b/yarn/stable/src/main/scala/org/apache/spark/deploy/yarn/WorkerLauncher.scala @@ -117,18 +117,17 @@ class WorkerLauncher(args: ApplicationMasterArguments, conf: Configuration, spar } /** Get the Yarn approved local directories. */ - private def getLocalDirs(): String = { + private def getLocalDirs(): String = { // 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 val localDirs = Option(System.getenv("YARN_LOCAL_DIRS")) - .getOrElse(Option(System.getenv("LOCAL_DIRS")) - .getOrElse("")) + .orElse(Option(System.getenv("LOCAL_DIRS"))) - if (localDirs.isEmpty()) { - throw new Exception("Yarn Local dirs can't be empty") - } - localDirs + localDirs match { + case None => throw new Exception("Yarn Local dirs can't be empty") + case Some(l) => l + } } private def getApplicationAttemptId(): ApplicationAttemptId = { -- cgit v1.2.3