Merge branch '1.6.1-SNAPSHOT' Conflicts: core/src/main/java/org/apache/accumulo/core/conf/ConfigSanityCheck.java core/src/main/java/org/apache/accumulo/core/conf/ConfigurationDocGen.java core/src/main/java/org/apache/accumulo/core/conf/DefaultConfiguration.java
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/c6ed57ed Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/c6ed57ed Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/c6ed57ed Branch: refs/heads/master Commit: c6ed57ed8f68ba99dfe54bbb7a36f85a4baa59b5 Parents: b8271d4 37f900b Author: Bill Havanki <bhava...@cloudera.com> Authored: Wed Aug 13 10:48:05 2014 -0400 Committer: Bill Havanki <bhava...@cloudera.com> Committed: Wed Aug 13 10:48:05 2014 -0400 ---------------------------------------------------------------------- .../accumulo/core/conf/ConfigSanityCheck.java | 41 +++++++--- .../accumulo/core/conf/ConfigurationDocGen.java | 23 +++++- .../core/conf/DefaultConfiguration.java | 62 +++++---------- .../core/conf/ConfigSanityCheckTest.java | 79 ++++++++++++++++++++ .../core/conf/DefaultConfigurationTest.java | 44 +++++++++++ docs/pom.xml | 4 +- 6 files changed, 193 insertions(+), 60 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/c6ed57ed/core/src/main/java/org/apache/accumulo/core/conf/ConfigSanityCheck.java ---------------------------------------------------------------------- diff --cc core/src/main/java/org/apache/accumulo/core/conf/ConfigSanityCheck.java index 1fb035c,88d32ef..4bda600 --- a/core/src/main/java/org/apache/accumulo/core/conf/ConfigSanityCheck.java +++ b/core/src/main/java/org/apache/accumulo/core/conf/ConfigSanityCheck.java @@@ -29,17 -29,15 +29,19 @@@ public class ConfigSanityCheck private static final String PREFIX = "BAD CONFIG "; /** - * Validates the given configuration. A valid configuration contains only - * Validates the given configuration entries. ++ * Validates the given configuration entries. A valid configuration contains only + * valid properties (i.e., defined or otherwise valid) that are not prefixes + * and whose values are formatted correctly for their property types. A valid + * configuration also contains a value for property + * {@link Property#INSTANCE_ZK_TIMEOUT} within a valid range. * - * @param acuconf configuration - * @throws RuntimeException if the configuration fails validation + * @param entries iterable through configuration keys and values + * @throws SanityCheckException if a fatal configuration error is found */ - public static void validate(AccumuloConfiguration acuconf) { - for (Entry<String,String> entry : acuconf) { + public static void validate(Iterable<Entry<String,String>> entries) { + String instanceZkTimeoutKey = Property.INSTANCE_ZK_TIMEOUT.getKey(); + String instanceZkTimeoutValue = null; + for (Entry<String,String> entry : entries) { String key = entry.getKey(); String value = entry.getValue(); Property prop = Property.getPropertyByKey(entry.getKey()); http://git-wip-us.apache.org/repos/asf/accumulo/blob/c6ed57ed/core/src/main/java/org/apache/accumulo/core/conf/ConfigurationDocGen.java ---------------------------------------------------------------------- diff --cc core/src/main/java/org/apache/accumulo/core/conf/ConfigurationDocGen.java index d90ce98,41a1f3b..d8d788b --- a/core/src/main/java/org/apache/accumulo/core/conf/ConfigurationDocGen.java +++ b/core/src/main/java/org/apache/accumulo/core/conf/ConfigurationDocGen.java @@@ -19,7 -20,7 +20,8 @@@ import java.io.FileNotFoundException import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; + import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.TreeMap; @@@ -348,8 -336,21 +350,25 @@@ class ConfigurationDocGen new HTML().generate(); } - void generateLaTeX() { - new LaTeX().generate(); + void generateAsciidoc() { + new Asciidoc().generate(); } + /* - * Generate documentation for conf/accumulo-site.xml file usage ++ * Generates documentation for conf/accumulo-site.xml file usage. Arguments ++ * are: "--generate-doc", file to write to. ++ * ++ * @param args command-line arguments ++ * @throws IllegalArgumentException if args is invalid + */ + public static void main(String[] args) throws FileNotFoundException, UnsupportedEncodingException { + if (args.length == 2 && args[0].equals("--generate-html")) { - new ConfigurationDocGen(new PrintStream(args[1], Constants.UTF8.name())).generateHtml(); - } else if (args.length == 2 && args[0].equals("--generate-latex")) { - new ConfigurationDocGen(new PrintStream(args[1], Constants.UTF8.name())).generateLaTeX(); ++ new ConfigurationDocGen(new PrintStream(args[1], StandardCharsets.UTF_8.name())).generateHtml(); ++ } else if (args.length == 2 && args[0].equals("--generate-asciidoc")) { ++ new ConfigurationDocGen(new PrintStream(args[1], StandardCharsets.UTF_8.name())).generateAsciidoc(); + } else { - throw new IllegalArgumentException("Usage: " + ConfigurationDocGen.class.getName() + " --generate-html <filename> | --generate-latex <filename>"); ++ throw new IllegalArgumentException("Usage: " + ConfigurationDocGen.class.getName() + " --generate-html <filename> | --generate-asciidoc <filename>"); + } + } + } http://git-wip-us.apache.org/repos/asf/accumulo/blob/c6ed57ed/core/src/main/java/org/apache/accumulo/core/conf/DefaultConfiguration.java ---------------------------------------------------------------------- diff --cc core/src/main/java/org/apache/accumulo/core/conf/DefaultConfiguration.java index 635813f,6e1b779..b1d8851 --- a/core/src/main/java/org/apache/accumulo/core/conf/DefaultConfiguration.java +++ b/core/src/main/java/org/apache/accumulo/core/conf/DefaultConfiguration.java @@@ -24,26 -21,28 +21,30 @@@ import java.util.HashMap import java.util.Map; import java.util.Map.Entry; -import org.apache.accumulo.core.Constants; - +/** + * An {@link AccumuloConfiguration} that contains only default values for + * properties. This class is a singleton. + */ public class DefaultConfiguration extends AccumuloConfiguration { - private static DefaultConfiguration instance = null; - private Map<String,String> resolvedProps = null; + private final static Map<String,String> resolvedProps; + static { + Map<String, String> m = new HashMap<String,String>(); + for (Property prop : Property.values()) { + if (!prop.getType().equals(PropertyType.PREFIX)) { + m.put(prop.getKey(), prop.getDefaultValue()); + } + } + ConfigSanityCheck.validate(m.entrySet()); + resolvedProps = Collections.unmodifiableMap(m); + } /** - * Gets an instance of this class. + * Gets a default configuration. * * @return default configuration - * @throws RuntimeException if the default configuration is invalid */ - synchronized public static DefaultConfiguration getInstance() { - if (instance == null) { - instance = new DefaultConfiguration(); - ConfigSanityCheck.validate(instance); - } - return instance; + public static DefaultConfiguration getInstance() { + return new DefaultConfiguration(); } @Override @@@ -68,22 -56,5 +58,4 @@@ if (filter.accept(entry.getKey())) props.put(entry.getKey(), entry.getValue()); } -- - /* - * Generates documentation for conf/accumulo-site.xml file usage. Arguments - * are: "--generate-doc", file to write to. - * - * @param args command-line arguments - * @throws IllegalArgumentException if args is invalid - */ - public static void main(String[] args) throws FileNotFoundException, UnsupportedEncodingException { - if (args.length == 2 && args[0].equals("--generate-html")) { - new ConfigurationDocGen(new PrintStream(args[1], StandardCharsets.UTF_8.name())).generateHtml(); - } else if (args.length == 2 && args[0].equals("--generate-asciidoc")) { - new ConfigurationDocGen(new PrintStream(args[1], StandardCharsets.UTF_8.name())).generateAsciidoc(); - } else { - throw new IllegalArgumentException("Usage: " + DefaultConfiguration.class.getName() + " --generate-html <filename> | --generate-latex <filename>"); - } - } - } http://git-wip-us.apache.org/repos/asf/accumulo/blob/c6ed57ed/docs/pom.xml ---------------------------------------------------------------------- diff --cc docs/pom.xml index 4cc75a9,a6260c6..47d98da --- a/docs/pom.xml +++ b/docs/pom.xml @@@ -119,11 -77,11 +119,11 @@@ </goals> <phase>compile</phase> <configuration> - <mainClass>org.apache.accumulo.core.conf.DefaultConfiguration</mainClass> + <mainClass>org.apache.accumulo.core.conf.ConfigurationDocGen</mainClass> <classpathScope>compile</classpathScope> <arguments> - <argument>--generate-latex</argument> - <argument>${project.build.directory}/latex/accumulo_user_manual/appendices/config.tex</argument> + <argument>--generate-asciidoc</argument> + <argument>${project.build.directory}/asciidoc/appendices/config.txt</argument> </arguments> </configuration> </execution>