From e269c3fb5a938e4359232628175569dbbd1a12c1 Mon Sep 17 00:00:00 2001 From: Giovanni Matteo Fumarola Date: Mon, 12 Nov 2018 15:06:43 -0800 Subject: [PATCH] YARN-8997. [Submarine] Small refactors of modifier, condition check and redundant local variables. Contributed by Zhankun Tang. --- .../apache/hadoop/yarn/submarine/client/cli/CliUtils.java | 4 +--- .../runtimes/common/FSBasedSubmarineStorageImpl.java | 6 ++---- .../runtimes/yarnservice/YarnServiceJobMonitor.java | 3 +-- .../runtimes/yarnservice/YarnServiceJobSubmitter.java | 5 +---- .../submarine/runtimes/yarnservice/YarnServiceUtils.java | 4 +--- 5 files changed, 6 insertions(+), 16 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-submarine/src/main/java/org/apache/hadoop/yarn/submarine/client/cli/CliUtils.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-submarine/src/main/java/org/apache/hadoop/yarn/submarine/client/cli/CliUtils.java index 546c6ebbbf..05e830f50d 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-submarine/src/main/java/org/apache/hadoop/yarn/submarine/client/cli/CliUtils.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-submarine/src/main/java/org/apache/hadoop/yarn/submarine/client/cli/CliUtils.java @@ -156,9 +156,7 @@ public class CliUtils { return true; if (args.length == 1) { - if (args[0].equals("-h") || args[0].equals("--help")) { - return true; - } + return args[0].equals("-h") || args[0].equals("--help"); } return false; diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-submarine/src/main/java/org/apache/hadoop/yarn/submarine/runtimes/common/FSBasedSubmarineStorageImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-submarine/src/main/java/org/apache/hadoop/yarn/submarine/runtimes/common/FSBasedSubmarineStorageImpl.java index 767fe78fc3..18815107ff 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-submarine/src/main/java/org/apache/hadoop/yarn/submarine/runtimes/common/FSBasedSubmarineStorageImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-submarine/src/main/java/org/apache/hadoop/yarn/submarine/runtimes/common/FSBasedSubmarineStorageImpl.java @@ -73,8 +73,7 @@ public class FSBasedSubmarineStorageImpl extends SubmarineStorage { private Path getModelInfoPath(String modelName, String version, boolean create) throws IOException { Path modelDir = rdm.getModelDir(modelName, create); - Path modelInfo = new Path(modelDir, version + ".info"); - return modelInfo; + return new Path(modelDir, version + ".info"); } private void serializeMap(FSDataOutputStream fos, Map map) @@ -98,7 +97,6 @@ public class FSBasedSubmarineStorageImpl extends SubmarineStorage { private Path getJobInfoPath(String jobName, boolean create) throws IOException { Path path = rdm.getJobStagingArea(jobName, create); - Path fileName = new Path(path, "job.info"); - return fileName; + return new Path(path, "job.info"); } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-submarine/src/main/java/org/apache/hadoop/yarn/submarine/runtimes/yarnservice/YarnServiceJobMonitor.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-submarine/src/main/java/org/apache/hadoop/yarn/submarine/runtimes/yarnservice/YarnServiceJobMonitor.java index 94d30b030f..fab018a900 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-submarine/src/main/java/org/apache/hadoop/yarn/submarine/runtimes/yarnservice/YarnServiceJobMonitor.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-submarine/src/main/java/org/apache/hadoop/yarn/submarine/runtimes/yarnservice/YarnServiceJobMonitor.java @@ -40,7 +40,6 @@ public class YarnServiceJobMonitor extends JobMonitor { } Service serviceSpec = this.serviceClient.getStatus(jobName); - JobStatus jobStatus = JobStatusBuilder.fromServiceSpec(serviceSpec); - return jobStatus; + return JobStatusBuilder.fromServiceSpec(serviceSpec); } } 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 d57c675dee..bcd4698f91 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 @@ -103,10 +103,7 @@ public class YarnServiceJobSubmitter implements JobSubmitter { } private boolean needHdfs(String content) { - if (content != null && content.contains("hdfs://")) { - return true; - } - return false; + return content != null && content.contains("hdfs://"); } private void addHdfsClassPathIfNeeded(RunJobParameters parameters, diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-submarine/src/main/java/org/apache/hadoop/yarn/submarine/runtimes/yarnservice/YarnServiceUtils.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-submarine/src/main/java/org/apache/hadoop/yarn/submarine/runtimes/yarnservice/YarnServiceUtils.java index d69840abb9..ce3a1eb1b3 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-submarine/src/main/java/org/apache/hadoop/yarn/submarine/runtimes/yarnservice/YarnServiceUtils.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-submarine/src/main/java/org/apache/hadoop/yarn/submarine/runtimes/yarnservice/YarnServiceUtils.java @@ -58,9 +58,7 @@ public class YarnServiceUtils { private static String getDNSNameCommonSuffix(String serviceName, String userName, String domain, int port) { - String commonEndpointSuffix = - "." + serviceName + "." + userName + "." + domain + ":" + port; - return commonEndpointSuffix; + return "." + serviceName + "." + userName + "." + domain + ":" + port; } public static String getTFConfigEnv(String curCommponentName, int nWorkers,