Skip to content

KsqlServerMain

KsqlServerMain is a standalone application to start an Executable:

  1. StandaloneExecutor for queries file
  2. KsqlRestApplication unless ksql.connect.worker.config configuration property is specified
  3. MultiExecutable with a ConnectExecutable and the KsqlRestApplication

KsqlServerMain supports command-line options.

KsqlServerMain can be launched on command line using ksql-server-start shell script.

ksql-server-start Shell Script

ksql-server-start shell script (indirectly or ksql-run-class directly) is used to launch KsqlServerMain on command line.

./bin/ksql-run-class io.confluent.ksql.rest.server.KsqlServerMain
$ ./bin/ksql-server-start --help
NAME
        server - KSQL Cluster

SYNOPSIS
        server [ {-h | --help} ] [ --queries-file <queriesFile> ] [--]
                <config-file>

OPTIONS
        -h, --help
            Display help information

        --queries-file <queriesFile>
            Path to the query file on the local machine.

        --
            This option can be used to separate command-line options from the
            list of arguments (useful when arguments might be mistaken for
            command-line options)

        <config-file>
            A file specifying configs for the KSQL Server, KSQL, and its
            underlying Kafka Streams instance(s). Refer to KSQL documentation
            for a list of available configs.

            This option may occur a maximum of 1 times

Creating Instance

KsqlServerMain takes the following to be created:

KsqlServerMain is created when:

  • KsqlServerMain standalone application is launched

Launching KsqlServerMain (on Command Line)

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:

  1. Properties with the Java system properties applied
  2. queries file command-line option (if defined)
  3. ksql.server.install.dir configuration property from the properties file
  4. A new KsqlConfig with the config and system properties
  5. 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.

Back to top