HDFS-12530. Processor argument in Offline Image Viewer should be case insensitive. Contributed by Hanisha Koneru.

This commit is contained in:
Arpit Agarwal 2017-09-22 09:47:57 -07:00
parent 908d8e914e
commit 08fca508e6

View File

@ -33,6 +33,7 @@
import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.net.NetUtils; import org.apache.hadoop.net.NetUtils;
import org.apache.hadoop.util.StringUtils;
/** /**
* OfflineImageViewerPB to dump the contents of an Hadoop image file to XML or * OfflineImageViewerPB to dump the contents of an Hadoop image file to XML or
@ -174,8 +175,8 @@ public static int run(String[] args) throws Exception {
Configuration conf = new Configuration(); Configuration conf = new Configuration();
try (PrintStream out = outputFile.equals("-") ? try (PrintStream out = outputFile.equals("-") ?
System.out : new PrintStream(outputFile, "UTF-8")) { System.out : new PrintStream(outputFile, "UTF-8")) {
switch (processor) { switch (StringUtils.toUpperCase(processor)) {
case "FileDistribution": case "FILEDISTRIBUTION":
long maxSize = Long.parseLong(cmd.getOptionValue("maxSize", "0")); long maxSize = Long.parseLong(cmd.getOptionValue("maxSize", "0"));
int step = Integer.parseInt(cmd.getOptionValue("step", "0")); int step = Integer.parseInt(cmd.getOptionValue("step", "0"));
boolean formatOutput = cmd.hasOption("format"); boolean formatOutput = cmd.hasOption("format");
@ -186,7 +187,7 @@ public static int run(String[] args) throws Exception {
new PBImageXmlWriter(conf, out).visit(new RandomAccessFile(inputFile, new PBImageXmlWriter(conf, out).visit(new RandomAccessFile(inputFile,
"r")); "r"));
break; break;
case "ReverseXML": case "REVERSEXML":
try { try {
OfflineImageReconstructor.run(inputFile, outputFile); OfflineImageReconstructor.run(inputFile, outputFile);
} catch (Exception e) { } catch (Exception e) {
@ -196,14 +197,14 @@ public static int run(String[] args) throws Exception {
System.exit(1); System.exit(1);
} }
break; break;
case "Web": case "WEB":
String addr = cmd.getOptionValue("addr", "localhost:5978"); String addr = cmd.getOptionValue("addr", "localhost:5978");
try (WebImageViewer viewer = try (WebImageViewer viewer =
new WebImageViewer(NetUtils.createSocketAddr(addr))) { new WebImageViewer(NetUtils.createSocketAddr(addr))) {
viewer.start(inputFile); viewer.start(inputFile);
} }
break; break;
case "Delimited": case "DELIMITED":
try (PBImageDelimitedTextWriter writer = try (PBImageDelimitedTextWriter writer =
new PBImageDelimitedTextWriter(out, delimiter, tempPath)) { new PBImageDelimitedTextWriter(out, delimiter, tempPath)) {
writer.visit(new RandomAccessFile(inputFile, "r")); writer.visit(new RandomAccessFile(inputFile, "r"));