Package org.apache.flink.configuration
Class DelegatingConfiguration
- java.lang.Object
-
- org.apache.flink.api.common.ExecutionConfig.GlobalJobParameters
-
- org.apache.flink.configuration.Configuration
-
- org.apache.flink.configuration.DelegatingConfiguration
-
- All Implemented Interfaces:
Serializable,Cloneable,ReadableConfig,WritableConfig,IOReadableWritable
public final class DelegatingConfiguration extends Configuration
A configuration that manages a subset of keys with a common prefix from a given configuration.- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.apache.flink.configuration.Configuration
confData
-
-
Constructor Summary
Constructors Constructor Description DelegatingConfiguration()Default constructor for serialization.DelegatingConfiguration(Configuration backingConfig, String prefix)Creates a new delegating configuration which stores its key/value pairs in the given configuration using the specifies key prefix.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAll(Configuration other)voidaddAll(Configuration other, String prefix)Adds all entries from the given configuration into this configuration.voidaddAllToProperties(Properties props)Adds all entries in thisConfigurationto the givenProperties.Configurationclone()booleancontains(ConfigOption<?> configOption)Checks whether there is an entry for the given config option.booleancontainsKey(String key)Checks whether there is an entry with the specified key.booleanequals(Object obj)<T> Tget(ConfigOption<T> option)Please check the java doc ofConfiguration.getRawValueFromOption(ConfigOption).booleangetBoolean(String key, boolean defaultValue)Returns the value associated with the given key as a boolean.booleangetBoolean(ConfigOption<Boolean> configOption)Returns the value associated with the given config option as a boolean.booleangetBoolean(ConfigOption<Boolean> configOption, boolean overrideDefault)Returns the value associated with the given config option as a boolean.byte[]getBytes(String key, byte[] defaultValue)Returns the value associated with the given key as a byte array.<T> Class<T>getClass(String key, Class<? extends T> defaultValue, ClassLoader classLoader)Returns the class associated with the given key as a string.doublegetDouble(String key, double defaultValue)Returns the value associated with the given key as a double.doublegetDouble(ConfigOption<Double> configOption)Returns the value associated with the given config option as adouble.doublegetDouble(ConfigOption<Double> configOption, double overrideDefault)Returns the value associated with the given config option as adouble.<T extends Enum<T>>
TgetEnum(Class<T> enumClass, ConfigOption<String> configOption)Returns the value associated with the given config option as an enum.floatgetFloat(String key, float defaultValue)Returns the value associated with the given key as a float.floatgetFloat(ConfigOption<Float> configOption)Returns the value associated with the given config option as a float.floatgetFloat(ConfigOption<Float> configOption, float overrideDefault)Returns the value associated with the given config option as a float.intgetInteger(String key, int defaultValue)Returns the value associated with the given key as an integer.intgetInteger(ConfigOption<Integer> configOption)Returns the value associated with the given config option as an integer.intgetInteger(ConfigOption<Integer> configOption, int overrideDefault)Returns the value associated with the given config option as an integer.longgetLong(String key, long defaultValue)Returns the value associated with the given key as a long.longgetLong(ConfigOption<Long> configOption)Returns the value associated with the given config option as a long integer.longgetLong(ConfigOption<Long> configOption, long overrideDefault)Returns the value associated with the given config option as a long integer.<T> Optional<T>getOptional(ConfigOption<T> option)Reads a value using the metadata included inConfigOption.StringgetString(String key, String defaultValue)Returns the value associated with the given key as a string.StringgetString(ConfigOption<String> configOption)Returns the value associated with the given config option as a string.StringgetString(ConfigOption<String> configOption, String overrideDefault)Returns the value associated with the given config option as a string.StringgetValue(ConfigOption<?> configOption)Returns the value associated with the given config option as a string.inthashCode()Set<String>keySet()Returns the keys of all key/value pairs stored inside this configuration object.voidread(DataInputView in)Reads the object's internal data from the given data input view.<T> booleanremoveConfig(ConfigOption<T> configOption)Removes given config option from the configuration.booleanremoveKey(String key)Removes given key from the configuration.<T> Configurationset(ConfigOption<T> option, T value)Stores a given value using the metadata included in theConfigOption.voidsetBoolean(String key, boolean value)Adds the given key/value pair to the configuration object.voidsetBoolean(ConfigOption<Boolean> key, boolean value)Adds the given value to the configuration object.voidsetBytes(String key, byte[] bytes)Adds the given byte array to the configuration object.voidsetClass(String key, Class<?> klazz)Adds the given key/value pair to the configuration object.voidsetDouble(String key, double value)Adds the given key/value pair to the configuration object.voidsetDouble(ConfigOption<Double> key, double value)Adds the given value to the configuration object.voidsetFloat(String key, float value)Adds the given key/value pair to the configuration object.voidsetFloat(ConfigOption<Float> key, float value)Adds the given value to the configuration object.voidsetInteger(String key, int value)Adds the given key/value pair to the configuration object.voidsetInteger(ConfigOption<Integer> key, int value)Adds the given value to the configuration object.voidsetLong(String key, long value)Adds the given key/value pair to the configuration object.voidsetLong(ConfigOption<Long> key, long value)Adds the given value to the configuration object.voidsetString(String key, String value)Adds the given key/value pair to the configuration object.voidsetString(ConfigOption<String> key, String value)Adds the given value to the configuration object.Map<String,String>toMap()Convert UserConfig into aMap<String, String>representation.StringtoString()voidwrite(DataOutputView out)Writes the object's internal data to the given data output view.-
Methods inherited from class org.apache.flink.configuration.Configuration
fromMap
-
-
-
-
Constructor Detail
-
DelegatingConfiguration
public DelegatingConfiguration()
Default constructor for serialization. Creates an empty delegating configuration.
-
DelegatingConfiguration
public DelegatingConfiguration(Configuration backingConfig, String prefix)
Creates a new delegating configuration which stores its key/value pairs in the given configuration using the specifies key prefix.- Parameters:
backingConfig- The configuration holding the actual config data.prefix- The prefix prepended to all config keys.
-
-
Method Detail
-
getString
public String getString(String key, String defaultValue)
Description copied from class:ConfigurationReturns the value associated with the given key as a string.- Overrides:
getStringin classConfiguration- Parameters:
key- the key pointing to the associated valuedefaultValue- the default value which is returned in case there is no value associated with the given key- Returns:
- the (default) value associated with the given key
-
getString
public String getString(ConfigOption<String> configOption)
Description copied from class:ConfigurationReturns the value associated with the given config option as a string.- Overrides:
getStringin classConfiguration- Parameters:
configOption- The configuration option- Returns:
- the (default) value associated with the given config option
-
getString
public String getString(ConfigOption<String> configOption, String overrideDefault)
Description copied from class:ConfigurationReturns the value associated with the given config option as a string. If no value is mapped under any key of the option, it returns the specified default instead of the option's default value.- Overrides:
getStringin classConfiguration- Parameters:
configOption- The configuration option- Returns:
- the (default) value associated with the given config option
-
setString
public void setString(String key, String value)
Description copied from class:ConfigurationAdds the given key/value pair to the configuration object.- Overrides:
setStringin classConfiguration- Parameters:
key- the key of the key/value pair to be addedvalue- the value of the key/value pair to be added
-
setString
public void setString(ConfigOption<String> key, String value)
Description copied from class:ConfigurationAdds the given value to the configuration object. The main key of the config option will be used to map the value.- Overrides:
setStringin classConfiguration- Parameters:
key- the option specifying the key to be addedvalue- the value of the key/value pair to be added
-
getClass
public <T> Class<T> getClass(String key, Class<? extends T> defaultValue, ClassLoader classLoader) throws ClassNotFoundException
Description copied from class:ConfigurationReturns the class associated with the given key as a string.- Overrides:
getClassin classConfiguration- Type Parameters:
T- The type of the class to return.- Parameters:
key- The key pointing to the associated valuedefaultValue- The optional default value returned if no entry existsclassLoader- The class loader used to resolve the class.- Returns:
- The value associated with the given key, or the default value, if to entry for the key exists.
- Throws:
ClassNotFoundException
-
setClass
public void setClass(String key, Class<?> klazz)
Description copied from class:ConfigurationAdds the given key/value pair to the configuration object. The class can be retrieved by invokingConfiguration.getClass(String, Class, ClassLoader)if it is in the scope of the class loader on the caller.- Overrides:
setClassin classConfiguration- Parameters:
key- The key of the pair to be addedklazz- The value of the pair to be added- See Also:
Configuration.getClass(String, Class, ClassLoader)
-
getInteger
public int getInteger(String key, int defaultValue)
Description copied from class:ConfigurationReturns the value associated with the given key as an integer.- Overrides:
getIntegerin classConfiguration- Parameters:
key- the key pointing to the associated valuedefaultValue- the default value which is returned in case there is no value associated with the given key- Returns:
- the (default) value associated with the given key
-
getInteger
public int getInteger(ConfigOption<Integer> configOption)
Description copied from class:ConfigurationReturns the value associated with the given config option as an integer.- Overrides:
getIntegerin classConfiguration- Parameters:
configOption- The configuration option- Returns:
- the (default) value associated with the given config option
-
getInteger
public int getInteger(ConfigOption<Integer> configOption, int overrideDefault)
Description copied from class:ConfigurationReturns the value associated with the given config option as an integer. If no value is mapped under any key of the option, it returns the specified default instead of the option's default value.- Overrides:
getIntegerin classConfiguration- Parameters:
configOption- The configuration optionoverrideDefault- The value to return if no value was mapper for any key of the option- Returns:
- the configured value associated with the given config option, or the overrideDefault
-
setInteger
public void setInteger(String key, int value)
Description copied from class:ConfigurationAdds the given key/value pair to the configuration object.- Overrides:
setIntegerin classConfiguration- Parameters:
key- the key of the key/value pair to be addedvalue- the value of the key/value pair to be added
-
setInteger
public void setInteger(ConfigOption<Integer> key, int value)
Description copied from class:ConfigurationAdds the given value to the configuration object. The main key of the config option will be used to map the value.- Overrides:
setIntegerin classConfiguration- Parameters:
key- the option specifying the key to be addedvalue- the value of the key/value pair to be added
-
getLong
public long getLong(String key, long defaultValue)
Description copied from class:ConfigurationReturns the value associated with the given key as a long.- Overrides:
getLongin classConfiguration- Parameters:
key- the key pointing to the associated valuedefaultValue- the default value which is returned in case there is no value associated with the given key- Returns:
- the (default) value associated with the given key
-
getLong
public long getLong(ConfigOption<Long> configOption)
Description copied from class:ConfigurationReturns the value associated with the given config option as a long integer.- Overrides:
getLongin classConfiguration- Parameters:
configOption- The configuration option- Returns:
- the (default) value associated with the given config option
-
getLong
public long getLong(ConfigOption<Long> configOption, long overrideDefault)
Description copied from class:ConfigurationReturns the value associated with the given config option as a long integer. If no value is mapped under any key of the option, it returns the specified default instead of the option's default value.- Overrides:
getLongin classConfiguration- Parameters:
configOption- The configuration optionoverrideDefault- The value to return if no value was mapper for any key of the option- Returns:
- the configured value associated with the given config option, or the overrideDefault
-
setLong
public void setLong(String key, long value)
Description copied from class:ConfigurationAdds the given key/value pair to the configuration object.- Overrides:
setLongin classConfiguration- Parameters:
key- the key of the key/value pair to be addedvalue- the value of the key/value pair to be added
-
setLong
public void setLong(ConfigOption<Long> key, long value)
Description copied from class:ConfigurationAdds the given value to the configuration object. The main key of the config option will be used to map the value.- Overrides:
setLongin classConfiguration- Parameters:
key- the option specifying the key to be addedvalue- the value of the key/value pair to be added
-
getBoolean
public boolean getBoolean(String key, boolean defaultValue)
Description copied from class:ConfigurationReturns the value associated with the given key as a boolean.- Overrides:
getBooleanin classConfiguration- Parameters:
key- the key pointing to the associated valuedefaultValue- the default value which is returned in case there is no value associated with the given key- Returns:
- the (default) value associated with the given key
-
getBoolean
public boolean getBoolean(ConfigOption<Boolean> configOption)
Description copied from class:ConfigurationReturns the value associated with the given config option as a boolean.- Overrides:
getBooleanin classConfiguration- Parameters:
configOption- The configuration option- Returns:
- the (default) value associated with the given config option
-
setBoolean
public void setBoolean(String key, boolean value)
Description copied from class:ConfigurationAdds the given key/value pair to the configuration object.- Overrides:
setBooleanin classConfiguration- Parameters:
key- the key of the key/value pair to be addedvalue- the value of the key/value pair to be added
-
setBoolean
public void setBoolean(ConfigOption<Boolean> key, boolean value)
Description copied from class:ConfigurationAdds the given value to the configuration object. The main key of the config option will be used to map the value.- Overrides:
setBooleanin classConfiguration- Parameters:
key- the option specifying the key to be addedvalue- the value of the key/value pair to be added
-
getBoolean
public boolean getBoolean(ConfigOption<Boolean> configOption, boolean overrideDefault)
Description copied from class:ConfigurationReturns the value associated with the given config option as a boolean. If no value is mapped under any key of the option, it returns the specified default instead of the option's default value.- Overrides:
getBooleanin classConfiguration- Parameters:
configOption- The configuration optionoverrideDefault- The value to return if no value was mapper for any key of the option- Returns:
- the configured value associated with the given config option, or the overrideDefault
-
getFloat
public float getFloat(String key, float defaultValue)
Description copied from class:ConfigurationReturns the value associated with the given key as a float.- Overrides:
getFloatin classConfiguration- Parameters:
key- the key pointing to the associated valuedefaultValue- the default value which is returned in case there is no value associated with the given key- Returns:
- the (default) value associated with the given key
-
getFloat
public float getFloat(ConfigOption<Float> configOption)
Description copied from class:ConfigurationReturns the value associated with the given config option as a float.- Overrides:
getFloatin classConfiguration- Parameters:
configOption- The configuration option- Returns:
- the (default) value associated with the given config option
-
getFloat
public float getFloat(ConfigOption<Float> configOption, float overrideDefault)
Description copied from class:ConfigurationReturns the value associated with the given config option as a float. If no value is mapped under any key of the option, it returns the specified default instead of the option's default value.- Overrides:
getFloatin classConfiguration- Parameters:
configOption- The configuration optionoverrideDefault- The value to return if no value was mapper for any key of the option- Returns:
- the configured value associated with the given config option, or the overrideDefault
-
setFloat
public void setFloat(String key, float value)
Description copied from class:ConfigurationAdds the given key/value pair to the configuration object.- Overrides:
setFloatin classConfiguration- Parameters:
key- the key of the key/value pair to be addedvalue- the value of the key/value pair to be added
-
setFloat
public void setFloat(ConfigOption<Float> key, float value)
Description copied from class:ConfigurationAdds the given value to the configuration object. The main key of the config option will be used to map the value.- Overrides:
setFloatin classConfiguration- Parameters:
key- the option specifying the key to be addedvalue- the value of the key/value pair to be added
-
getDouble
public double getDouble(String key, double defaultValue)
Description copied from class:ConfigurationReturns the value associated with the given key as a double.- Overrides:
getDoublein classConfiguration- Parameters:
key- the key pointing to the associated valuedefaultValue- the default value which is returned in case there is no value associated with the given key- Returns:
- the (default) value associated with the given key
-
getDouble
public double getDouble(ConfigOption<Double> configOption)
Description copied from class:ConfigurationReturns the value associated with the given config option as adouble.- Overrides:
getDoublein classConfiguration- Parameters:
configOption- The configuration option- Returns:
- the (default) value associated with the given config option
-
getDouble
public double getDouble(ConfigOption<Double> configOption, double overrideDefault)
Description copied from class:ConfigurationReturns the value associated with the given config option as adouble. If no value is mapped under any key of the option, it returns the specified default instead of the option's default value.- Overrides:
getDoublein classConfiguration- Parameters:
configOption- The configuration optionoverrideDefault- The value to return if no value was mapper for any key of the option- Returns:
- the configured value associated with the given config option, or the overrideDefault
-
setDouble
public void setDouble(String key, double value)
Description copied from class:ConfigurationAdds the given key/value pair to the configuration object.- Overrides:
setDoublein classConfiguration- Parameters:
key- the key of the key/value pair to be addedvalue- the value of the key/value pair to be added
-
setDouble
public void setDouble(ConfigOption<Double> key, double value)
Description copied from class:ConfigurationAdds the given value to the configuration object. The main key of the config option will be used to map the value.- Overrides:
setDoublein classConfiguration- Parameters:
key- the option specifying the key to be addedvalue- the value of the key/value pair to be added
-
getBytes
public byte[] getBytes(String key, byte[] defaultValue)
Description copied from class:ConfigurationReturns the value associated with the given key as a byte array.- Overrides:
getBytesin classConfiguration- Parameters:
key- The key pointing to the associated value.defaultValue- The default value which is returned in case there is no value associated with the given key.- Returns:
- the (default) value associated with the given key.
-
setBytes
public void setBytes(String key, byte[] bytes)
Description copied from class:ConfigurationAdds the given byte array to the configuration object. If key isnullthen nothing is added.- Overrides:
setBytesin classConfiguration- Parameters:
key- The key under which the bytes are added.bytes- The bytes to be added.
-
getValue
public String getValue(ConfigOption<?> configOption)
Description copied from class:ConfigurationReturns the value associated with the given config option as a string.- Overrides:
getValuein classConfiguration- Parameters:
configOption- The configuration option- Returns:
- the (default) value associated with the given config option
-
getEnum
public <T extends Enum<T>> T getEnum(Class<T> enumClass, ConfigOption<String> configOption)
Description copied from class:ConfigurationReturns the value associated with the given config option as an enum.- Overrides:
getEnumin classConfiguration- Parameters:
enumClass- The return enum classconfigOption- The configuration option
-
addAllToProperties
public void addAllToProperties(Properties props)
Description copied from class:ConfigurationAdds all entries in thisConfigurationto the givenProperties.- Overrides:
addAllToPropertiesin classConfiguration
-
addAll
public void addAll(Configuration other)
- Overrides:
addAllin classConfiguration
-
addAll
public void addAll(Configuration other, String prefix)
Description copied from class:ConfigurationAdds all entries from the given configuration into this configuration. The keys are prepended with the given prefix.- Overrides:
addAllin classConfiguration- Parameters:
other- The configuration whose entries are added to this configuration.prefix- The prefix to prepend.
-
toString
public String toString()
- Overrides:
toStringin classConfiguration
-
keySet
public Set<String> keySet()
Description copied from class:ConfigurationReturns the keys of all key/value pairs stored inside this configuration object.- Overrides:
keySetin classConfiguration- Returns:
- the keys of all key/value pairs stored inside this configuration object
-
clone
public Configuration clone()
- Overrides:
clonein classConfiguration
-
toMap
public Map<String,String> toMap()
Description copied from class:ExecutionConfig.GlobalJobParametersConvert UserConfig into aMap<String, String>representation. This can be used by the runtime, for example for presenting the user config in the web frontend.- Overrides:
toMapin classConfiguration- Returns:
- Key/Value representation of the UserConfig
-
removeConfig
public <T> boolean removeConfig(ConfigOption<T> configOption)
Description copied from class:ConfigurationRemoves given config option from the configuration.- Overrides:
removeConfigin classConfiguration- Type Parameters:
T- Type of the config option- Parameters:
configOption- config option to remove- Returns:
- true is config has been removed, false otherwise
-
removeKey
public boolean removeKey(String key)
Description copied from class:ConfigurationRemoves given key from the configuration.- Overrides:
removeKeyin classConfiguration- Parameters:
key- key of a config option to remove- Returns:
- true is config has been removed, false otherwise
-
containsKey
public boolean containsKey(String key)
Description copied from class:ConfigurationChecks whether there is an entry with the specified key.- Overrides:
containsKeyin classConfiguration- Parameters:
key- key of entry- Returns:
- true if the key is stored, false otherwise
-
contains
public boolean contains(ConfigOption<?> configOption)
Description copied from class:ConfigurationChecks whether there is an entry for the given config option.- Overrides:
containsin classConfiguration- Parameters:
configOption- The configuration option- Returns:
- true if a valid (current or deprecated) key of the config option is stored, false otherwise
-
get
public <T> T get(ConfigOption<T> option)
Description copied from class:ConfigurationPlease check the java doc ofConfiguration.getRawValueFromOption(ConfigOption). If no keys are found inConfiguration, default value of the given option will return. Please make sure there will be at least one value available. Otherwise, a NPE will be thrown by Flink when the value is used.NOTE: current logic is not able to get the default value of the fallback key's ConfigOption, in case the given ConfigOption has no default value. If you want to use fallback key, please make sure its value could be found in
Configurationat runtime.- Specified by:
getin interfaceReadableConfig- Overrides:
getin classConfiguration- Type Parameters:
T- type of the value to read- Parameters:
option- metadata of the option to read- Returns:
- the value of the given option
- See Also:
ReadableConfig.getOptional(ConfigOption)
-
getOptional
public <T> Optional<T> getOptional(ConfigOption<T> option)
Description copied from interface:ReadableConfigReads a value using the metadata included inConfigOption. In contrast toReadableConfig.get(ConfigOption)returnsOptional.empty()if value not present.- Specified by:
getOptionalin interfaceReadableConfig- Overrides:
getOptionalin classConfiguration- Type Parameters:
T- type of the value to read- Parameters:
option- metadata of the option to read- Returns:
- read value or
Optional.empty()if not found - See Also:
ReadableConfig.get(ConfigOption)
-
set
public <T> Configuration set(ConfigOption<T> option, T value)
Description copied from interface:WritableConfigStores a given value using the metadata included in theConfigOption. The value should be readable back throughReadableConfig.- Specified by:
setin interfaceWritableConfig- Overrides:
setin classConfiguration- Type Parameters:
T- type of the value to be stored- Parameters:
option- metadata informationvalue- value to be stored- Returns:
- instance of this configuration for fluent API
-
read
public void read(DataInputView in) throws IOException
Description copied from interface:IOReadableWritableReads the object's internal data from the given data input view.- Specified by:
readin interfaceIOReadableWritable- Overrides:
readin classConfiguration- Parameters:
in- the input view to read the data from- Throws:
IOException- thrown if any error occurs while reading from the input stream
-
write
public void write(DataOutputView out) throws IOException
Description copied from interface:IOReadableWritableWrites the object's internal data to the given data output view.- Specified by:
writein interfaceIOReadableWritable- Overrides:
writein classConfiguration- Parameters:
out- the output view to receive the data.- Throws:
IOException- thrown if any error occurs while writing to the output stream
-
hashCode
public int hashCode()
- Overrides:
hashCodein classConfiguration
-
equals
public boolean equals(Object obj)
- Overrides:
equalsin classConfiguration
-
-