From d0bc6a27fdbeea2e06c0151e72347946ababf2e4 Mon Sep 17 00:00:00 2001 From: Sunil G Date: Tue, 25 Sep 2018 11:23:34 +0530 Subject: [PATCH] YARN-8817. [Submarine] In cases when user doesn't ask HDFS path while submitting job but framework requires user to set HDFS related environments. Contributed by Wangda Tan. --- .../yarnservice/YarnServiceJobSubmitter.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-submarine/src/main/java/org/apache/hadoop/yarn/submarine/runtimes/yarnservice/YarnServiceJobSubmitter.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-submarine/src/main/java/org/apache/hadoop/yarn/submarine/runtimes/yarnservice/YarnServiceJobSubmitter.java index 5855287880..d57c675dee 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-submarine/src/main/java/org/apache/hadoop/yarn/submarine/runtimes/yarnservice/YarnServiceJobSubmitter.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-submarine/src/main/java/org/apache/hadoop/yarn/submarine/runtimes/yarnservice/YarnServiceJobSubmitter.java @@ -102,6 +102,13 @@ private String getValueOfEnvionment(String envar) { } } + private boolean needHdfs(String content) { + if (content != null && content.contains("hdfs://")) { + return true; + } + return false; + } + private void addHdfsClassPathIfNeeded(RunJobParameters parameters, PrintWriter fw, Component comp) throws IOException { // Find envs to use HDFS @@ -121,14 +128,11 @@ private void addHdfsClassPathIfNeeded(RunJobParameters parameters, boolean lackingEnvs = false; - if ((parameters.getInputPath() != null && parameters.getInputPath() - .contains("hdfs://")) || (parameters.getCheckpointPath() != null - && parameters.getCheckpointPath().contains("hdfs://")) || ( - parameters.getSavedModelPath() != null && parameters.getSavedModelPath() - .contains("hdfs://")) || hadoopEnv) { + if (needHdfs(parameters.getInputPath()) || needHdfs( + parameters.getPSLaunchCmd()) || needHdfs( + parameters.getWorkerLaunchCmd()) || hadoopEnv) { // HDFS is asked either in input or output, set LD_LIBRARY_PATH // and classpath - if (hdfsHome != null) { // Unset HADOOP_HOME/HADOOP_YARN_HOME to make sure host machine's envs // won't pollute docker's env.