com.cloudera.lib.util
Class XConfiguration

java.lang.Object
  extended by org.apache.hadoop.conf.Configuration
      extended by com.cloudera.lib.util.XConfiguration
All Implemented Interfaces:
Iterable<Map.Entry<String,String>>, org.apache.hadoop.io.Writable

public class XConfiguration
extends org.apache.hadoop.conf.Configuration

Extends Hadoop Configuration providing a new constructor which reads an XML configuration from an InputStream.

OConfiguration(InputStream is).


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.hadoop.conf.Configuration
org.apache.hadoop.conf.Configuration.IntegerRanges
 
Constructor Summary
XConfiguration()
          Create an empty configuration.
XConfiguration(InputStream is)
          Create a configuration from an InputStream.
XConfiguration(Properties props)
          Create an configuration from a Properties instance.
XConfiguration(Reader reader)
          Create a configuration from an Reader.
 
Method Summary
static void copy(org.apache.hadoop.conf.Configuration source, org.apache.hadoop.conf.Configuration target)
          Copy configuration key/value pairs from one configuration to another if a property exists in the target, it gets replaced.
 Class<?> getClassByName(String name)
          This is a stop gap fix for HADOOP-4416.
static void injectDefaults(org.apache.hadoop.conf.Configuration source, org.apache.hadoop.conf.Configuration target)
          Injects configuration key/value pairs from one configuration to another if the key does not exist in the target configuration.
 XConfiguration resolve()
          Returns a new XConfiguration instance with all inline values resolved.
 Properties toProperties()
          Return a Properties instance with the configuration properties.
 String toXmlString()
          Return a string with the configuration in XML format.
 String toXmlString(boolean prolog)
           
 XConfiguration trim()
          Returns a new XConfiguration with all values trimmed.
 
Methods inherited from class org.apache.hadoop.conf.Configuration
addDefaultResource, addResource, addResource, addResource, addResource, clear, dumpConfiguration, get, get, getBoolean, getClass, getClass, getClasses, getClassLoader, getConfResourceAsInputStream, getConfResourceAsReader, getEnum, getFile, getFloat, getInstances, getInt, getLocalPath, getLong, getPattern, getRange, getRaw, getResource, getStringCollection, getStrings, getStrings, getTrimmed, getTrimmedStringCollection, getTrimmedStrings, getTrimmedStrings, getValByRegex, iterator, main, readFields, reloadConfiguration, set, setBoolean, setBooleanIfUnset, setClass, setClassLoader, setEnum, setFloat, setIfUnset, setInt, setLong, setPattern, setQuietMode, setStrings, size, toString, write, writeXml, writeXml
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XConfiguration

public XConfiguration()
Create an empty configuration.

Default values are not loaded.


XConfiguration

public XConfiguration(InputStream is)
               throws IOException
Create a configuration from an InputStream.

ERROR canibalized from Configuration.loadResource().

Parameters:
is - inputstream to read the configuration from.
Throws:
IOException - thrown if the configuration could not be read.

XConfiguration

public XConfiguration(Reader reader)
               throws IOException
Create a configuration from an Reader.

ERROR canibalized from Configuration.loadResource().

Parameters:
reader - reader to read the configuration from.
Throws:
IOException - thrown if the configuration could not be read.

XConfiguration

public XConfiguration(Properties props)
Create an configuration from a Properties instance.

Parameters:
props - Properties instance to get all properties from.
Method Detail

getClassByName

public Class<?> getClassByName(String name)
                        throws ClassNotFoundException
This is a stop gap fix for HADOOP-4416.

Overrides:
getClassByName in class org.apache.hadoop.conf.Configuration
Throws:
ClassNotFoundException

copy

public static void copy(org.apache.hadoop.conf.Configuration source,
                        org.apache.hadoop.conf.Configuration target)
Copy configuration key/value pairs from one configuration to another if a property exists in the target, it gets replaced.

Parameters:
source - source configuration.
target - target configuration.

injectDefaults

public static void injectDefaults(org.apache.hadoop.conf.Configuration source,
                                  org.apache.hadoop.conf.Configuration target)
Injects configuration key/value pairs from one configuration to another if the key does not exist in the target configuration.

Parameters:
source - source configuration.
target - target configuration.

trim

public XConfiguration trim()
Returns a new XConfiguration with all values trimmed.

Returns:
a new XConfiguration with all values trimmed.

resolve

public XConfiguration resolve()
Returns a new XConfiguration instance with all inline values resolved.

Returns:
a new XConfiguration instance with all inline values resolved.

toXmlString

public String toXmlString()
Return a string with the configuration in XML format.

Returns:
a string with the configuration in XML format.

toXmlString

public String toXmlString(boolean prolog)

toProperties

public Properties toProperties()
Return a Properties instance with the configuration properties.

Returns:
a Properties instance with the configuration properties.


Copyright © 2012 Cloudera. All Rights Reserved.