StandaloneExecutor¶
StandaloneExecutor
is the Executable for Headless Execution Mode.
Creating Instance¶
StandaloneExecutor
takes the following to be created:
- ServiceContext
- ProcessingLogConfig
- KsqlConfig
- KsqlEngine
- Query File
- UserFunctionLoader
-
failOnNoQueries
flag - VersionCheckerAgent
- Factory to build an Injector (based on KsqlExecutionContext and ServiceContext)
- MetricCollectors
StandaloneExecutor
is created when:
StandaloneExecutorFactory
utility is used to create a StandaloneExecutor
KsqlEngine¶
StandaloneExecutor
is given a KsqlEngine when created.
The KsqlEngine
is active until shutdown.
The KsqlEngine
is used when:
startAsync¶
void startAsync()
startAsync
requests the UserFunctionLoader to load.
startAsync
maybeCreateProcessingLogTopic.
With stream.auto.create
enabled, startAsync
prints out the following WARN message to the logs:
processing log auto-create is enabled, but this is not supported for headless mode.
startAsync
reads the queriesFile to process.
startAsync
showWelcomeMessage.
In the end, startAsync
requests the VersionCheckerAgent to start (with the SERVER
module type and non-null configuration properties of the KsqlConfig).
startAsync
is part of the Executable abstraction.
Loading Queries File¶
String readQueriesFile(
String queryFilePath)
readQueriesFile
reads the given queryFilePath
with UTF_8
encoding.
Processing Queries¶
void processesQueryFile(
String queries)
processesQueryFile
requests the KsqlEngine to parse the SQL queries (into a collection of ParsedStatement
s).
processesQueryFile
validates the ParsedStatements.
processesQueryFile
uses the injectorFactory to create an Injector
(with the KsqlEngine and the ServiceContext).
processesQueryFile
...FIXME
Validating Statements¶
void validateStatements(
List<ParsedStatement> statements)
validateStatements
requests the KsqlEngine to create a SandboxedExecutionContext (with the ServiceContext).
validateStatements
uses the injectorFactory to create an Injector
(with the SandboxedExecutionContext and its ServiceContext).
validateStatements
creates a StatementExecutor to execute the ParsedStatements.
In the end, if failOnNoQueries and there was no QueryContainer, validateStatements
throws a KsqlException
:
The SQL file does not contain any persistent queries.
i.e. it contains no 'INSERT INTO', 'CREATE TABLE x AS SELECT' or
'CREATE STREAM x AS SELECT' style statements.
Executing Statements¶
boolean executeStatements(
List<ParsedStatement> statements,
StatementExecutor executor)
executeStatements
requests the given StatementExecutor to execute the given ParsedStatement
s one by one.
In the end, executeStatements
returns whether there was a ParsedStatement
with a query.
executeStatements
is used when:
StandaloneExecutor
is requested to processes a query file and validate statements