Class ReconfigurableBase

java.lang.Object
org.apache.hadoop.conf.Configured
org.apache.hadoop.conf.ReconfigurableBase
All Implemented Interfaces:
Configurable, Reconfigurable

public abstract class ReconfigurableBase extends Configured implements Reconfigurable
Utility base class for implementing the Reconfigurable interface. Subclasses should override reconfigurePropertyImpl to change individual properties and getReconfigurableProperties to get all properties that can be changed at run time.
  • Constructor Details

    • ReconfigurableBase

      public ReconfigurableBase()
      Construct a ReconfigurableBase.
    • ReconfigurableBase

      public ReconfigurableBase(Configuration conf)
      Construct a ReconfigurableBase with the Configuration conf.
      Parameters:
      conf - configuration.
  • Method Details

    • setReconfigurationUtil

      @VisibleForTesting public void setReconfigurationUtil(ReconfigurationUtil ru)
    • getNewConf

      protected abstract Configuration getNewConf()
      Create a new configuration.
      Returns:
      configuration.
    • getChangedProperties

      @VisibleForTesting public Collection<ReconfigurationUtil.PropertyChange> getChangedProperties(Configuration newConf, Configuration oldConf)
    • startReconfigurationTask

      public void startReconfigurationTask() throws IOException
      Start a reconfiguration task to reload configuration in background.
      Throws:
      IOException - raised on errors performing I/O.
    • getReconfigurationTaskStatus

      public ReconfigurationTaskStatus getReconfigurationTaskStatus()
    • shutdownReconfigurationTask

      public void shutdownReconfigurationTask()
    • reconfigureProperty

      public final void reconfigureProperty(String property, String newVal) throws ReconfigurationException
      Change a configuration property on this object to the value specified. Change a configuration property on this object to the value specified and return the previous value that the configuration property was set to (or null if it was not previously set). If newVal is null, set the property to its default value; This method makes the change to this objects Configuration and calls reconfigurePropertyImpl to update internal data structures. This method cannot be overridden, subclasses should instead override reconfigurePropertyImpl.
      Specified by:
      reconfigureProperty in interface Reconfigurable
      Parameters:
      property - property name.
      newVal - new value.
      Throws:
      ReconfigurationException - if there was an error applying newVal. If the property cannot be changed, throw a ReconfigurationException.
    • getReconfigurableProperties

      public abstract Collection<String> getReconfigurableProperties()
      Return all the properties that can be changed at run time. Subclasses must override this.
      Specified by:
      getReconfigurableProperties in interface Reconfigurable
      Returns:
      reconfigurable propertys.
    • isPropertyReconfigurable

      public boolean isPropertyReconfigurable(String property)
      Return whether a given property is changeable at run time. If isPropertyReconfigurable returns true for a property, then changeConf should not throw an exception when changing this property. Subclasses may wish to override this with a more efficient implementation.
      Specified by:
      isPropertyReconfigurable in interface Reconfigurable
      Parameters:
      property - property name.
      Returns:
      true if property reconfigurable; false if not.
    • reconfigurePropertyImpl

      protected abstract String reconfigurePropertyImpl(String property, String newVal) throws ReconfigurationException
      Change a configuration property. Subclasses must override this. This method applies the change to all internal data structures derived from the configuration property that is being changed. If this object owns other Reconfigurable objects reconfigureProperty should be called recursively to make sure that the configuration of these objects are updated.
      Parameters:
      property - Name of the property that is being reconfigured.
      newVal - Proposed new value of the property.
      Returns:
      Effective new value of the property. This may be different from newVal.
      Throws:
      ReconfigurationException - if there was an error applying newVal.