From 6c0e36b91ccf749a83417fef4515f0d87b83215e Mon Sep 17 00:00:00 2001 From: Yongjun Zhang Date: Fri, 11 Dec 2015 18:44:01 -0800 Subject: [PATCH] HDFS-9519. Some coding improvement in SecondaryNameNode#main. (Xiao Chen via Yongjun Zhang) (cherry picked from commit 2a4c7d4facabb8b99d6dcbf4ccfe2afedf4fd445) Conflicts: hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../hdfs/server/namenode/SecondaryNameNode.java | 14 ++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 0991c8f4c8b..31ac6610601 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -850,6 +850,9 @@ Release 2.8.0 - UNRELEASED HDFS-9535. Newly completed blocks in IBR should not be considered under-replicated too quickly. (Mingliang Liu via jing9) + HDFS-9519. Some coding improvement in SecondaryNameNode#main. + (Xiao Chen via Yongjun Zhang) + OPTIMIZATIONS HDFS-8026. Trace FSOutputSummer#writeChecksumChunks rather than diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/SecondaryNameNode.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/SecondaryNameNode.java index 9909d4add4d..acb2c8a535c 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/SecondaryNameNode.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/SecondaryNameNode.java @@ -679,18 +679,16 @@ public class SecondaryNameNode implements Runnable, SecondaryNameNode secondary = null; secondary = new SecondaryNameNode(tconf, opts); + // SecondaryNameNode can be started in 2 modes: + // 1. run a command (i.e. checkpoint or geteditsize) then terminate + // 2. run as a daemon when {@link #parseArgs} yields no commands if (opts != null && opts.getCommand() != null) { + // mode 1 int ret = secondary.processStartupCommand(opts); terminate(ret); - } - - if (secondary != null) { - // The web server is only needed when starting SNN as a daemon, - // and not needed if called from shell command. Starting the web server - // from shell may fail when getting credentials, if the environment - // is not set up for it, which is most of the case. + } else { + // mode 2 secondary.startInfoServer(); - secondary.startCheckpointThread(); secondary.join(); }