KsqlServerMain¶
KsqlServerMain
is the ksqlDB server.
KsqlServerMain
can be started on command line using ksql-server-start shell script (that supports command-line options).
When launched, KsqlServerMain
starts an Executable:
- StandaloneExecutor with queries file specified (for headless execution mode)
- KsqlRestApplication unless ksql.connect.worker.config configuration property is specified
MultiExecutable
with aConnectExecutable
and aKsqlRestApplication
Creating Instance¶
KsqlServerMain
takes the following to be created:
-
PreconditionChecker
- Executable factory
- Shutdown Handler
KsqlServerMain
is created when:
KsqlServerMain
application is launched
Launching Application¶
main
parses the command-line options and loads the required properties file (with the Java system properties applied overriding earlier values).
main
creates and validates a KsqlConfig.
main
configures QueryLogger (with the KsqlConfig
).
main
creates an Executable based on the following:
- Properties with the Java system properties applied
- queries file command-line option (if defined)
ksql.server.install.dir
configuration property from the properties file- A new KsqlConfig with the config and system properties
- A new
MetricCollectors
main
creates a new KsqlServerMain (with the Executable
) and starts it up.
Note
main
is paused when starting up the executable (using awaitTerminated) until notifyTerminated which happens as part of a Java Virtual Machine shutdown hook.
Creating Executable¶
Executable createExecutable(
Map<String, String> properties,
Optional<String> queriesFile,
String installDir,
KsqlConfig ksqlConfig,
MetricCollectors metricCollectors)
With queries file specified, createExecutable
returns a new StandaloneExecutor.
Otherwise, createExecutable
creates a KsqlRestConfig (with the given properties
) to build a KsqlRestApplication (with the KsqlRestConfig
and the given MetricCollectors
).
With no ksql.connect.worker.config configuration property specified, createExecutable
returns the KsqlRestApplication
. Otherwise, createExecutable
creates a ConnectExecutable
and returns a MultiExecutable
(with the ConnectExecutable
and the KsqlRestApplication
).
tryStartApp¶
void tryStartApp()
tryStartApp
prints out the following INFO message to the logs:
Starting server
tryStartApp
requests the Executable to startAsync.
tryStartApp
prints out the following INFO message to the logs:
Server up and running
tryStartApp
requests the Executable to awaitTerminated.
Finally (when the Executable was requested to terminate), tryStartApp
prints out the following INFO message to the logs:
Server shutting down
tryStartApp
requests the Executable to shutdown.