Author: suresh
Date: Tue Jan 31 20:03:49 2012
New Revision: 1238779
URL: http://svn.apache.org/viewvc?rev=1238779&view=rev
Log:
HDFS-2835. Fix findbugs and javadoc issue with GetConf.java. Contributed by
Suresh Srinivas.
Modified:
hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/GetConf.java
Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
URL:
http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt?rev=1238779&r1=1238778&r2=1238779&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt (original)
+++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt Tue Jan 31
20:03:49 2012
@@ -384,6 +384,9 @@ Release 0.23.1 - UNRELEASED
directory results in leases updated incorrectly. (Uma Maheswara Rao G
via szetszwo)
+ HDFS-2835. Fix findbugs and javadoc issue with GetConf.java.
+ (suresh)
+
Release 0.23.0 - 2011-11-01
INCOMPATIBLE CHANGES
Modified:
hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/GetConf.java
URL:
http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/GetConf.java?rev=1238779&r1=1238778&r2=1238779&view=diff
==============================================================================
---
hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/GetConf.java
(original)
+++
hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/GetConf.java
Tue Jan 31 20:03:49 2012
@@ -21,7 +21,9 @@ import java.io.IOException;
import java.io.PrintStream;
import java.net.InetSocketAddress;
import java.security.PrivilegedExceptionAction;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.Configured;
@@ -47,6 +49,9 @@ import org.apache.hadoop.util.ToolRunner
* {@link GetConf.Command}.
*
* See {@link GetConf.Command#NAMENODE} for example.
+ *
+ * Add for the new option added, a map entry with the corresponding
+ * {@link GetConf.CommandHandler}.
* </ul>
*/
public class GetConf extends Configured implements Tool {
@@ -54,31 +59,40 @@ public class GetConf extends Configured
+ "getting configuration information from the config file.\n";
enum Command {
- NAMENODE("-namenodes", new NameNodesCommandHandler(),
- "gets list of namenodes in the cluster."),
- SECONDARY("-secondaryNameNodes", new SecondaryNameNodesCommandHandler(),
+ NAMENODE("-namenodes", "gets list of namenodes in the cluster."),
+ SECONDARY("-secondaryNameNodes",
"gets list of secondary namenodes in the cluster."),
- BACKUP("-backupNodes", new BackupNodesCommandHandler(),
- "gets list of backup nodes in the cluster."),
+ BACKUP("-backupNodes", "gets list of backup nodes in the cluster."),
INCLUDE_FILE("-includeFile",
- new CommandHandler("DFSConfigKeys.DFS_HOSTS"),
"gets the include file path that defines the datanodes " +
"that can join the cluster."),
EXCLUDE_FILE("-excludeFile",
- new CommandHandler("DFSConfigKeys.DFS_HOSTS_EXCLUDE"),
"gets the exclude file path that defines the datanodes " +
"that need to decommissioned."),
- NNRPCADDRESSES("-nnRpcAddresses",
- new NNRpcAddressesCommandHandler(),
- "gets the namenode rpc addresses");
+ NNRPCADDRESSES("-nnRpcAddresses", "gets the namenode rpc addresses");
+ private static Map<String, CommandHandler> map;
+ static {
+ map = new HashMap<String, CommandHandler>();
+ map.put(NAMENODE.getName().toLowerCase(),
+ new NameNodesCommandHandler());
+ map.put(SECONDARY.getName().toLowerCase(),
+ new SecondaryNameNodesCommandHandler());
+ map.put(BACKUP.getName().toLowerCase(),
+ new BackupNodesCommandHandler());
+ map.put(INCLUDE_FILE.getName().toLowerCase(),
+ new CommandHandler("DFSConfigKeys.DFS_HOSTS"));
+ map.put(EXCLUDE_FILE.getName().toLowerCase(),
+ new CommandHandler("DFSConfigKeys.DFS_HOSTS_EXCLUDE"));
+ map.put(NNRPCADDRESSES.getName().toLowerCase(),
+ new NNRpcAddressesCommandHandler());
+ }
+
private final String cmd;
- private final CommandHandler handler;
private final String description;
- Command(String cmd, CommandHandler handler, String description) {
+ Command(String cmd, String description) {
this.cmd = cmd;
- this.handler = handler;
this.description = description;
}
@@ -91,12 +105,7 @@ public class GetConf extends Configured
}
public static CommandHandler getHandler(String name) {
- for (Command cmd : values()) {
- if (cmd.getName().equalsIgnoreCase(name)) {
- return cmd.handler;
- }
- }
- return null;
+ return map.get(name.toLowerCase());
}
}