Class PinotConfiguration


  • public class PinotConfiguration
    extends Object

    Provides a configuration abstraction for Pinot to decouple services from configuration sources and frameworks.

    Pinot services may retreived configurations from PinotConfiguration independently from any source of configuration. PinotConfiguration currently supports configuration loaded from the following sources :

    These different sources will all merged in an underlying CompositeConfiguration for which all configuration keys will have been sanitized. Through this mechanism, properties can be configured and retrieved with kebab case, camel case, snake case and environment variable conventions.

    Property Note
    module.sub-module.alerts.email-address Kebab case, which is recommended for use in .properties and .yml files.
    module.subModule.alerts.emailAddress Standard camel case syntax.
    controller.sub_module.alerts.email_address Snake case notation, which is an alternative format for use in .properties and .yml files.
    PINOT_MODULE_SUBMODULE_ALERTS_EMAILADDRESS Upper case format, which is recommended when using system environment variables.
    • Constructor Detail

      • PinotConfiguration

        public PinotConfiguration()
        Creates an empty instance.
      • PinotConfiguration

        public PinotConfiguration​(org.apache.commons.configuration.Configuration baseConfiguration)
        Builds a new instance out of an existing Apache Commons Configuration instance. Will apply property key sanitization to enable relaxed binding. Properties from the base configuration will be copied and won't be linked.
        Parameters:
        baseConfiguration - an existing Configuration for which all properties will be duplicated and sanitized for relaxed binding.
      • PinotConfiguration

        public PinotConfiguration​(Map<String,​Object> baseProperties)
        Creates a new instance with existing properties provided through a map.
        Parameters:
        baseProperties - to provide programmatically through a Map.
      • PinotConfiguration

        public PinotConfiguration​(Map<String,​Object> baseProperties,
                                  Map<String,​String> environmentVariables)
        Creates a new instance with existing properties provided through a map as well as environment variables. Base properties will have priority offers properties defined in environment variables. Keys will be sanitized for relaxed binding. See PinotConfiguration for further details.
        Parameters:
        baseProperties - with highest precedences (e.g. CLI arguments)
        environmentVariables - as a Map. Can be provided with SystemEnvironment
      • PinotConfiguration

        public PinotConfiguration​(PinotFSSpec pinotFSSpec)
        Helper constructor to create an instance from configurations found in a PinotFSSpec instance. Intended for use by Job Runners
        Parameters:
        pinotFSSpec -
    • Method Detail

      • addProperty

        public void addProperty​(String name,
                                Object value)
        Deprecated.
        Configurations should be immutable. Prefer creating a new PinotConfiguration(org.apache.pinot.spi.ingestion.batch.spec.PinotFSSpec) with base properties to overwrite properties.
        Overwrites a property value in memory.
        Parameters:
        name - of the property to append in memory. Applies relaxed binding on the property name.
        value - to overwrite in memory
      • containsKey

        public boolean containsKey​(String key)
        Check if the configuration contains the specified key after being sanitized.
        Parameters:
        key - to sanitized and lookup
        Returns:
        true if key exists.
      • getKeys

        public List<String> getKeys()
        Returns:
        all the sanitized keys defined in the underlying CompositeConfiguration.
      • getProperty

        public String getProperty​(String name)
        Retrieves a String value with the given property name. See PinotConfiguration for supported key naming conventions. If multiple properties exists with the same key, all values will be joined as a comma separated String.
        Parameters:
        name - of the property to retrieve a value. Property name will be sanitized.
        Returns:
        the property String value. Null if missing.
      • getProperty

        public boolean getProperty​(String name,
                                   boolean defaultValue)
        Retrieves a boolean value with the given property name. See PinotConfiguration for supported key naming conventions.
        Parameters:
        name - of the property to retrieve a value. Property name will be sanitized.
        Returns:
        the property boolean value. Fallback to default value if missing.
      • getProperty

        public <T> T getProperty​(String name,
                                 Class<T> returnType)
        Retrieves a typed value with the given property name. See PinotConfiguration for supported key naming conventions.
        Parameters:
        name - of the property to retrieve a value. Property name will be sanitized.
        returnType - a class reference of the value type.
        Returns:
        the typed configuration value. Null if missing.
      • getProperty

        public double getProperty​(String name,
                                  double defaultValue)
        Retrieves a double value with the given property name. See PinotConfiguration for supported key naming conventions.
        Parameters:
        name - of the property to retrieve a value. Property name will be sanitized.
        Returns:
        the property double value. Fallback to default value if missing.
      • getProperty

        public int getProperty​(String name,
                               int defaultValue)
        Retrieves a integer value with the given property name. See PinotConfiguration for supported key naming conventions.
        Parameters:
        name - of the property to retrieve a value. Property name will be sanitized.
        Returns:
        the property integer value. Fallback to default value if missing.
      • getProperty

        public List<String> getProperty​(String name,
                                        List<String> defaultValues)
        Retrieves a list of String values with the given property name. See PinotConfiguration for supported key naming conventions.
        Parameters:
        name - of the property to retrieve a list of values. Property name will be sanitized.
        Returns:
        the property String value. Fallback to the provided default values if no property is found.
      • getProperty

        public long getProperty​(String name,
                                long defaultValue)
        Retrieves a long value with the given property name. See PinotConfiguration for supported key naming conventions.
        Parameters:
        name - of the property to retrieve a value. Property name will be sanitized.
        Returns:
        the property long value. Fallback to default value if missing.
      • getProperty

        public String getProperty​(String name,
                                  String defaultValue)
        Retrieves a String value with the given property name. See PinotConfiguration for supported key naming conventions.
        Parameters:
        name - of the property to retrieve a value. Property name will be sanitized.
        Returns:
        the property String value. Fallback to default value if missing.
      • getRawProperty

        public Object getRawProperty​(String name)
        Returns the raw object stored within the underlying CompositeConfiguration. See PinotConfiguration for supported key naming conventions.
        Parameters:
        name - of the property to retrieve a raw object value. Property name will be sanitized.
        Returns:
        the object referenced. Null if key is not found.
      • getRawProperty

        public Object getRawProperty​(String name,
                                     Object defaultValue)
        Returns the raw object stored within the underlying CompositeConfiguration. See PinotConfiguration for supported key naming conventions.
        Parameters:
        name - of the property to retrieve a raw object value. Property name will be sanitized.
        Returns:
        the object referenced. Fallback to provided default value if key is not found.
      • setProperty

        public void setProperty​(String name,
                                Object value)
        Overwrites a property value in memory.
        Parameters:
        name - of the property to overwrite in memory. Applies relaxed binding on the property name.
        value - to overwrite in memory
      • clearProperty

        public void clearProperty​(String name)
        Delete a property value in memory.
        Parameters:
        name - of the property to remove in memory. Applies relaxed binding on the property name.
      • subset

        public PinotConfiguration subset​(String prefix)

        Creates a copy of the configuration only containing properties matching a property prefix. Changes made on the source PinotConfiguration will not be available in the subset instance since properties are copied.

        The prefix is removed from the keys in the subset. See Configuration.subset(String) for further details.

        Parameters:
        prefix - of the properties to copy. Applies relaxed binding on the properties prefix.
        Returns:
        a new PinotConfiguration instance with
      • toMap

        public Map<String,​Object> toMap()
        Returns:
        a key-value Map found in the underlying CompositeConfiguration
      • isEmpty

        public boolean isEmpty()