UserFunctionLoader¶
UserFunctionLoader uses Function Loaders to loadFunctions.
Creating Instance¶
UserFunctionLoader takes the following to be created:
-
MutableFunctionRegistry - Plugin Directory
- Parent
ClassLoader - blacklist
-
Metrics -
loadCustomerUdfsflag
UserFunctionLoader is created when:
UdfLoaderUtilis requested to loadUserFunctionLoaderis requested to newInstance
Function Loaders¶
UserFunctionLoader creates the function loaders when created:
The loaders are used to loadFunctions.
Creating UserFunctionLoader¶
UserFunctionLoader newInstance(
KsqlConfig config,
MutableFunctionRegistry metaStore,
String ksqlInstallDir,
Metrics metricsRegistry)
With ksql.udf.enable.security.manager enabled, newInstance sets the System security as ExtensionSecurityManager.
In the end, newInstance creates a UserFunctionLoader with the following:
- The given
MutableFunctionRegistry - The plugin directory as ext under the given
ksqlInstallDirunless ksql.extension.dir is defined - A new
Blacklistwithresource-blacklist.txtunder the plugin directory - The given
Metricsif ksql.udf.collect.metrics - ksql.udfs.enabled
newInstance is used when:
KsqlContextis used to create a KsqlContextKsqlRestApplicationis used to build a KsqlRestApplicationStandaloneExecutorFactoryis used to create a StandaloneExecutor
Loading Function Jars¶
void load()
load loadFunctions.
With loadCustomerUdfs enabled, load finds all the jar files in the pluginDir and loadFunctions for every jar file (unless blacklisted).
load is used when:
KsqlContextis used to create a KsqlContextUdfLoaderUtilis requested to loadKsqlRestApplicationis used to build a KsqlRestApplicationStandaloneExecutoris requested to startAsync
loadFunctions¶
void loadFunctions(
ClassLoader loader,
Optional<Path> path)
ClassGraph
loadFunctions uses ClassGraph library to scan the classpath.
loadFunctions finds classes with the function annotations and uses the UdfLoader to load them.
| Annotation | Loader |
|---|---|
| UdfDescription | UdfLoader |
| UdafDescription | UdafLoader |
| UdtfDescription | UdtfLoader |
Logging¶
Enable ALL logging level for io.confluent.ksql.function.UserFunctionLoader logger to see what happens inside.
Add the following line to config/log4j.properties:
log4j.logger.io.confluent.ksql.function.UserFunctionLoader=ALL
Refer to Logging.