2015-11-05 01:19:49 +08:00
@ echo off
rem Licensed to the Apache Software Foundation (ASF) under one or more
rem contributor license agreements. See the NOTICE file distributed with
rem this work for additional information regarding copyright ownership.
rem The ASF licenses this file to You under the Apache License, Version 2.0
rem (the "License"); you may not use this file except in compliance with
rem the License. You may obtain a copy of the License at
rem
rem http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.
setlocal enabledelayedexpansion
IF [%1 ] EQU [] (
echo USAGE: %0 classname [opts]
EXIT /B 1
)
rem Using pushd popd to set BASE_DIR to the absolute path
pushd %~dp0 ..\..
set BASE_DIR = %CD%
popd
IF [" %SCALA_VERSION% " ] EQU [" " ] (
2024-09-30 02:08:51 +08:00
set SCALA_VERSION = 2.13.15
2015-11-05 01:19:49 +08:00
)
IF [" %SCALA_BINARY_VERSION% " ] EQU [" " ] (
2016-11-17 10:15:14 +08:00
for /f " tokens=1,2 delims=. " %% a in ( " %SCALA_VERSION% " ) do (
set FIRST = %% a
set SECOND = %% b
if [" !SECOND! " ] EQU [" " ] (
set SCALA_BINARY_VERSION = !FIRST!
) else (
set SCALA_BINARY_VERSION = !FIRST! .!SECOND!
)
)
2015-11-05 01:19:49 +08:00
)
rem Classpath addition for kafka-core dependencies
2017-09-06 07:27:08 +08:00
for %% i in ( " %BASE_DIR% \core\build\dependant-libs- %SCALA_VERSION% \*.jar " ) do (
call : concat " %% i "
2015-11-05 01:19:49 +08:00
)
2016-12-30 01:03:24 +08:00
rem Classpath addition for kafka-examples
2017-09-06 07:27:08 +08:00
for %% i in ( " %BASE_DIR% \examples\build\libs\kafka-examples*.jar " ) do (
call : concat " %% i "
2015-11-05 01:19:49 +08:00
)
rem Classpath addition for kafka-clients
2017-09-06 07:27:08 +08:00
for %% i in ( " %BASE_DIR% \clients\build\libs\kafka-clients*.jar " ) do (
call : concat " %% i "
2015-11-05 01:19:49 +08:00
)
2016-12-30 01:03:24 +08:00
rem Classpath addition for kafka-streams
2017-09-06 07:27:08 +08:00
for %% i in ( " %BASE_DIR% \streams\build\libs\kafka-streams*.jar " ) do (
call : concat " %% i "
2016-12-30 01:03:24 +08:00
)
rem Classpath addition for kafka-streams-examples
2017-09-06 07:27:08 +08:00
for %% i in ( " %BASE_DIR% \streams\examples\build\libs\kafka-streams-examples*.jar " ) do (
call : concat " %% i "
2016-12-30 01:03:24 +08:00
)
2017-09-06 07:27:08 +08:00
for %% i in ( " %BASE_DIR% \streams\build\dependant-libs- %SCALA_VERSION% \rocksdb*.jar " ) do (
call : concat " %% i "
2015-11-05 01:19:49 +08:00
)
2016-12-30 01:03:24 +08:00
rem Classpath addition for kafka tools
2017-09-06 07:27:08 +08:00
for %% i in ( " %BASE_DIR% \tools\build\libs\kafka-tools*.jar " ) do (
call : concat " %% i "
2016-12-30 01:03:24 +08:00
)
2017-09-06 07:27:08 +08:00
for %% i in ( " %BASE_DIR% \tools\build\dependant-libs- %SCALA_VERSION% \*.jar " ) do (
call : concat " %% i "
2016-12-30 01:03:24 +08:00
)
for %% p in ( api runtime file json tools) do (
2017-09-06 07:27:08 +08:00
for %% i in ( " %BASE_DIR% \connect\ %% p\build\libs\connect- %% p*.jar " ) do (
call : concat " %% i "
2016-12-30 01:03:24 +08:00
)
if exist " %BASE_DIR% \connect\ %% p\build\dependant-libs\* " (
2017-09-06 07:27:08 +08:00
call : concat " %BASE_DIR% \connect\ %% p\build\dependant-libs\* "
2016-12-30 01:03:24 +08:00
)
)
2015-11-05 01:19:49 +08:00
rem Classpath addition for release
2017-09-06 07:27:08 +08:00
for %% i in ( " %BASE_DIR% \libs\* " ) do (
call : concat " %% i "
2017-01-27 06:17:09 +08:00
)
2015-11-05 01:19:49 +08:00
rem Classpath addition for core
2017-09-06 07:27:08 +08:00
for %% i in ( " %BASE_DIR% \core\build\libs\kafka_ %SCALA_BINARY_VERSION% *.jar " ) do (
call : concat " %% i "
2015-11-05 01:19:49 +08:00
)
rem JMX settings
IF [" %KAFKA_JMX_OPTS% " ] EQU [" " ] (
set KAFKA_JMX_OPTS = -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false
)
rem JMX port to use
IF [" %JMX_PORT% " ] NEQ [" " ] (
set KAFKA_JMX_OPTS = %KAFKA_JMX_OPTS% -Dcom.sun.management.jmxremote.port=%JMX_PORT%
)
2016-02-17 04:23:24 +08:00
rem Log directory to use
IF [" %LOG_DIR% " ] EQU [" " ] (
2019-02-22 04:55:14 +08:00
set LOG_DIR = %BASE_DIR% /logs
2016-02-17 04:23:24 +08:00
)
2015-11-05 01:19:49 +08:00
rem Log4j settings
IF [" %KAFKA_LOG4J_OPTS% " ] EQU [" " ] (
2025-01-01 21:06:01 +08:00
set KAFKA_LOG4J_OPTS = -Dlog4j2.configurationFile=file:%BASE_DIR% /config/tools-log4j2.yaml
2016-02-17 04:23:24 +08:00
) ELSE (
2024-12-30 20:38:58 +08:00
rem Check if Log4j 1.x configuration options are present in KAFKA_LOG4J_OPTS
echo %KAFKA_LOG4J_OPTS% | findstr /r /c:" log4j\.[ ^ ]*(\.properties|\.xml)$ " > nul
IF %ERRORLEVEL% == 0 (
rem Enable Log4j 1.x configuration compatibility mode for Log4j 2
set LOG4J_COMPATIBILITY = true
echo DEPRECATED: A Log4j 1.x configuration file has been detected, which is no longer recommended. >& 2
echo To use a Log4j 2.x configuration, please see https://logging.apache.org/log4j/2.x/migrate-from-log4j1.html#Log4j2ConfigurationFormat for details about Log4j configuration file migration. >& 2
echo You can also use the %BASE_DIR% /config/tool-log4j2.yaml file as a starting point. Make sure to remove the Log4j 1.x configuration after completing the migration. >& 2
)
2016-08-19 11:50:20 +08:00
rem create logs directory
2017-09-06 07:27:08 +08:00
IF not exist " %LOG_DIR% " (
mkdir " %LOG_DIR% "
2016-02-17 04:23:24 +08:00
)
2015-11-05 01:19:49 +08:00
)
2017-09-06 07:27:08 +08:00
set KAFKA_LOG4J_OPTS = -Dkafka.logs.dir=" %LOG_DIR% " " %KAFKA_LOG4J_OPTS% "
2016-02-17 04:23:24 +08:00
2015-11-05 01:19:49 +08:00
rem Generic jvm settings you want to add
IF [" %KAFKA_OPTS% " ] EQU [" " ] (
set KAFKA_OPTS =
)
2016-02-24 07:55:09 +08:00
set DEFAULT_JAVA_DEBUG_PORT = 5005
set DEFAULT_DEBUG_SUSPEND_FLAG = n
rem Set Debug options if enabled
IF [" %KAFKA_DEBUG% " ] NEQ [" " ] (
IF [" %JAVA_DEBUG_PORT% " ] EQU [" " ] (
set JAVA_DEBUG_PORT = %DEFAULT_JAVA_DEBUG_PORT%
)
IF [" %DEBUG_SUSPEND_FLAG% " ] EQU [" " ] (
set DEBUG_SUSPEND_FLAG = %DEFAULT_DEBUG_SUSPEND_FLAG%
)
set DEFAULT_JAVA_DEBUG_OPTS = -agentlib:jdwp=transport=dt_socket,server=y,suspend=!DEBUG_SUSPEND_FLAG! ,address=!JAVA_DEBUG_PORT!
IF [" %JAVA_DEBUG_OPTS% " ] EQU [" " ] (
set JAVA_DEBUG_OPTS = !DEFAULT_JAVA_DEBUG_OPTS!
)
echo Enabling Java debug options: !JAVA_DEBUG_OPTS!
set KAFKA_OPTS = !JAVA_DEBUG_OPTS! !KAFKA_OPTS!
)
2015-11-05 01:19:49 +08:00
rem Which java to use
IF [" %JAVA_HOME% " ] EQU [" " ] (
set JAVA = java
) ELSE (
set JAVA = " %JAVA_HOME% /bin/java "
)
rem Memory options
IF [" %KAFKA_HEAP_OPTS% " ] EQU [" " ] (
set KAFKA_HEAP_OPTS = -Xmx256M
)
rem JVM performance options
IF [" %KAFKA_JVM_PERFORMANCE_OPTS% " ] EQU [" " ] (
2017-10-12 17:09:16 +08:00
set KAFKA_JVM_PERFORMANCE_OPTS = -server -XX:+UseG1GC -XX:MaxGCPauseMillis=20 -XX:InitiatingHeapOccupancyPercent=35 -XX:+ExplicitGCInvokesConcurrent -Djava.awt.headless=true
2015-11-05 01:19:49 +08:00
)
2017-09-06 07:27:08 +08:00
IF not defined CLASSPATH (
2015-11-05 01:19:49 +08:00
echo Classpath is empty. Please build the project first e.g. by running 'gradlew jarAll'
EXIT /B 2
)
2019-01-26 12:37:31 +08:00
set COMMAND = %JAVA% %KAFKA_HEAP_OPTS% %KAFKA_JVM_PERFORMANCE_OPTS% %KAFKA_JMX_OPTS% %KAFKA_LOG4J_OPTS% -cp " %CLASSPATH% " %KAFKA_OPTS% %*
2015-11-05 01:19:49 +08:00
rem echo.
rem echo %COMMAND%
rem echo.
%COMMAND%
goto : eof
: concat
2017-09-06 07:27:08 +08:00
IF not defined CLASSPATH (
set CLASSPATH = " %~1 "
2015-11-05 01:19:49 +08:00
) ELSE (
2017-09-06 07:27:08 +08:00
set CLASSPATH = %CLASSPATH% ;" %~1 "
2015-11-05 01:19:49 +08:00
)