org.apache.hadoop.hbase
Class CompoundConfiguration

java.lang.Object
  extended by org.apache.hadoop.conf.Configuration
      extended by org.apache.hadoop.hbase.CompoundConfiguration
All Implemented Interfaces:
Iterable<Map.Entry<String,String>>, org.apache.hadoop.io.Writable

@InterfaceAudience.Private
public class CompoundConfiguration
extends org.apache.hadoop.conf.Configuration

Do a shallow merge of multiple KV configuration pools. This is a very useful utility class to easily add per-object configurations in addition to wider scope settings. This is different from Configuration.addResource() functionality, which performs a deep merge and mutates the common data structure.

For clarity: the shallow merge allows the user to mutate either of the configuration objects and have changes reflected everywhere. In contrast to a deep merge, that requires you to explicitly know all applicable copies to propagate changes.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.hadoop.conf.Configuration
org.apache.hadoop.conf.Configuration.IntegerRanges
 
Field Summary
protected  List<org.apache.hadoop.hbase.CompoundConfiguration.ImmutableConfigMap> configs
           
 
Constructor Summary
CompoundConfiguration()
          Default Constructor.
 
Method Summary
 CompoundConfiguration add(org.apache.hadoop.conf.Configuration conf)
          Add Hadoop Configuration object to config list.
 CompoundConfiguration addStringMap(Map<String,String> map)
          Add String map to config list.
 CompoundConfiguration addWritableMap(Map<ImmutableBytesWritable,ImmutableBytesWritable> map)
          Add ImmutableBytesWritable map to config list.
 void clear()
          This class is immutable.
 String get(String key)
           
 String get(String name, String defaultValue)
          You should just ignore everything below this line unless there's a bug in Configuration.java...
 boolean getBoolean(String name, boolean defaultValue)
           
 Class<?> getClass(String name, Class<?> defaultValue)
           
<U> Class<? extends U>
getClass(String name, Class<? extends U> defaultValue, Class<U> xface)
           
 Class<?> getClassByName(String name)
           
 Class<?>[] getClasses(String name, Class<?>... defaultValue)
           
 float getFloat(String name, float defaultValue)
           
protected  String getHexDigits(String value)
           
 int getInt(String name, int defaultValue)
           
 long getLong(String name, long defaultValue)
           
 org.apache.hadoop.conf.Configuration.IntegerRanges getRange(String name, String defaultValue)
           
 String getRaw(String key)
           
 Collection<String> getStringCollection(String name)
           
 String[] getStrings(String name)
           
 String[] getStrings(String name, String... defaultValue)
           
 Iterator<Map.Entry<String,String>> iterator()
           
 void readFields(DataInput in)
           
 void set(String name, String value)
           
 void setBoolean(String name, boolean value)
           
 void setBooleanIfUnset(String name, boolean value)
           
 void setClass(String name, Class<?> theClass, Class<?> xface)
           
 void setClassLoader(ClassLoader classLoader)
           
 void setFloat(String name, float value)
           
 void setIfUnset(String name, String value)
           
 void setInt(String name, int value)
           
 void setLong(String name, long value)
           
 void setStrings(String name, String... values)
           
 int size()
           
 String toString()
           
 void write(DataOutput out)
           
 void writeXml(OutputStream out)
           
 
Methods inherited from class org.apache.hadoop.conf.Configuration
addDefaultResource, addResource, addResource, addResource, addResource, dumpConfiguration, getClassLoader, getConfResourceAsInputStream, getConfResourceAsReader, getEnum, getFile, getInstances, getLocalPath, getResource, getValByRegex, main, reloadConfiguration, setEnum, setQuietMode, writeXml
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

configs

protected List<org.apache.hadoop.hbase.CompoundConfiguration.ImmutableConfigMap> configs
Constructor Detail

CompoundConfiguration

public CompoundConfiguration()
Default Constructor. Initializes empty configuration

Method Detail

add

public CompoundConfiguration add(org.apache.hadoop.conf.Configuration conf)
Add Hadoop Configuration object to config list. The added configuration overrides the previous ones if there are name collisions.

Parameters:
conf - configuration object
Returns:
this, for builder pattern

addWritableMap

public CompoundConfiguration addWritableMap(Map<ImmutableBytesWritable,ImmutableBytesWritable> map)
Add ImmutableBytesWritable map to config list. This map is generally created by HTableDescriptor or HColumnDescriptor, but can be abstractly used. The added configuration overrides the previous ones if there are name collisions.

Parameters:
map - ImmutableBytesWritable map
Returns:
this, for builder pattern

addStringMap

public CompoundConfiguration addStringMap(Map<String,String> map)
Add String map to config list. This map is generally created by HTableDescriptor or HColumnDescriptor, but can be abstractly used. The added configuration overrides the previous ones if there are name collisions.

Returns:
this, for builder pattern

toString

public String toString()
Overrides:
toString in class org.apache.hadoop.conf.Configuration

get

public String get(String key)
Overrides:
get in class org.apache.hadoop.conf.Configuration

getRaw

public String getRaw(String key)
Overrides:
getRaw in class org.apache.hadoop.conf.Configuration

getClassByName

