Return-Path: X-Original-To: apmail-spark-reviews-archive@minotaur.apache.org Delivered-To: apmail-spark-reviews-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D704C107B5 for ; Fri, 18 Apr 2014 09:09:00 +0000 (UTC) Received: (qmail 97286 invoked by uid 500); 18 Apr 2014 03:37:39 -0000 Delivered-To: apmail-spark-reviews-archive@spark.apache.org Received: (qmail 96937 invoked by uid 500); 18 Apr 2014 03:37:39 -0000 Mailing-List: contact reviews-help@spark.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: reviews@spark.apache.org Delivered-To: mailing list reviews@spark.apache.org Received: (qmail 96024 invoked by uid 99); 18 Apr 2014 03:37:37 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Apr 2014 03:37:37 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id BF9CC99759E; Fri, 18 Apr 2014 03:37:36 +0000 (UTC) From: berngp To: reviews@spark.apache.org Reply-To: reviews@spark.apache.org References: In-Reply-To: Subject: [GitHub] spark pull request: [SPARK-1522] : YARN ClientBase throws a NPE if... Content-Type: text/plain Message-Id: <20140418033736.BF9CC99759E@tyr.zones.apache.org> Date: Fri, 18 Apr 2014 03:37:36 +0000 (UTC) Github user berngp commented on a diff in the pull request: https://github.com/apache/spark/pull/433#discussion_r11763060 --- Diff: yarn/common/src/main/scala/org/apache/spark/deploy/yarn/ClientBase.scala --- @@ -378,55 +378,48 @@ object ClientBase { val APP_JAR: String = "app.jar" val LOG4J_PROP: String = "log4j.properties" - // Based on code from org.apache.hadoop.mapreduce.v2.util.MRApps - def populateHadoopClasspath(conf: Configuration, env: HashMap[String, String]) { - val classpathEntries = Option(conf.getStrings( - YarnConfiguration.YARN_APPLICATION_CLASSPATH)).getOrElse( - getDefaultYarnApplicationClasspath()) - for (c <- classpathEntries) { - YarnSparkHadoopUtil.addToEnvironment(env, Environment.CLASSPATH.name, c.trim, - File.pathSeparator) - } + def populateHadoopClasspath(conf: Configuration, env: HashMap[String, String]) = { + val classPathElementsToAdd = getYarnAppClasspath(conf) ++ getMRAppClasspath(conf) + addToAppClasspath(env, classPathElementsToAdd) + classPathElementsToAdd + } - val mrClasspathEntries = Option(conf.getStrings( - "mapreduce.application.classpath")).getOrElse( - getDefaultMRApplicationClasspath()) - if (mrClasspathEntries != null) { - for (c <- mrClasspathEntries) { - YarnSparkHadoopUtil.addToEnvironment(env, Environment.CLASSPATH.name, c.trim, - File.pathSeparator) - } - } + protected[yarn] def getYarnAppClasspath(conf: Configuration) = + getAppClasspathForKey(YarnConfiguration.YARN_APPLICATION_CLASSPATH, conf)(getDefaultYarnApplicationClasspath) + + protected[yarn] def getMRAppClasspath(conf: Configuration) = + getAppClasspathForKey("mapreduce.application.classpath", conf)(getDefaultMRApplicationClasspath) + + protected[yarn] def addToAppClasspath(env: HashMap[String, String], elements : Iterable[String]) { + for ( c <- elements ) + yield (YarnSparkHadoopUtil.addToEnvironment(env, Environment.CLASSPATH.name, c.trim, File.pathSeparator)) --- End diff -- I kept the `for (c <- classPathElementsToAdd.flatten)`, to be honest the `yield` was a remanence of a different approach. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastructure@apache.org or file a JIRA ticket with INFRA. ---