Class DelegatingConfiguration

    • 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: Configuration
        Returns the value associated with the given key as a string. We encourage users and developers to always use ConfigOption for getting the configurations if possible, for its rich description, type, default-value and other supports. The string-key-based getter should only be used when ConfigOption is not applicable, e.g., the key is programmatically generated in runtime.
        Overrides:
        getString in class Configuration
        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
      • setString

        public void setString​(String key,
                              String value)
        Description copied from class: Configuration
        Adds the given key/value pair to the configuration object. We encourage users and developers to always use ConfigOption for setting the configurations if possible, for its rich description, type, default-value and other supports. The string-key-based setter should only be used when ConfigOption is not applicable, e.g., the key is programmatically generated in runtime.
        Overrides:
        setString in class Configuration
        Parameters:
        key - the key of the key/value pair to be added
        value - the value of the key/value pair to be added
      • getBytes

        public byte[] getBytes​(String key,
                               byte[] defaultValue)
        Description copied from class: Configuration
        Returns the value associated with the given key as a byte array.
        Overrides:
        getBytes in class Configuration
        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: Configuration
        Adds the given byte array to the configuration object. If key is null then nothing is added.
        Overrides:
        setBytes in class Configuration
        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: Configuration
        Returns the value associated with the given config option as a string.
        Overrides:
        getValue in class Configuration
        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: Configuration
        Returns the value associated with the given config option as an enum.
        Overrides:
        getEnum in class Configuration
        Parameters:
        enumClass - The return enum class
        configOption - The configuration option
      • addAll

        public void addAll​(Configuration other,
                           String prefix)
        Description copied from class: Configuration
        Adds all entries from the given configuration into this configuration. The keys are prepended with the given prefix.
        Overrides:
        addAll in class Configuration
        Parameters:
        other - The configuration whose entries are added to this configuration.
        prefix - The prefix to prepend.
      • keySet

        public Set<String> keySet()
        Description copied from class: Configuration
        Returns the keys of all key/value pairs stored inside this configuration object.
        Overrides:
        keySet in class Configuration
        Returns:
        the keys of all key/value pairs stored inside this configuration object
      • toFileWritableMap

        public Map<String,​String> toFileWritableMap()
        Description copied from class: Configuration
        Convert Config into a Map<String, String> representation.

        NOTE: This method is extracted from the Configuration.toMap() method and should be called when Config needs to be written to a file.

        This method ensures the value is properly escaped when writing the key-value pair to a standard YAML file.

        Overrides:
        toFileWritableMap in class Configuration
      • removeConfig

        public <T> boolean removeConfig​(ConfigOption<T> configOption)
        Description copied from class: Configuration
        Removes given config option from the configuration.
        Overrides:
        removeConfig in class Configuration
        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: Configuration
        Removes given key from the configuration.
        Overrides:
        removeKey in class Configuration
        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: Configuration
        Checks whether there is an entry with the specified key.
        Overrides:
        containsKey in class Configuration
        Parameters:
        key - key of entry
        Returns:
        true if the key is stored, false otherwise
      • contains

        public boolean contains​(ConfigOption<?> configOption)
        Description copied from class: Configuration
        Checks whether there is an entry for the given config option.
        Overrides:
        contains in class Configuration
        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: Configuration
        Please check the java doc of 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.

        Specified by:
        get in interface ReadableConfig
        Overrides:
        get in class Configuration
        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)
      • get

        public <T> T get​(ConfigOption<T> configOption,
                         T overrideDefault)
        Description copied from class: Configuration
        Returns the value associated with the given config option as a T. If no value is mapped under any key of the option, it returns the specified default instead of the option's default value.
        Overrides:
        get in class Configuration
        Parameters:
        configOption - The configuration option
        overrideDefault - 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
      • set

        public <T> Configuration set​(ConfigOption<T> option,
                                     T value)
        Description copied from interface: WritableConfig
        Stores a given value using the metadata included in the ConfigOption. The value should be readable back through ReadableConfig.
        Specified by:
        set in interface WritableConfig
        Overrides:
        set in class Configuration
        Type Parameters:
        T - type of the value to be stored
        Parameters:
        option - metadata information
        value - value to be stored
        Returns:
        instance of this configuration for fluent API