Class ConfigurationUtils


  • public class ConfigurationUtils
    extends Object
    Utility class for Configuration related helper functions.
    • Method Detail

      • parseTempDirectories

        @Nonnull
        public static String[] parseTempDirectories​(Configuration configuration)
        Extracts the task manager directories for temporary files as defined by CoreOptions.TMP_DIRS.
        Parameters:
        configuration - configuration object
        Returns:
        array of configured directories (in order)
      • getRandomTempDirectory

        @Nonnull
        public static File getRandomTempDirectory​(Configuration configuration)
        Picks a temporary directory randomly from the given configuration.
        Parameters:
        configuration - to extract the temp directory from
        Returns:
        a randomly picked temporary directory
      • parseMap

        public static Map<String,​String> parseMap​(String stringSerializedMap)
        Parses a string as a map of strings. The expected format of the map is:
         key1:value1,key2:value2
         

        Parts of the string can be escaped by wrapping with single or double quotes.

        Parameters:
        stringSerializedMap - a string to parse
        Returns:
        parsed map
      • getStandaloneClusterStartupPeriodTime

        public static Time getStandaloneClusterStartupPeriodTime​(Configuration configuration)
      • assembleDynamicConfigsStr

        public static String assembleDynamicConfigsStr​(Map<String,​String> config)
        Creates a dynamic parameter list String of the passed configuration map.
        Parameters:
        config - A Map containing parameter/value entries that shall be used in the dynamic parameter list.
        Returns:
        The dynamic parameter list String.
      • parseTmResourceDynamicConfigs

        @VisibleForTesting
        public static Map<String,​String> parseTmResourceDynamicConfigs​(String dynamicConfigsStr)
      • parseJvmArgString

        @VisibleForTesting
        public static Map<String,​String> parseJvmArgString​(String jvmParamsStr)
      • getPrefixedKeyValuePairs

        public static Map<String,​String> getPrefixedKeyValuePairs​(String prefix,
                                                                        Configuration configuration)
        Extract and parse Flink configuration properties with a given name prefix and return the result as a Map.
      • convertValue

        public static <T> T convertValue​(Object rawValue,
                                         Class<?> clazz)
        Tries to convert the raw value into the provided type.
        Type Parameters:
        T - type of the result
        Parameters:
        rawValue - rawValue to convert into the provided type clazz
        clazz - clazz specifying the target type
        Returns:
        the converted value if rawValue is of type clazz
        Throws:
        IllegalArgumentException - if the rawValue cannot be converted in the specified target type clazz
      • convertToEnum

        public static <E extends Enum<?>> E convertToEnum​(Object o,
                                                          Class<E> clazz)
      • canBePrefixMap

        public static boolean canBePrefixMap​(ConfigOption<?> configOption)
        Maps can be represented in two ways.

        With constant key space:

             avro-confluent.properties = schema: 1, other-prop: 2
         

        Or with variable key space (i.e. prefix notation):

             avro-confluent.properties.schema = 1
             avro-confluent.properties.other-prop = 2
         
      • filterPrefixMapKey

        public static boolean filterPrefixMapKey​(String key,
                                                 String candidate)
        Filter condition for prefix map keys.