Class FactoryUtil
Factorys.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classHelper utility for validating all options for aCatalogFactory.static classHelper utility for validating all options for aCatalogStoreFactory.static classDefault implementation ofCatalogFactory.Context.static classDefault implementation ofCatalogStoreFactory.Context.static classDefault implementation ofDynamicTableFactory.Context.static classDefault implementation ofModuleFactory.Context.static classFactoryUtil.FactoryHelper<F extends Factory>Base helper utility for validating all options for aFactory.static classHelper utility for validating all options for aModuleFactory.static classHelper utility for discovering formats and validating all options for aDynamicTableFactory. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final org.apache.flink.configuration.ConfigOption<String>static final org.apache.flink.configuration.ConfigOption<String>static final StringSuffix for keys ofConfigOptionin case a connector requires multiple formats (e.g.static final StringThe placeholder symbol to be used for keys of options which can be templated.static final org.apache.flink.configuration.ConfigOption<Integer>Describes the property version.static final org.apache.flink.configuration.ConfigOption<Integer>static final org.apache.flink.configuration.ConfigOption<Duration>static final org.apache.flink.configuration.ConfigOption<Integer>static final org.apache.flink.configuration.ConfigOption<String>static final org.apache.flink.configuration.ConfigOption<Duration>static final org.apache.flink.configuration.ConfigOption<Duration>static final org.apache.flink.configuration.ConfigOption<WatermarkEmitStrategy>static final org.apache.flink.configuration.ConfigOption<String> -
Method Summary
Modifier and TypeMethodDescriptioncheckWatermarkOptions(org.apache.flink.configuration.ReadableConfig conf) Check watermark-related options and return error messages.static CatalogcreateCatalog(String catalogName, Map<String, String> options, org.apache.flink.configuration.ReadableConfig configuration, ClassLoader classLoader) Attempts to discover an appropriate catalog factory and creates an instance of the catalog.createCatalogFactoryHelper(CatalogFactory factory, CatalogFactory.Context context) Creates a utility that helps validating options for aCatalogFactory.createCatalogStoreFactoryHelper(CatalogStoreFactory factory, CatalogStoreFactory.Context context) Creates a utility that helps validating options for aCatalogStoreFactory.static DynamicTableSinkcreateDynamicTableSink(DynamicTableSinkFactory preferredFactory, ObjectIdentifier objectIdentifier, ResolvedCatalogTable catalogTable, Map<String, String> enrichmentOptions, org.apache.flink.configuration.ReadableConfig configuration, ClassLoader classLoader, boolean isTemporary) Creates aDynamicTableSinkfrom aCatalogTable.static DynamicTableSourcecreateDynamicTableSource(DynamicTableSourceFactory preferredFactory, ObjectIdentifier objectIdentifier, ResolvedCatalogTable catalogTable, Map<String, String> enrichmentOptions, org.apache.flink.configuration.ReadableConfig configuration, ClassLoader classLoader, boolean isTemporary) Creates aDynamicTableSourcefrom aCatalogTable.static ModulecreateModule(String moduleName, Map<String, String> options, org.apache.flink.configuration.ReadableConfig configuration, ClassLoader classLoader) Discovers a matching module factory and creates an instance of it.createModuleFactoryHelper(ModuleFactory factory, ModuleFactory.Context context) Creates a utility that helps validating options for aModuleFactory.createTableFactoryHelper(DynamicTableFactory factory, DynamicTableFactory.Context context) Creates a utility that helps in discovering formats, merging options withDynamicTableFactory.Context.getEnrichmentOptions()and validating them all for aDynamicTableFactory.static <T extends Factory>
TdiscoverFactory(ClassLoader classLoader, Class<T> factoryClass, String factoryIdentifier) Discovers a factory using the given factory base class and identifier.static <T extends DynamicTableFactory>
Optional<T>getDynamicTableFactory(Class<T> factoryClass, Catalog catalog) Returns theDynamicTableFactoryviaCatalog.static StringgetFormatPrefix(org.apache.flink.configuration.ConfigOption<String> formatOption, String formatIdentifier) Returns the required option prefix for options of the given format.static StringstringifyOption(String key, String value) static voidvalidateFactoryOptions(Set<org.apache.flink.configuration.ConfigOption<?>> requiredOptions, Set<org.apache.flink.configuration.ConfigOption<?>> optionalOptions, org.apache.flink.configuration.ReadableConfig options) Validates the required options and optional options.static voidvalidateFactoryOptions(Factory factory, org.apache.flink.configuration.ReadableConfig options) Validates the required and optionalConfigOptions of a factory.static voidvalidateUnconsumedKeys(String factoryIdentifier, Set<String> allOptionKeys, Set<String> consumedOptionKeys) Validates unconsumed option keys.static voidvalidateUnconsumedKeys(String factoryIdentifier, Set<String> allOptionKeys, Set<String> consumedOptionKeys, Set<String> deprecatedOptionKeys) Validates unconsumed option keys.static voidvalidateWatermarkOptions(String factoryIdentifier, org.apache.flink.configuration.ReadableConfig conf) Validate watermark options from table options.
-
Field Details
-
PROPERTY_VERSION
Describes the property version. This can be used for backwards compatibility in case the property format changes. -
CONNECTOR
-
FORMAT
-
SINK_PARALLELISM
-
SQL_GATEWAY_ENDPOINT_TYPE
-
SOURCE_PARALLELISM
-
WATERMARK_EMIT_STRATEGY
public static final org.apache.flink.configuration.ConfigOption<WatermarkEmitStrategy> WATERMARK_EMIT_STRATEGY -
WATERMARK_ALIGNMENT_GROUP
-
WATERMARK_ALIGNMENT_MAX_DRIFT
public static final org.apache.flink.configuration.ConfigOption<Duration> WATERMARK_ALIGNMENT_MAX_DRIFT -
WATERMARK_ALIGNMENT_UPDATE_INTERVAL
public static final org.apache.flink.configuration.ConfigOption<Duration> WATERMARK_ALIGNMENT_UPDATE_INTERVAL -
SOURCE_IDLE_TIMEOUT
-
WORKFLOW_SCHEDULER_TYPE
-
FORMAT_SUFFIX
Suffix for keys ofConfigOptionin case a connector requires multiple formats (e.g. for both key and value).See
createTableFactoryHelper(DynamicTableFactory, DynamicTableFactory.Context)for more information.- See Also:
-
PLACEHOLDER_SYMBOL
The placeholder symbol to be used for keys of options which can be templated. SeeFactoryfor details.- See Also:
-
-
Method Details
-
createDynamicTableSource
public static DynamicTableSource createDynamicTableSource(@Nullable DynamicTableSourceFactory preferredFactory, ObjectIdentifier objectIdentifier, ResolvedCatalogTable catalogTable, Map<String, String> enrichmentOptions, org.apache.flink.configuration.ReadableConfig configuration, ClassLoader classLoader, boolean isTemporary) Creates aDynamicTableSourcefrom aCatalogTable.If is passed, the table source is created from that factory. Otherwise, an attempt is made to discover a matching factory using Java SPI (see
Factoryfor details). -
createDynamicTableSink
public static DynamicTableSink createDynamicTableSink(@Nullable DynamicTableSinkFactory preferredFactory, ObjectIdentifier objectIdentifier, ResolvedCatalogTable catalogTable, Map<String, String> enrichmentOptions, org.apache.flink.configuration.ReadableConfig configuration, ClassLoader classLoader, boolean isTemporary) Creates aDynamicTableSinkfrom aCatalogTable.If is passed, the table sink is created from that factory. Otherwise, an attempt is made to discover a matching factory using Java SPI (see
Factoryfor details). -
createCatalogFactoryHelper
public static FactoryUtil.CatalogFactoryHelper createCatalogFactoryHelper(CatalogFactory factory, CatalogFactory.Context context) Creates a utility that helps validating options for aCatalogFactory.Note: This utility checks for left-over options in the final step.
-
createCatalogStoreFactoryHelper
public static FactoryUtil.CatalogStoreFactoryHelper createCatalogStoreFactoryHelper(CatalogStoreFactory factory, CatalogStoreFactory.Context context) Creates a utility that helps validating options for aCatalogStoreFactory.Note: This utility checks for left-over options in the final step.
-
createModuleFactoryHelper
public static FactoryUtil.ModuleFactoryHelper createModuleFactoryHelper(ModuleFactory factory, ModuleFactory.Context context) Creates a utility that helps validating options for aModuleFactory.Note: This utility checks for left-over options in the final step.
-
createTableFactoryHelper
public static FactoryUtil.TableFactoryHelper createTableFactoryHelper(DynamicTableFactory factory, DynamicTableFactory.Context context) Creates a utility that helps in discovering formats, merging options withDynamicTableFactory.Context.getEnrichmentOptions()and validating them all for aDynamicTableFactory.The following example sketches the usage:
// in createDynamicTableSource() helper = FactoryUtil.createTableFactoryHelper(this, context); keyFormat = helper.discoverDecodingFormat(DeserializationFormatFactory.class, KEY_FORMAT); valueFormat = helper.discoverDecodingFormat(DeserializationFormatFactory.class, VALUE_FORMAT); helper.validate(); ... // construct connector with discovered formatsNote: The format option parameter of
FactoryUtil.TableFactoryHelper.discoverEncodingFormat(Class, ConfigOption)andFactoryUtil.TableFactoryHelper.discoverDecodingFormat(Class, ConfigOption)must beFORMATor end withFORMAT_SUFFIX. The discovery logic will replace 'format' with the factory identifier value as the format prefix. For example, assuming the identifier is 'json', if the format option key is 'format', then the format prefix is 'json.'. If the format option key is 'value.format', then the format prefix is 'value.json'. The format prefix is used to project the options for the format factory.Note: When created, this utility merges the options from
DynamicTableFactory.Context.getEnrichmentOptions()usingDynamicTableFactory.forwardOptions(). When invokingFactoryUtil.FactoryHelper.validate(), this utility checks for left-over options in the final step. -
createCatalog
public static Catalog createCatalog(String catalogName, Map<String, String> options, org.apache.flink.configuration.ReadableConfig configuration, ClassLoader classLoader) Attempts to discover an appropriate catalog factory and creates an instance of the catalog.This first uses the legacy
TableFactorystack to discover a matchingCatalogFactory. If none is found, it falls back to the new stack usingFactoryinstead. -
createModule
public static Module createModule(String moduleName, Map<String, String> options, org.apache.flink.configuration.ReadableConfig configuration, ClassLoader classLoader) Discovers a matching module factory and creates an instance of it.This first uses the legacy
TableFactorystack to discover a matchingModuleFactory. If none is found, it falls back to the new stack usingFactoryinstead. -
discoverFactory
public static <T extends Factory> T discoverFactory(ClassLoader classLoader, Class<T> factoryClass, String factoryIdentifier) Discovers a factory using the given factory base class and identifier.This method is meant for cases where
createTableFactoryHelper(DynamicTableFactory, DynamicTableFactory.Context)createDynamicTableSource(DynamicTableSourceFactory, ObjectIdentifier, ResolvedCatalogTable, Map, ReadableConfig, ClassLoader, boolean), andcreateDynamicTableSink(DynamicTableSinkFactory, ObjectIdentifier, ResolvedCatalogTable, Map, ReadableConfig, ClassLoader, boolean)are not applicable. -
validateFactoryOptions
public static void validateFactoryOptions(Factory factory, org.apache.flink.configuration.ReadableConfig options) Validates the required and optionalConfigOptions of a factory.Note: It does not check for left-over options.
-
validateFactoryOptions
public static void validateFactoryOptions(Set<org.apache.flink.configuration.ConfigOption<?>> requiredOptions, Set<org.apache.flink.configuration.ConfigOption<?>> optionalOptions, org.apache.flink.configuration.ReadableConfig options) Validates the required options and optional options.Note: It does not check for left-over options.
-
validateUnconsumedKeys
public static void validateUnconsumedKeys(String factoryIdentifier, Set<String> allOptionKeys, Set<String> consumedOptionKeys, Set<String> deprecatedOptionKeys) Validates unconsumed option keys. -
validateUnconsumedKeys
public static void validateUnconsumedKeys(String factoryIdentifier, Set<String> allOptionKeys, Set<String> consumedOptionKeys) Validates unconsumed option keys. -
getFormatPrefix
public static String getFormatPrefix(org.apache.flink.configuration.ConfigOption<String> formatOption, String formatIdentifier) Returns the required option prefix for options of the given format. -
getDynamicTableFactory
public static <T extends DynamicTableFactory> Optional<T> getDynamicTableFactory(Class<T> factoryClass, @Nullable Catalog catalog) Returns theDynamicTableFactoryviaCatalog. -
stringifyOption
-
validateWatermarkOptions
public static void validateWatermarkOptions(String factoryIdentifier, org.apache.flink.configuration.ReadableConfig conf) Validate watermark options from table options.- Parameters:
factoryIdentifier- identifier of tableconf- table options
-
checkWatermarkOptions
public static Optional<String> checkWatermarkOptions(org.apache.flink.configuration.ReadableConfig conf) Check watermark-related options and return error messages.- Parameters:
conf- table options- Returns:
- Optional of error messages
-