UserFunctionLoader¶
UserFunctionLoader
uses Function Loaders to loadFunctions.
Creating Instance¶
UserFunctionLoader
takes the following to be created:
-
MutableFunctionRegistry
- Plugin Directory
- Parent
ClassLoader
- blacklist
-
Metrics
-
loadCustomerUdfs
flag
UserFunctionLoader
is created when:
UdfLoaderUtil
is requested to loadUserFunctionLoader
is 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
ksqlInstallDir
unless ksql.extension.dir is defined - A new
Blacklist
withresource-blacklist.txt
under the plugin directory - The given
Metrics
if ksql.udf.collect.metrics - ksql.udfs.enabled
newInstance
is used when:
KsqlContext
is used to create a KsqlContextKsqlRestApplication
is used to build a KsqlRestApplicationStandaloneExecutorFactory
is 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:
KsqlContext
is used to create a KsqlContextUdfLoaderUtil
is requested to loadKsqlRestApplication
is used to build a KsqlRestApplicationStandaloneExecutor
is 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.