public final class DelegatingConfiguration extends Configuration
confData
Constructor and 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.
|
Modifier and Type | Method and Description |
---|---|
void |
addAll(Configuration other) |
void |
addAll(Configuration other,
String prefix)
Adds all entries from the given configuration into this configuration.
|
void |
addAllToProperties(Properties props)
Adds all entries in this
Configuration to the given Properties . |
Configuration |
clone() |
boolean |
contains(ConfigOption<?> configOption)
Checks whether there is an entry for the given config option.
|
boolean |
containsKey(String key)
Checks whether there is an entry with the specified key.
|
boolean |
equals(Object obj) |
<T> T |
get(ConfigOption<T> option)
Please check the java doc of
Configuration.getRawValueFromOption(ConfigOption) . |
boolean |
getBoolean(ConfigOption<Boolean> configOption)
Returns the value associated with the given config option as a boolean.
|
boolean |
getBoolean(ConfigOption<Boolean> configOption,
boolean overrideDefault)
Returns the value associated with the given config option as a boolean.
|
boolean |
getBoolean(String key,
boolean defaultValue)
Returns the value associated with the given key 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.
|
double |
getDouble(ConfigOption<Double> configOption)
Returns the value associated with the given config option as a
double . |
double |
getDouble(ConfigOption<Double> configOption,
double overrideDefault)
Returns the value associated with the given config option as a
double . |
double |
getDouble(String key,
double defaultValue)
Returns the value associated with the given key as a double.
|
<T extends Enum<T>> |
getEnum(Class<T> enumClass,
ConfigOption<String> configOption)
Returns the value associated with the given config option as an enum.
|
float |
getFloat(ConfigOption<Float> configOption)
Returns the value associated with the given config option as a float.
|
float |
getFloat(ConfigOption<Float> configOption,
float overrideDefault)
Returns the value associated with the given config option as a float.
|
float |
getFloat(String key,
float defaultValue)
Returns the value associated with the given key as a float.
|
int |
getInteger(ConfigOption<Integer> configOption)
Returns the value associated with the given config option as an integer.
|
int |
getInteger(ConfigOption<Integer> configOption,
int overrideDefault)
Returns the value associated with the given config option as an integer.
|
int |
getInteger(String key,
int defaultValue)
Returns the value associated with the given key as an integer.
|
long |
getLong(ConfigOption<Long> configOption)
Returns the value associated with the given config option as a long integer.
|
long |
getLong(ConfigOption<Long> configOption,
long overrideDefault)
Returns the value associated with the given config option as a long integer.
|
long |
getLong(String key,
long defaultValue)
Returns the value associated with the given key as a long.
|
<T> Optional<T> |
getOptional(ConfigOption<T> option)
Reads a value using the metadata included in
ConfigOption . |
String |
getString(ConfigOption<String> configOption)
Returns the value associated with the given config option as a string.
|
String |
getString(ConfigOption<String> configOption,
String overrideDefault)
Returns the value associated with the given config option as a string.
|
String |
getString(String key,
String defaultValue)
Returns the value associated with the given key as a string.
|
String |
getValue(ConfigOption<?> configOption)
Returns the value associated with the given config option as a string.
|
int |
hashCode() |
Set<String> |
keySet()
Returns the keys of all key/value pairs stored inside this configuration object.
|
void |
read(DataInputView in)
Reads the object's internal data from the given data input view.
|
<T> boolean |
removeConfig(ConfigOption<T> configOption)
Removes given config option from the configuration.
|
boolean |
removeKey(String key)
Removes given key from the configuration.
|
<T> Configuration |
set(ConfigOption<T> option,
T value)
Stores a given value using the metadata included in the
ConfigOption . |
void |
setBoolean(ConfigOption<Boolean> key,
boolean value)
Adds the given value to the configuration object.
|
void |
setBoolean(String key,
boolean value)
Adds the given key/value pair to the configuration object.
|
void |
setBytes(String key,
byte[] bytes)
Adds the given byte array to the configuration object.
|
void |
setClass(String key,
Class<?> klazz)
Adds the given key/value pair to the configuration object.
|
void |
setDouble(ConfigOption<Double> key,
double value)
Adds the given value to the configuration object.
|
void |
setDouble(String key,
double value)
Adds the given key/value pair to the configuration object.
|
void |
setFloat(ConfigOption<Float> key,
float value)
Adds the given value to the configuration object.
|
void |
setFloat(String key,
float value)
Adds the given key/value pair to the configuration object.
|
void |
setInteger(ConfigOption<Integer> key,
int value)
Adds the given value to the configuration object.
|
void |
setInteger(String key,
int value)
Adds the given key/value pair to the configuration object.
|
void |
setLong(ConfigOption<Long> key,
long value)
Adds the given value to the configuration object.
|
void |
setLong(String key,
long value)
Adds the given key/value pair to the configuration object.
|
void |
setString(ConfigOption<String> key,
String value)
Adds the given value to the configuration object.
|
void |
setString(String key,
String value)
Adds the given key/value pair to the configuration object.
|
Map<String,String> |
toMap()
Convert UserConfig into a
Map<String, String> representation. |
String |
toString() |
void |
write(DataOutputView out)
Writes the object's internal data to the given data output view.
|
fromMap
public DelegatingConfiguration()
public DelegatingConfiguration(Configuration backingConfig, String prefix)
backingConfig
- The configuration holding the actual config data.prefix
- The prefix prepended to all config keys.public String getString(String key, String defaultValue)
Configuration
getString
in class Configuration
key
- the key pointing to the associated valuedefaultValue
- the default value which is returned in case there is no value associated
with the given keypublic String getString(ConfigOption<String> configOption)
Configuration
getString
in class Configuration
configOption
- The configuration optionpublic String getString(ConfigOption<String> configOption, String overrideDefault)
Configuration
getString
in class Configuration
configOption
- The configuration optionpublic void setString(String key, String value)
Configuration
setString
in class Configuration
key
- the key of the key/value pair to be addedvalue
- the value of the key/value pair to be addedpublic void setString(ConfigOption<String> key, String value)
Configuration
setString
in class Configuration
key
- the option specifying the key to be addedvalue
- the value of the key/value pair to be addedpublic <T> Class<T> getClass(String key, Class<? extends T> defaultValue, ClassLoader classLoader) throws ClassNotFoundException
Configuration
getClass
in class Configuration
T
- The type of the class to return.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.ClassNotFoundException
public void setClass(String key, Class<?> klazz)
Configuration
Configuration.getClass(String, Class, ClassLoader)
if it is in the scope of the class
loader on the caller.setClass
in class Configuration
key
- The key of the pair to be addedklazz
- The value of the pair to be addedConfiguration.getClass(String, Class, ClassLoader)
public int getInteger(String key, int defaultValue)
Configuration
getInteger
in class Configuration
key
- the key pointing to the associated valuedefaultValue
- the default value which is returned in case there is no value associated
with the given keypublic int getInteger(ConfigOption<Integer> configOption)
Configuration
getInteger
in class Configuration
configOption
- The configuration optionpublic int getInteger(ConfigOption<Integer> configOption, int overrideDefault)
Configuration
getInteger
in class Configuration
configOption
- The configuration optionoverrideDefault
- The value to return if no value was mapper for any key of the optionpublic void setInteger(String key, int value)
Configuration
setInteger
in class Configuration
key
- the key of the key/value pair to be addedvalue
- the value of the key/value pair to be addedpublic void setInteger(ConfigOption<Integer> key, int value)
Configuration
setInteger
in class Configuration
key
- the option specifying the key to be addedvalue
- the value of the key/value pair to be addedpublic long getLong(String key, long defaultValue)
Configuration
getLong
in class Configuration
key
- the key pointing to the associated valuedefaultValue
- the default value which is returned in case there is no value associated
with the given keypublic long getLong(ConfigOption<Long> configOption)
Configuration
getLong
in class Configuration
configOption
- The configuration optionpublic long getLong(ConfigOption<Long> configOption, long overrideDefault)
Configuration
getLong
in class Configuration
configOption
- The configuration optionoverrideDefault
- The value to return if no value was mapper for any key of the optionpublic void setLong(String key, long value)
Configuration
setLong
in class Configuration
key
- the key of the key/value pair to be addedvalue
- the value of the key/value pair to be addedpublic void setLong(ConfigOption<Long> key, long value)
Configuration
setLong
in class Configuration
key
- the option specifying the key to be addedvalue
- the value of the key/value pair to be addedpublic boolean getBoolean(String key, boolean defaultValue)
Configuration
getBoolean
in class Configuration
key
- the key pointing to the associated valuedefaultValue
- the default value which is returned in case there is no value associated
with the given keypublic boolean getBoolean(ConfigOption<Boolean> configOption)
Configuration
getBoolean
in class Configuration
configOption
- The configuration optionpublic void setBoolean(String key, boolean value)
Configuration
setBoolean
in class Configuration
key
- the key of the key/value pair to be addedvalue
- the value of the key/value pair to be addedpublic void setBoolean(ConfigOption<Boolean> key, boolean value)
Configuration
setBoolean
in class Configuration
key
- the option specifying the key to be addedvalue
- the value of the key/value pair to be addedpublic boolean getBoolean(ConfigOption<Boolean> configOption, boolean overrideDefault)
Configuration
getBoolean
in class Configuration
configOption
- The configuration optionoverrideDefault
- The value to return if no value was mapper for any key of the optionpublic float getFloat(String key, float defaultValue)
Configuration
getFloat
in class Configuration
key
- the key pointing to the associated valuedefaultValue
- the default value which is returned in case there is no value associated
with the given keypublic float getFloat(ConfigOption<Float> configOption)
Configuration
getFloat
in class Configuration
configOption
- The configuration optionpublic float getFloat(ConfigOption<Float> configOption, float overrideDefault)
Configuration
getFloat
in class Configuration
configOption
- The configuration optionoverrideDefault
- The value to return if no value was mapper for any key of the optionpublic void setFloat(String key, float value)
Configuration
setFloat
in class Configuration
key
- the key of the key/value pair to be addedvalue
- the value of the key/value pair to be addedpublic void setFloat(ConfigOption<Float> key, float value)
Configuration
setFloat
in class Configuration
key
- the option specifying the key to be addedvalue
- the value of the key/value pair to be addedpublic double getDouble(String key, double defaultValue)
Configuration
getDouble
in class Configuration
key
- the key pointing to the associated valuedefaultValue
- the default value which is returned in case there is no value associated
with the given keypublic double getDouble(ConfigOption<Double> configOption)
Configuration
double
.getDouble
in class Configuration
configOption
- The configuration optionpublic double getDouble(ConfigOption<Double> configOption, double overrideDefault)
Configuration
double
. If no value is
mapped under any key of the option, it returns the specified default instead of the option's
default value.getDouble
in class Configuration
configOption
- The configuration optionoverrideDefault
- The value to return if no value was mapper for any key of the optionpublic void setDouble(String key, double value)
Configuration
setDouble
in class Configuration
key
- the key of the key/value pair to be addedvalue
- the value of the key/value pair to be addedpublic void setDouble(ConfigOption<Double> key, double value)
Configuration
setDouble
in class Configuration
key
- the option specifying the key to be addedvalue
- the value of the key/value pair to be addedpublic byte[] getBytes(String key, byte[] defaultValue)
Configuration
getBytes
in class Configuration
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.public void setBytes(String key, byte[] bytes)
Configuration
null
then
nothing is added.setBytes
in class Configuration
key
- The key under which the bytes are added.bytes
- The bytes to be added.public String getValue(ConfigOption<?> configOption)
Configuration
getValue
in class Configuration
configOption
- The configuration optionpublic <T extends Enum<T>> T getEnum(Class<T> enumClass, ConfigOption<String> configOption)
Configuration
getEnum
in class Configuration
enumClass
- The return enum classconfigOption
- The configuration optionpublic void addAllToProperties(Properties props)
Configuration
Configuration
to the given Properties
.addAllToProperties
in class Configuration
public void addAll(Configuration other)
addAll
in class Configuration
public void addAll(Configuration other, String prefix)
Configuration
addAll
in class Configuration
other
- The configuration whose entries are added to this configuration.prefix
- The prefix to prepend.public String toString()
toString
in class Configuration
public Set<String> keySet()
Configuration
keySet
in class Configuration
public Configuration clone()
clone
in class Configuration
public Map<String,String> toMap()
ExecutionConfig.GlobalJobParameters
Map<String, String>
representation. This can be used by
the runtime, for example for presenting the user config in the web frontend.toMap
in class Configuration
public <T> boolean removeConfig(ConfigOption<T> configOption)
Configuration
removeConfig
in class Configuration
T
- Type of the config optionconfigOption
- config option to removepublic boolean removeKey(String key)
Configuration
removeKey
in class Configuration
key
- key of a config option to removepublic boolean containsKey(String key)
Configuration
containsKey
in class Configuration
key
- key of entrypublic boolean contains(ConfigOption<?> configOption)
Configuration
contains
in class Configuration
configOption
- The configuration optionpublic <T> T get(ConfigOption<T> option)
Configuration
Configuration.getRawValueFromOption(ConfigOption)
. If no keys are
found in Configuration
, 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 Configuration
at runtime.
get
in interface ReadableConfig
get
in class Configuration
T
- type of the value to readoption
- metadata of the option to readReadableConfig.getOptional(ConfigOption)
public <T> Optional<T> getOptional(ConfigOption<T> option)
ReadableConfig
ConfigOption
. In contrast to ReadableConfig.get(ConfigOption)
returns Optional.empty()
if value not present.getOptional
in interface ReadableConfig
getOptional
in class Configuration
T
- type of the value to readoption
- metadata of the option to readOptional.empty()
if not foundReadableConfig.get(ConfigOption)
public <T> Configuration set(ConfigOption<T> option, T value)
WritableConfig
ConfigOption
. The value
should be readable back through ReadableConfig
.set
in interface WritableConfig
set
in class Configuration
T
- type of the value to be storedoption
- metadata informationvalue
- value to be storedpublic void read(DataInputView in) throws IOException
IOReadableWritable
read
in interface IOReadableWritable
read
in class Configuration
in
- the input view to read the data fromIOException
- thrown if any error occurs while reading from the input streampublic void write(DataOutputView out) throws IOException
IOReadableWritable
write
in interface IOReadableWritable
write
in class Configuration
out
- the output view to receive the data.IOException
- thrown if any error occurs while writing to the output streampublic int hashCode()
hashCode
in class Configuration
public boolean equals(Object obj)
equals
in class Configuration
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.