public Class<?> getClassByName(String name)
                        throws ClassNotFoundException
Overrides:
getClassByName in class org.apache.hadoop.conf.Configuration
Throws:
ClassNotFoundException

size

public int size()
Overrides:
size in class org.apache.hadoop.conf.Configuration

get

public String get(String name,
                  String defaultValue)
You should just ignore everything below this line unless there's a bug in Configuration.java... Below get APIs are directly copied from Configuration.java Oh, how I wish this wasn't so! A tragically-sad example of why you use interfaces instead of inheritance. Why the duplication? We basically need to override Configuration.getProps or we'd need protected access to Configuration.properties so we can modify that pointer. There are a bunch of functions in the base Configuration that call getProps() and we need to use our derived version instead of the base version. We need to make a generic implementation that works across all HDFS versions. We should modify Configuration.properties in HDFS 1.0 to be protected, but we still need to have this code until that patch makes it to all the HDFS versions we support.

Overrides:
get in class org.apache.hadoop.conf.Configuration

getInt

public int getInt(String name,
                  int defaultValue)
Overrides:
getInt in class org.apache.hadoop.conf.Configuration

getLong

public long getLong(String name,
                    long defaultValue)
Overrides:
getLong in class org.apache.hadoop.conf.Configuration

getHexDigits

protected String getHexDigits(String value)

getFloat

public float getFloat(String name,
                      float defaultValue)
Overrides:
getFloat in class org.apache.hadoop.conf.Configuration

getBoolean

public boolean getBoolean(String name,
                          boolean defaultValue)
Overrides:
getBoolean in class org.apache.hadoop.conf.Configuration

getRange

public org.apache.hadoop.conf.Configuration.IntegerRanges getRange(String name,
                                                                   String defaultValue)
Overrides:
getRange in class org.apache.hadoop.conf.Configuration

getStringCollection

public Collection<String> getStringCollection(String name)
Overrides:
getStringCollection in class org.apache.hadoop.conf.Configuration

getStrings

public String[] getStrings(String name)
Overrides:
getStrings in class org.apache.hadoop.conf.Configuration

getStrings

public String[] getStrings(String name,
                           String... defaultValue)
Overrides:
getStrings in class org.apache.hadoop.conf.Configuration

getClasses

public Class<?>[] getClasses(String name,
                             Class<?>... defaultValue)
Overrides:
getClasses in class org.apache.hadoop.conf.Configuration

getClass

public Class<?> getClass(String name,
                         Class<?> defaultValue)
Overrides:
getClass in class org.apache.hadoop.conf.Configuration

getClass

public <U> Class<? extends U> getClass(String name,
                                       Class<? extends U> defaultValue,
                                       Class<U> xface)
Overrides:
getClass in class org.apache.hadoop.conf.Configuration

clear

public void clear()
This class is immutable. Quickly abort any attempts to alter it *

Overrides:
clear in class org.apache.hadoop.conf.Configuration

iterator

public Iterator<Map.Entry<String,String>> iterator()
Specified by:
iterator in interface Iterable<Map.Entry<String,String>>
Overrides:
iterator in class org.apache.hadoop.conf.Configuration

set

public void set(String name,
                String value)
Overrides:
set in class org.apache.hadoop.conf.Configuration

setIfUnset

public void setIfUnset(String name,
                       String value)
Overrides:
setIfUnset in class org.apache.hadoop.conf.Configuration

setInt

public void setInt(String name,
                   int value)
Overrides:
setInt in class org.apache.hadoop.conf.Configuration

setLong

public void setLong(String name,
                    long value)
Overrides:
setLong in class org.apache.hadoop.conf.Configuration

setFloat

public void setFloat(String name,
                     float value)
Overrides:
setFloat in class org.apache.hadoop.conf.Configuration

setBoolean

public void setBoolean(String name,
                       boolean value)
Overrides:
setBoolean in class org.apache.hadoop.conf.Configuration

setBooleanIfUnset

public void setBooleanIfUnset(String name,
                              boolean value)
Overrides:
setBooleanIfUnset in class org.apache.hadoop.conf.Configuration

setStrings

public void setStrings(String name,
                       String... values)
Overrides:
setStrings in class org.apache.hadoop.conf.Configuration

setClass

public void setClass(String name,
                     Class<?> theClass,
                     Class<?> xface)
Overrides:
setClass in class org.apache.hadoop.conf.Configuration

setClassLoader

public void setClassLoader(ClassLoader classLoader)
Overrides:
setClassLoader in class org.apache.hadoop.conf.Configuration

readFields

public void readFields(DataInput in)
                throws IOException
Specified by:
readFields in interface org.apache.hadoop.io.Writable
Overrides:
readFields in class org.apache.hadoop.conf.Configuration
Throws:
IOException

write

public void write(DataOutput out)
           throws IOException
Specified by:
write in interface org.apache.hadoop.io.Writable
Overrides:
write in class org.apache.hadoop.conf.Configuration
Throws:
IOException

writeXml

public void writeXml(OutputStream out)
              throws IOException
Overrides:
writeXml in class org.apache.hadoop.conf.Configuration
Throws:
IOException


Copyright © 2013 The Apache Software Foundation. All Rights Reserved.