com.bigdata.config
Class Configuration

java.lang.Object
  extended by com.bigdata.config.Configuration

public class Configuration
extends Object

Base class for managing the initial configuration metadata for indices and locatable resources.

Version:
$Id: Configuration.java 2265 2009-10-26 12:51:06Z thompsonbry $
Author:
Bryan Thompson
TODO:
There are some drawbacks with this approach. It remains to be seen whether this can be improved on readily.

We can not report properties that DO NOT correspond to any known property within the umbrella bigdata namespace (as log4j does) because we do not make a closed world assumption for properties in that namespace.

We can not interpret properties given in a Java code style (as jini does with its Configuration object).

We are not using the Java beans model so you can not describe property values or instantiate objects using reflection. Instead, the logic for that stuff shows up in the code for the class that is being configured.

This presumes a fixed syntactic relation between a resource/index and its container rather than the explicit relation defined by RelationSchema.CONTAINER.


Field Summary
static char DOT
          The namespace separator character.
protected static org.apache.log4j.Logger log
          Property values are logged at INFO.
static String NAMESPACE
          The prefix for namespace specific property value overrides.
 
Constructor Summary
Configuration()
           
 
Method Summary
static String getOverrideProperty(String namespace, String property)
          Return the name that can be used to overrride the specified property for the given namespace.
static String getProperty(IIndexManager indexManagerIsIgnored, Properties properties, String namespace, String propertyName, String defaultValue)
          Return the value for property, which may be the default value, a global override, or a namespace override.
static
<E> E
getProperty(IIndexManager indexManager, Properties properties, String namespace, String globalName, String defaultValue, IValidator<E> validator)
          Variant converts to the specified generic type and validates the value.
static NV getProperty2(IIndexManager indexManagerIsIgnored, Properties properties, String namespace, String globalName, String defaultValue)
          Variant returns both the name under which the value was discovered and the value.
protected static UUID resolveDataService(IIndexManager indexManager, String val)
          Resolve the value to a DataService UUID.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static final transient org.apache.log4j.Logger log
Property values are logged at INFO.


NAMESPACE

public static final transient String NAMESPACE
The prefix for namespace specific property value overrides.

See Also:
Constant Field Values

DOT

public static final transient char DOT
The namespace separator character.

See Also:
Constant Field Values
Constructor Detail

Configuration

public Configuration()
Method Detail

getProperty

public static String getProperty(IIndexManager indexManagerIsIgnored,
                                 Properties properties,
                                 String namespace,
                                 String propertyName,
                                 String defaultValue)
Return the value for property, which may be the default value, a global override, or a namespace override. Defaults are assigned by three mechanisms.
  1. Default values are generally described in the javadoc for Options interfaces. The specific default is supplied by the caller and will be used if the value is not overriden using any of the other methods.
  2. The default value may be globally overriden using the property name. For example, you can override the default branching factor for all BTrees by specifying a value for IndexMetadata.Options#BTREE_BRANCHING_FACTOR. In general, the name of the property is declared by an interface along with its default value.
  3. Any value may be overriden by a value that is specific to the namespace (or to any prefix of that namespace which can be formed by chopping off the namespace at a DOT). For example, you can override the branching factor property for an index named foo.myIndex by specifying a value for the property name com.bigdata.namespace.foo.myIndex.com.bigdata.btree.BTree.branchingFactor ("com.bigdata.namespace" is the NAMESPACE prefix for overrides, foo.myIndex is the name of the index, and is the name of the property that will be overriden for that index). Alternatively you can override the branching factor for all indices in the "foo" relation by specifying a value for the property name com.bigdata.namespace.foo.com.bigdata.btree.BTree.branchingFactor. Note: You can use getOverrideProperty(String, String) to form these property names automatically, including from within a Jini configuration file.

Parameters:
indexManagerIsIgnored - The value specified to the ctor (optional).
properties - The properties object against which the value of the property will be resolved.
namespace - The namespace of the index, relation, etc (optional).
propertyName - The bare name of the property whose default value is requested (without the namespace).
defaultValue - The value for that property that will be returned if the default has not been overriden as described above (optional).
Returns:
The resolved value for the property.
TODO:
test when namespace is empty (journal uses that) and possibly null.

getProperty2

public static NV getProperty2(IIndexManager indexManagerIsIgnored,
                              Properties properties,
                              String namespace,
                              String globalName,
                              String defaultValue)
Variant returns both the name under which the value was discovered and the value.

Parameters:
indexManagerIsIgnored -
properties -
namespace -
globalName -
defaultValue -
Returns:

getProperty

public static <E> E getProperty(IIndexManager indexManager,
                                Properties properties,
                                String namespace,
                                String globalName,
                                String defaultValue,
                                IValidator<E> validator)
                     throws ConfigurationException
Variant converts to the specified generic type and validates the value.

Type Parameters:
E -
Parameters:
indexManager -
properties -
namespace -
globalName -
defaultValue -
validator -
Returns:
The validated value -or- null if there was no default.
Throws:
ConfigurationException

resolveDataService

protected static UUID resolveDataService(IIndexManager indexManager,
                                         String val)
Resolve the value to a DataService UUID.

Parameters:
indexManager - The index manager (optional).
val - The value is either a UUID or a service name.
Returns:
The UUID of the identified service -or- null if no service is identified for that value or if the indexManager is either not given or not an IBigdataFederation.
Throws:
IllegalArgumentException - if the val is null.

getOverrideProperty

public static String getOverrideProperty(String namespace,
                                         String property)
Return the name that can be used to overrride the specified property for the given namespace.

Parameters:
namespace - The namespace (of an index, relation, etc).
property - The global property name.
Returns:
The name that is used to override that property for that namespace.


Copyright © 2006-2009 SYSTAP, LLC. All Rights Reserved.