Class PinotConfiguration
- java.lang.Object
-
- org.apache.pinot.spi.env.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.
PinotConfigurationcurrently supports configuration loaded from the following sources :- Apache Commons
Configuration(seePinotConfiguration(Configuration)) - Generic key-value properties provided with a
Map(seePinotConfiguration(Map) - Environment variables (see
PinotConfiguration(Map, Map) PinotFSSpec(seePinotConfiguration(PinotFSSpec)
These different sources will all merged in an underlying
CompositeConfigurationfor 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. - Apache Commons
-
-
Field Summary
Fields Modifier and Type Field Description static StringCONFIG_PATHS_KEY
-
Constructor Summary
Constructors Constructor Description PinotConfiguration()Creates an empty instance.PinotConfiguration(Map<String,Object> baseProperties)Creates a new instance with existing properties provided through a map.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.PinotConfiguration(org.apache.commons.configuration.Configuration baseConfiguration)Builds a new instance out of an existing Apache CommonsConfigurationinstance.PinotConfiguration(PinotFSSpec pinotFSSpec)Helper constructor to create an instance from configurations found in a PinotFSSpec instance.
-
Method Summary
Modifier and Type Method Description voidaddProperty(String name, Object value)Deprecated.Configurations should be immutable.voidclearProperty(String name)Delete a property value in memory.PinotConfigurationclone()Creates a new instance ofPinotConfigurationby closing the underlyingCompositeConfiguration.booleancontainsKey(String key)Check if the configuration contains the specified key after being sanitized.List<String>getKeys()StringgetProperty(String name)Retrieves a String value with the given property name.booleangetProperty(String name, boolean defaultValue)Retrieves a boolean value with the given property name.doublegetProperty(String name, double defaultValue)Retrieves a double value with the given property name.intgetProperty(String name, int defaultValue)Retrieves a integer value with the given property name.longgetProperty(String name, long defaultValue)Retrieves a long value with the given property name.<T> TgetProperty(String name, Class<T> returnType)Retrieves a typed value with the given property name.StringgetProperty(String name, String defaultValue)Retrieves a String value with the given property name.List<String>getProperty(String name, List<String> defaultValues)Retrieves a list of String values with the given property name.ObjectgetRawProperty(String name)Returns the raw object stored within the underlyingCompositeConfiguration.ObjectgetRawProperty(String name, Object defaultValue)Returns the raw object stored within the underlyingCompositeConfiguration.booleanisEmpty()voidsetProperty(String name, Object value)Overwrites a property value in memory.PinotConfigurationsubset(String prefix)Creates a copy of the configuration only containing properties matching a property prefix.Map<String,Object>toMap()StringtoString()
-
-
-
Field Detail
-
CONFIG_PATHS_KEY
public static final String CONFIG_PATHS_KEY
- See Also:
- Constant Field Values
-
-
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 CommonsConfigurationinstance. 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 existingConfigurationfor 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 aMap.
-
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. SeePinotConfigurationfor further details.- Parameters:
baseProperties- with highest precedences (e.g. CLI arguments)environmentVariables- as aMap. Can be provided withSystemEnvironment
-
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 newPinotConfiguration(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
-
clone
public PinotConfiguration clone()
Creates a new instance ofPinotConfigurationby closing the underlyingCompositeConfiguration. Useful to mutate configurationsPinotConfigurationwithout impacting the original configurations.- Overrides:
clonein classObject- Returns:
- a new
PinotConfigurationinstance with a clonedCompositeConfiguration.
-
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. SeePinotConfigurationfor 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. SeePinotConfigurationfor 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. SeePinotConfigurationfor 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. SeePinotConfigurationfor 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. SeePinotConfigurationfor 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. SeePinotConfigurationfor 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. SeePinotConfigurationfor 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. SeePinotConfigurationfor 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 underlyingCompositeConfiguration. SeePinotConfigurationfor 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 underlyingCompositeConfiguration. SeePinotConfigurationfor 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
PinotConfigurationwill 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
PinotConfigurationinstance with
-
toMap
public Map<String,Object> toMap()
- Returns:
- a key-value
Mapfound in the underlyingCompositeConfiguration
-
isEmpty
public boolean isEmpty()
-
-