Class ConfigurationManager

java.lang.Object
org.apache.hadoop.hbase.conf.ConfigurationManager

@Private @Evolving public class ConfigurationManager extends Object
Maintains the set of all the classes which would like to get notified when the Configuration is reloaded from the disk in the Online Configuration Change mechanism, which lets you update certain configuration properties on-the-fly, without having to restart the cluster.

If a class has configuration properties which you would like to be able to change on-the-fly, do the following:

  1. Implement the ConfigurationObserver interface. This would require you to implement the ConfigurationObserver.onConfigurationChange(Configuration) method. This is a callback that is used to notify your class' instance that the configuration has changed. In this method, you need to check if the new values for the properties that are of interest to your class are different from the cached values. If yes, update them.
    However, be careful with this. Certain properties might be trivially mutable online, but others might not. Two properties might be trivially mutable by themselves, but not when changed together. For example, if a method uses properties "a" and "b" to make some decision, and is running in parallel when the notifyOnChange() method updates "a", but hasn't yet updated "b", it might make a decision on the basis of a new value of "a", and an old value of "b". This might introduce subtle bugs. This needs to be dealt on a case-by-case basis, and this class does not provide any protection from such cases.
  2. Register the appropriate instance of the class with the ConfigurationManager instance, using the registerObserver(ConfigurationObserver) method. Be careful not to do this in the constructor, as you might cause the 'this' reference to escape. Use a factory method, or an initialize() method which is called after the construction of the object.
  3. Deregister the instance using the deregisterObserver(ConfigurationObserver) method when it is going out of scope. In case you are not able to do that for any reason, it is still okay, since entries for dead observers are automatically collected during GC. But nonetheless, it is still a good practice to deregister your observer, whenever possible.