From fe649bb3051f5647073c840d7334a90265ea3f06 Mon Sep 17 00:00:00 2001 From: Steve Loughran Date: Wed, 2 May 2018 13:33:56 +0100 Subject: [PATCH] HADOOP-12071. conftest is not documented. Contributed by Kengo Seki. --- .../java/org/apache/hadoop/util/ConfTest.java | 10 ++++------ .../src/site/markdown/CommandsManual.md | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ConfTest.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ConfTest.java index 1915e791d2..a2cb85f255 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ConfTest.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ConfTest.java @@ -84,7 +84,7 @@ private static List parseConf(InputStream in) QName property = new QName("property"); List nodes = new ArrayList(); - Stack parsed = new Stack(); + Stack parsed = new Stack<>(); XMLInputFactory factory = XMLInputFactory.newInstance(); XMLEventReader reader = factory.createXMLEventReader(in); @@ -258,9 +258,7 @@ public static void main(String[] args) throws IOException { if (confFile.isFile()) { files.add(confFile); } else if (confFile.isDirectory()) { - for (File file : listFiles(confFile)) { - files.add(file); - } + files.addAll(Arrays.asList(listFiles(confFile))); } else { terminate(1, confFile.getAbsolutePath() + " is neither a file nor directory"); @@ -313,9 +311,9 @@ class NodeInfo { private StartElement startElement; private List attributes = new ArrayList(); private Map elements = - new HashMap(); + new HashMap<>(); private Map> qNameXMLEventsMap = - new HashMap>(); + new HashMap<>(); public NodeInfo(StartElement startElement) { this.startElement = startElement; diff --git a/hadoop-common-project/hadoop-common/src/site/markdown/CommandsManual.md b/hadoop-common-project/hadoop-common/src/site/markdown/CommandsManual.md index 2839503502..ce904c596e 100644 --- a/hadoop-common-project/hadoop-common/src/site/markdown/CommandsManual.md +++ b/hadoop-common-project/hadoop-common/src/site/markdown/CommandsManual.md @@ -99,6 +99,23 @@ Usage: `hadoop classpath [--glob |--jar |-h |--help]` Prints the class path needed to get the Hadoop jar and the required libraries. If called without arguments, then prints the classpath set up by the command scripts, which is likely to contain wildcards in the classpath entries. Additional options print the classpath after wildcard expansion or write the classpath into the manifest of a jar file. The latter is useful in environments where wildcards cannot be used and the expanded classpath exceeds the maximum supported command line length. +### `conftest` + +Usage: `hadoop conftest [-conffile ]...` + +| COMMAND\_OPTION | Description | +|:---- |:---- | +| `-conffile` | Path of a configuration file or directory to validate | +| `-h`, `--help` | print help | + +Validates configuration XML files. +If the `-conffile` option is not specified, the files in `${HADOOP_CONF_DIR}` whose name end with .xml will be verified. If specified, that path will be verified. You can specify either a file or directory, and if a directory specified, the files in that directory whose name end with `.xml` will be verified. +You can specify `-conffile` option multiple times. + +The validation is fairly minimal: the XML is parsed and duplicate and empty +property names are checked for. The command does not support XInclude; if you +using that to pull in configuration items, it will declare the XML file invalid. + ### `credential` Usage: `hadoop credential [options]`