From 3272a1c2f83bf252a37d2642de1147f1d66b51ec Mon Sep 17 00:00:00 2001 From: Todd Lipcon Date: Wed, 11 Apr 2012 05:28:51 +0000 Subject: [PATCH] HDFS-3249. Use ToolRunner.confirmPrompt in NameNode. Contributed by Todd Lipcon. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1324563 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 2 ++ .../hadoop/hdfs/server/namenode/NameNode.java | 29 +------------------ 2 files changed, 3 insertions(+), 28 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 013dbb2cbb2..db81ece8908 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -239,6 +239,8 @@ Release 2.0.0 - UNRELEASED HDFS-3247. Improve bootstrapStandby behavior when original NN is not active (todd) + HDFS-3249. Use ToolRunner.confirmPrompt in NameNode (todd) + OPTIMIZATIONS HDFS-2477. Optimize computing the diff between a block report and the diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java index 9dbf36b8e46..4d70be8d5c5 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java @@ -72,6 +72,7 @@ import org.apache.hadoop.security.authorize.RefreshAuthorizationPolicyProtocol; import org.apache.hadoop.tools.GetUserMappingsProtocol; import org.apache.hadoop.util.ServicePlugin; import org.apache.hadoop.util.StringUtils; +import static org.apache.hadoop.util.ToolRunner.confirmPrompt; import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.Lists; @@ -971,34 +972,6 @@ public class NameNode { } } - /** - * Print out a prompt to the user, and return true if the user - * responds with "Y" or "yes". - */ - static boolean confirmPrompt(String prompt) throws IOException { - while (true) { - System.err.print(prompt + " (Y or N) "); - StringBuilder responseBuilder = new StringBuilder(); - while (true) { - int c = System.in.read(); - if (c == -1 || c == '\r' || c == '\n') { - break; - } - responseBuilder.append((char)c); - } - - String response = responseBuilder.toString(); - if (response.equalsIgnoreCase("y") || - response.equalsIgnoreCase("yes")) { - return true; - } else if (response.equalsIgnoreCase("n") || - response.equalsIgnoreCase("no")) { - return false; - } - // else ask them again - } - } - public static NameNode createNameNode(String argv[], Configuration conf) throws IOException { if (conf == null)