accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ctubb...@apache.org
Subject svn commit: r1484620 - in /accumulo/branches/1.5/core/src: main/java/org/apache/accumulo/core/conf/DefaultConfiguration.java main/java/org/apache/accumulo/core/conf/Property.java test/java/org/apache/accumulo/core/conf/PropertyTest.java
Date Mon, 20 May 2013 22:54:21 GMT
Author: ctubbsii
Date: Mon May 20 22:54:20 2013
New Revision: 1484620

URL: http://svn.apache.org/r1484620
Log:
ACCUMULO-1440 Separate variable interpolation in properties at runtime from the documentation
generated at compile time

Modified:
    accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/conf/DefaultConfiguration.java
    accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/conf/Property.java
    accumulo/branches/1.5/core/src/test/java/org/apache/accumulo/core/conf/PropertyTest.java

Modified: accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/conf/DefaultConfiguration.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/conf/DefaultConfiguration.java?rev=1484620&r1=1484619&r2=1484620&view=diff
==============================================================================
--- accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/conf/DefaultConfiguration.java
(original)
+++ accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/conf/DefaultConfiguration.java
Mon May 20 22:54:20 2013
@@ -138,7 +138,7 @@ public class DefaultConfiguration extend
           }
           doc.println(indent(indentDepth) + "<td" + (isDeprecated ? " class='deprecated'"
: "") + ">" + zoo + "</td>");
           doc.println(indent(indentDepth) + "<td" + (isDeprecated ? " class='deprecated'"
: "") + "><pre>"
-              + (prop.getDefaultValue().isEmpty() ? "&nbsp;" : prop.getDefaultValue().replaceAll("
", "&nbsp;")) + "</pre></td>");
+              + (prop.getRawDefaultValue().isEmpty() ? "&nbsp;" : prop.getRawDefaultValue().replaceAll("
", "&nbsp;")) + "</pre></td>");
           doc.println(indent(indentDepth) + "<td" + (isDeprecated ? " class='deprecated'"
: "") + ">" + (isDeprecated ? "<b><i>Deprecated.</i></b> " : "")
               + prop.getDescription() + "</td>");
           doc.println(indent(--indentDepth) + "</tr>");

Modified: accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/conf/Property.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/conf/Property.java?rev=1484620&r1=1484619&r2=1484620&view=diff
==============================================================================
--- accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/conf/Property.java (original)
+++ accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/conf/Property.java Mon
May 20 22:54:20 2013
@@ -28,31 +28,33 @@ import org.apache.accumulo.core.util.for
 import org.apache.accumulo.core.util.interpret.DefaultScanInterpreter;
 import org.apache.accumulo.start.classloader.AccumuloClassLoader;
 import org.apache.accumulo.start.classloader.vfs.AccumuloVFSClassLoader;
+import org.apache.commons.configuration.PropertiesConfiguration;
+import org.apache.commons.configuration.SystemConfiguration;
 import org.apache.log4j.Logger;
 
 public enum Property {
   // Crypto-related properties
   CRYPTO_PREFIX("crypto.", null, PropertyType.PREFIX, "Properties in this category related
to the configuration of both default and custom crypto modules.",
-      true),
+      true, false),
   CRYPTO_MODULE_CLASS("crypto.module.class", "NullCryptoModule", PropertyType.STRING,
       "Fully qualified class name of the class that implements the CryptoModule interface,
to be used in setting up encryption at rest for the WAL and "
-          + "(future) other parts of the code.", true),
-  CRYPTO_CIPHER_SUITE("crypto.cipher.suite", "NullCipher", PropertyType.STRING, "Describes
the cipher suite to use for the write-ahead log", true),
+          + "(future) other parts of the code.", true, false),
+  CRYPTO_CIPHER_SUITE("crypto.cipher.suite", "NullCipher", PropertyType.STRING, "Describes
the cipher suite to use for the write-ahead log", true, false),
   CRYPTO_CIPHER_ALGORITHM_NAME("crypto.cipher.algorithm.name", "NullCipher", PropertyType.STRING,
       "States the name of the algorithm used in the corresponding cipher suite. Do not make
these different, unless you enjoy mysterious exceptions and bugs.",
-      true),
+      true, false),
   CRYPTO_CIPHER_KEY_LENGTH("crypto.cipher.key.length", "128", PropertyType.STRING,
-      "Specifies the key length *in bits* to use for the symmetric key, should probably be
128 or 256 unless you really know what you're doing", true),
+      "Specifies the key length *in bits* to use for the symmetric key, should probably be
128 or 256 unless you really know what you're doing", true, false),
   CRYPTO_SECURE_RNG("crypto.secure.rng", "SHA1PRNG", PropertyType.STRING,
-      "States the secure random number generator to use, and defaults to the built-in Sun
SHA1PRNG", true),
+      "States the secure random number generator to use, and defaults to the built-in Sun
SHA1PRNG", true, false),
   CRYPTO_SECURE_RNG_PROVIDER("crypto.secure.rng.provider", "SUN", PropertyType.STRING,
-      "States the secure random number generator provider to use, and defaults to the built-in
SUN provider", true),
+      "States the secure random number generator provider to use, and defaults to the built-in
SUN provider", true, false),
   CRYPTO_SECRET_KEY_ENCRYPTION_STRATEGY_CLASS("crypto.secret.key.encryption.strategy.class",
"NullSecretKeyEncryptionStrategy", PropertyType.STRING,
-      "The class Accumulo should use for its key encryption strategy.", true),
+      "The class Accumulo should use for its key encryption strategy.", true, false),
   CRYPTO_DEFAULT_KEY_STRATEGY_HDFS_URI("crypto.default.key.strategy.hdfs.uri", "", PropertyType.STRING,
-      "The URL Accumulo should use to connect to DFS. If this is blank, Accumulo will obtain
this information from the Hadoop configuration", true),
+      "The URL Accumulo should use to connect to DFS. If this is blank, Accumulo will obtain
this information from the Hadoop configuration", true, false),
   CRYPTO_DEFAULT_KEY_STRATEGY_KEY_LOCATION("crypto.default.key.strategy.key.location", "/accumulo/crypto/secret/keyEncryptionKey",
PropertyType.ABSOLUTEPATH,
-      "The absolute path of where to store the key encryption key within HDFS.", true),
+      "The absolute path of where to store the key encryption key within HDFS.", true, false),
   
   // instance properties (must be the same for every node in an instance)
   INSTANCE_PREFIX("instance.", null, PropertyType.PREFIX,
@@ -221,10 +223,10 @@ public enum Property {
   MONITOR_BANNER_COLOR("monitor.banner.color", "#c4c4c4", PropertyType.STRING, "The color
of the banner text displayed on the monitor page."),
   MONITOR_BANNER_BACKGROUND("monitor.banner.background", "#304065", PropertyType.STRING,
       "The background color of the banner text displayed on the monitor page."),
-  MONITOR_SSL_KEYSTORE("monitor.ssl.keyStore", "", PropertyType.PATH, "The keystore for enabling
monitor SSL.", true),
-  MONITOR_SSL_KEYSTOREPASS("monitor.ssl.keyStorePassword", "", PropertyType.STRING, "The
keystore password for enabling monitor SSL.", true),
-  MONITOR_SSL_TRUSTSTORE("monitor.ssl.trustStore", "", PropertyType.PATH, "The truststore
for enabling monitor SSL.", true),
-  MONITOR_SSL_TRUSTSTOREPASS("monitor.ssl.trustStorePassword", "", PropertyType.STRING, "The
truststore password for enabling monitor SSL.", true),
+  MONITOR_SSL_KEYSTORE("monitor.ssl.keyStore", "", PropertyType.PATH, "The keystore for enabling
monitor SSL.", true, false),
+  MONITOR_SSL_KEYSTOREPASS("monitor.ssl.keyStorePassword", "", PropertyType.STRING, "The
keystore password for enabling monitor SSL.", true, false),
+  MONITOR_SSL_TRUSTSTORE("monitor.ssl.trustStore", "", PropertyType.PATH, "The truststore
for enabling monitor SSL.", true, false),
+  MONITOR_SSL_TRUSTSTOREPASS("monitor.ssl.trustStorePassword", "", PropertyType.STRING, "The
truststore password for enabling monitor SSL.", true, false),
   
   TRACE_PREFIX("trace.", null, PropertyType.PREFIX, "Properties in this category affect the
behavior of distributed tracing."),
   TRACE_PORT("trace.port.client", "12234", PropertyType.PORT, "The listening port for the
trace server"),
@@ -340,26 +342,27 @@ public enum Property {
           + "You can enable post delegation for a context, which will load classes from the
context first instead of the parent first.  "
           + "Do this by setting general.vfs.context.classpath.&lt;name&gt;.delegation=post,
where &lt;name&gt; is your context name.  "
           + "If delegation is not specified, it defaults to loading from parent classloader
first."),
-  VFS_CLASSLOADER_CACHE_DIR(AccumuloVFSClassLoader.VFS_CACHE_DIR, new File(System.getProperty("java.io.tmpdir"),
"accumulo-vfs-cache-"
-      + System.getProperty("user.name", "nouser")).getAbsolutePath(), PropertyType.ABSOLUTEPATH,
-      "Directory to use for the vfs cache. The cache will keep a soft reference to all of
the classes loaded in the VM."
-          + " This should be on local disk on each node with sufficient space. It defaults
to /tmp", false);
+  VFS_CLASSLOADER_CACHE_DIR(AccumuloVFSClassLoader.VFS_CACHE_DIR, "${java.io.tmpdir}" + File.separator
+ "accumulo-vfs-cache-${user.name}",
+      PropertyType.ABSOLUTEPATH, "Directory to use for the vfs cache. The cache will keep
a soft reference to all of the classes loaded in the VM."
+          + " This should be on local disk on each node with sufficient space. It defaults
to ${java.io.tmpdir}/accumulo-vfs-cache-${user.name}", false, true);
   
   private String key, defaultValue, description;
   private PropertyType type;
   private boolean experimental;
+  private boolean interpolated;
   static Logger log = Logger.getLogger(Property.class);
   
-  private Property(String name, String defaultValue, PropertyType type, String description,
boolean experimental) {
+  private Property(String name, String defaultValue, PropertyType type, String description,
boolean experimental, boolean interpolated) {
     this.key = name;
     this.defaultValue = defaultValue;
     this.description = description;
     this.type = type;
     this.experimental = experimental;
+    this.interpolated = interpolated;
   }
   
   private Property(String name, String defaultValue, PropertyType type, String description)
{
-    this(name, defaultValue, type, description, false);
+    this(name, defaultValue, type, description, false, false);
   }
   
   @Override
@@ -371,10 +374,25 @@ public enum Property {
     return this.key;
   }
   
-  public String getDefaultValue() {
+  public String getRawDefaultValue() {
     return this.defaultValue;
   }
   
+  public String getDefaultValue() {
+    if (this.interpolated) {
+      PropertiesConfiguration pconf = new PropertiesConfiguration();
+      pconf.append(new SystemConfiguration());
+      pconf.addProperty("hack_default_value", this.defaultValue);
+      String v = pconf.getString("hack_default_value");
+      if (this.type == PropertyType.ABSOLUTEPATH)
+        return new File(v).getAbsolutePath();
+      else
+        return v;
+    } else {
+      return getRawDefaultValue();
+    }
+  }
+  
   public PropertyType getType() {
     return this.type;
   }

Modified: accumulo/branches/1.5/core/src/test/java/org/apache/accumulo/core/conf/PropertyTest.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/core/src/test/java/org/apache/accumulo/core/conf/PropertyTest.java?rev=1484620&r1=1484619&r2=1484620&view=diff
==============================================================================
--- accumulo/branches/1.5/core/src/test/java/org/apache/accumulo/core/conf/PropertyTest.java
(original)
+++ accumulo/branches/1.5/core/src/test/java/org/apache/accumulo/core/conf/PropertyTest.java
Mon May 20 22:54:20 2013
@@ -16,9 +16,11 @@
  */
 package org.apache.accumulo.core.conf;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
+import java.io.File;
 import java.util.HashSet;
 
 import org.junit.Test;
@@ -99,4 +101,12 @@ public class PropertyTest {
     // typeCheckValidFormat(PropertyType.ABSOLUTEPATH, "d:\\foo12", "c:\\foo\\g", "c:\\foo\\c",
"c:\\");
     typeCheckInvalidFormat(PropertyType.ABSOLUTEPATH, "foo12", "foo/g", "foo\\c");
   }
+  
+  @Test
+  public void testRawDefaultValues() {
+    AccumuloConfiguration conf = AccumuloConfiguration.getDefaultConfiguration();
+    assertEquals("${java.io.tmpdir}" + File.separator + "accumulo-vfs-cache-${user.name}",
Property.VFS_CLASSLOADER_CACHE_DIR.getRawDefaultValue());
+    assertEquals(new File(System.getProperty("java.io.tmpdir"), "accumulo-vfs-cache-" + System.getProperty("user.name")).getAbsolutePath(),
+        conf.get(Property.VFS_CLASSLOADER_CACHE_DIR));
+  }
 }



Mime
View raw message