Class Configuration

    • Field Detail

      • confData

        protected final HashMap<String,​Object> confData
        Stores the concrete key/value pairs of this configuration object.
    • Constructor Detail

      • Configuration

        public Configuration()
        Creates a new empty configuration.
      • Configuration

        public Configuration​(Configuration other)
        Creates a new configuration with the copy of the given configuration.
        Parameters:
        other - The configuration to copy the entries from.
    • Method Detail

      • fromMap

        public static Configuration fromMap​(Map<String,​String> map)
        Creates a new configuration that is initialized with the options of the given map.
      • getClass

        public <T> Class<T> getClass​(String key,
                                     Class<? extends T> defaultValue,
                                     ClassLoader classLoader)
                              throws ClassNotFoundException
        Returns the class associated with the given key as a string.
        Type Parameters:
        T - The type of the class to return.
        Parameters:
        key - The key pointing to the associated value
        defaultValue - The optional default value returned if no entry exists
        classLoader - 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
      • getString

        @Deprecated
        public String getString​(String key,
                                String defaultValue)
        Returns the value associated with the given key as a string.
        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
      • getString

        @PublicEvolving
        public String getString​(ConfigOption<String> configOption)
        Returns the value associated with the given config option as a string.
        Parameters:
        configOption - The configuration option
        Returns:
        the (default) value associated with the given config option
      • getString

        @PublicEvolving
        public String getString​(ConfigOption<String> configOption,
                                String overrideDefault)
        Returns 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.
        Parameters:
        configOption - The configuration option
        Returns:
        the (default) value associated with the given config option
      • setString

        public void setString​(String key,
                              String value)
        Adds the given key/value pair to the configuration object.
        Parameters:
        key - the key of the key/value pair to be added
        value - the value of the key/value pair to be added
      • setString

        @PublicEvolving
        public void setString​(ConfigOption<String> key,
                              String value)
        Adds the given value to the configuration object. The main key of the config option will be used to map the value.
        Parameters:
        key - the option specifying the key to be added
        value - the value of the key/value pair to be added
      • getInteger

        @Deprecated
        public int getInteger​(String key,
                              int defaultValue)
        Returns the value associated with the given key as an integer.
        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
      • getInteger

        @PublicEvolving
        public int getInteger​(ConfigOption<Integer> configOption)
        Returns the value associated with the given config option as an integer.
        Parameters:
        configOption - The configuration option
        Returns:
        the (default) value associated with the given config option
      • getInteger

        @PublicEvolving
        public int getInteger​(ConfigOption<Integer> configOption,
                              int overrideDefault)
        Returns 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.
        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
      • setInteger

        public void setInteger​(String key,
                               int value)
        Adds the given key/value pair to the configuration object.
        Parameters:
        key - the key of the key/value pair to be added
        value - the value of the key/value pair to be added
      • setInteger

        @PublicEvolving
        public void setInteger​(ConfigOption<Integer> key,
                               int value)
        Adds the given value to the configuration object. The main key of the config option will be used to map the value.
        Parameters:
        key - the option specifying the key to be added
        value - the value of the key/value pair to be added
      • getLong

        @Deprecated
        public long getLong​(String key,
                            long defaultValue)
        Returns the value associated with the given key as a long.
        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
      • getLong

        @PublicEvolving
        public long getLong​(ConfigOption<Long> configOption)
        Returns the value associated with the given config option as a long integer.
        Parameters:
        configOption - The configuration option
        Returns:
        the (default) value associated with the given config option
      • getLong

        @PublicEvolving
        public long getLong​(ConfigOption<Long> configOption,
                            long overrideDefault)
        Returns 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.
        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
      • setLong

        public void setLong​(String key,
                            long value)
        Adds the given key/value pair to the configuration object.
        Parameters:
        key - the key of the key/value pair to be added
        value - the value of the key/value pair to be added
      • setLong

        @PublicEvolving
        public void setLong​(ConfigOption<Long> key,
                            long value)
        Adds the given value to the configuration object. The main key of the config option will be used to map the value.
        Parameters:
        key - the option specifying the key to be added
        value - the value of the key/value pair to be added
      • getBoolean

        @Deprecated
        public boolean getBoolean​(String key,
                                  boolean defaultValue)
        Returns the value associated with the given key as a boolean.
        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
      • getBoolean

        @PublicEvolving
        public boolean getBoolean​(ConfigOption<Boolean> configOption)
        Returns the value associated with the given config option as a boolean.
        Parameters:
        configOption - The configuration option
        Returns:
        the (default) value associated with the given config option
      • getBoolean

        @PublicEvolving
        public boolean getBoolean​(ConfigOption<Boolean> configOption,
                                  boolean overrideDefault)
        Returns 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.
        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
      • setBoolean

        public void setBoolean​(String key,
                               boolean value)
        Adds the given key/value pair to the configuration object.
        Parameters:
        key - the key of the key/value pair to be added
        value - the value of the key/value pair to be added
      • setBoolean

        @PublicEvolving
        public void setBoolean​(ConfigOption<Boolean> key,
                               boolean value)
        Adds the given value to the configuration object. The main key of the config option will be used to map the value.
        Parameters:
        key - the option specifying the key to be added
        value - the value of the key/value pair to be added
      • getFloat

        @Deprecated
        public float getFloat​(String key,
                              float defaultValue)
        Returns the value associated with the given key as a float.
        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
      • getFloat

        @PublicEvolving
        public float getFloat​(ConfigOption<Float> configOption)
        Returns the value associated with the given config option as a float.
        Parameters:
        configOption - The configuration option
        Returns:
        the (default) value associated with the given config option
      • getFloat

        @PublicEvolving
        public float getFloat​(ConfigOption<Float> configOption,
                              float overrideDefault)
        Returns 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.
        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
      • setFloat

        public void setFloat​(String key,
                             float value)
        Adds the given key/value pair to the configuration object.
        Parameters:
        key - the key of the key/value pair to be added
        value - the value of the key/value pair to be added
      • setFloat

        @PublicEvolving
        public void setFloat​(ConfigOption<Float> key,
                             float value)
        Adds the given value to the configuration object. The main key of the config option will be used to map the value.
        Parameters:
        key - the option specifying the key to be added
        value - the value of the key/value pair to be added
      • getDouble

        @Deprecated
        public double getDouble​(String key,
                                double defaultValue)
        Returns the value associated with the given key as a double.
        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
      • getDouble

        @PublicEvolving
        public double getDouble​(ConfigOption<Double> configOption)
        Returns the value associated with the given config option as a double.
        Parameters:
        configOption - The configuration option
        Returns:
        the (default) value associated with the given config option
      • getDouble

        @PublicEvolving
        public double getDouble​(ConfigOption<Double> configOption,
                                double overrideDefault)
        Returns the value associated with the given config option as a double. If no value is mapped under any key of the option, it returns the specified default instead of the option's default value.
        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
      • setDouble

        public void setDouble​(String key,
                              double value)
        Adds the given key/value pair to the configuration object.
        Parameters:
        key - the key of the key/value pair to be added
        value - the value of the key/value pair to be added
      • setDouble

        @PublicEvolving
        public void setDouble​(ConfigOption<Double> key,
                              double value)
        Adds the given value to the configuration object. The main key of the config option will be used to map the value.
        Parameters:
        key - the option specifying the key to be added
        value - the value of the key/value pair to be added
      • getBytes

        public byte[] getBytes​(String key,
                               byte[] defaultValue)
        Returns the value associated with the given key as a byte array.
        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)
        Adds the given byte array to the configuration object. If key is null then nothing is added.
        Parameters:
        key - The key under which the bytes are added.
        bytes - The bytes to be added.
      • getValue

        @PublicEvolving
        public String getValue​(ConfigOption<?> configOption)
        Returns the value associated with the given config option as a string.
        Parameters:
        configOption - The configuration option
        Returns:
        the (default) value associated with the given config option
      • getEnum

        @PublicEvolving
        public <T extends Enum<T>> T getEnum​(Class<T> enumClass,
                                             ConfigOption<String> configOption)
        Returns the value associated with the given config option as an enum.
        Parameters:
        enumClass - The return enum class
        configOption - The configuration option
        Throws:
        IllegalArgumentException - If the string associated with the given config option cannot be parsed as a value of the provided enum class.
      • keySet

        public Set<String> keySet()
        Returns the keys of all key/value pairs stored inside this configuration object.
        Returns:
        the keys of all key/value pairs stored inside this configuration object
      • addAllToProperties

        public void addAllToProperties​(Properties props)
        Adds all entries in this Configuration to the given Properties.
      • addAll

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

        public boolean containsKey​(String key)
        Checks whether there is an entry with the specified key.
        Parameters:
        key - key of entry
        Returns:
        true if the key is stored, false otherwise
      • contains

        @PublicEvolving
        public boolean contains​(ConfigOption<?> configOption)
        Checks whether there is an entry for the given config option.
        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)
        Please check the java doc of 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
        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)
      • 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
        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
      • removeConfig

        public <T> boolean removeConfig​(ConfigOption<T> configOption)
        Removes given config option from the 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)
        Removes given key from the configuration.
        Parameters:
        key - key of a config option to remove
        Returns:
        true is config has been removed, false otherwise
      • read

        public void read​(DataInputView in)
                  throws IOException
        Description copied from interface: IOReadableWritable
        Reads the object's internal data from the given data input view.
        Specified by:
        read in interface IOReadableWritable
        Parameters:
        in - the input view to read the data from
        Throws:
        IOException - thrown if any error occurs while reading from the input stream