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.

The iterator on CompoundConfiguration is unmodifiable. Obtaining iterator is an expensive operation.

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. WARNING: The values set in the CompoundConfiguration are do not handle Property variable substitution. However, if they are set in the underlying configuration substitutions are done.


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()
          These methods are unsupported, and no code using CompoundConfiguration depend upon them.
 String get(String key)
           
 String get(String name, String defaultValue)
          Get the value of the name.
 Class<?> getClassByName(String name)
           
 String getRaw(String key)
           
 Iterator<Map.Entry<String,String>> iterator()
           
 void set(String name, String value)
           
 int size()
           
 String toString()
           
 void write(DataOutput out)
           
 void writeXml(OutputStream out)
           
 
Methods inherited from class org.apache.hadoop.conf.Configuration
addDefaultResource, addDeprecation, addDeprecation, addDeprecation, addDeprecation, addResource, addResource, addResource, addResource, addResource, dumpConfiguration, dumpDeprecatedKeys, getBoolean, getClass, getClass, getClassByNameOrNull, getClasses, getClassLoader, getConfResourceAsInputStream, getConfResourceAsReader, getDouble, getEnum, getFile, getFloat, getInstances, getInt, getInts, getLocalPath, getLong, getLongBytes, getPattern, getPropertySources, getProps, getRange, getResource, getSocketAddr, getStringCollection, getStrings, getStrings, getTimeDuration, getTrimmed, getTrimmed, getTrimmedStringCollection, getTrimmedStrings, getTrimmedStrings, getValByRegex, isDeprecated, main, readFields, reloadConfiguration, set, setBoolean, setBooleanIfUnset, setClass, setClassLoader, setDouble, setEnum, setFloat, setIfUnset, setInt, setLong, setPattern, setQuietMode, setSocketAddr, setStrings, setTimeDuration, unset, updateConnectAddr, 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)
Get the value of the name. If the key is deprecated, it returns the value of the first key which replaces the deprecated key and is not null. If no such property exists, then defaultValue is returned. The CompooundConfiguration does not do property substitution. To do so we need Configuration.getProps to be protected or package visible. Though in hadoop2 it is protected, in hadoop1 the method is private and not accessible. All of the get* methods call this overridden get method.

Overrides:
get in class org.apache.hadoop.conf.Configuration
Parameters:
name - property name.
defaultValue - default value.
Returns:
property value, or defaultValue if the property doesn't exist.

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

clear

public void clear()
These methods are unsupported, and no code using CompoundConfiguration depend upon them. Quickly abort upon any attempts to use them.

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

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 © 2015 The Apache Software Foundation. All Rights Reserved.