Hi,

 

Is there some reason that shell scripts for Windows are separated into its
own dir instead being placed in <kafka_dir>/bin with other Unix ones?

 

Most of products out there have both types of scripts in bin dir.

 

One mroe thing, windows scripts need some corrections to be able to call
them from anywhere - they need to resolve kafka base dir (0or bin dir) by
resolving the dir where scripts reside (naturally "bin" directory), by using
"%~dp0" for eg in "kafka-list-topics.bat" (which doesn't exist at all in
windows dir):

 

@echo off

if not defined KAFKA_BIN_PATH ( 

  set KAFKA_BIN_PATH=%~dp0

)

if "%KAFKA_BIN_PATH:~-1%" == "\" (

  set KAFKA_BIN_PATH=%KAFKA_BIN_PATH:~0,-1%

)

%KAFKA_BIN_PATH%\kafka-run-class.bat kafka.admin.ListTopicCommand %*

 

Similarly, in kafka-run-class.bat there should be snippet for resolving base
dir via similar fashion:

 

if not defined KAFKA_BIN_PATH ( 

  set KAFKA_BIN_PATH=%~dp0

)

if "%KAFKA_BIN_PATH:~-1%" == "\" (

  set KAFKA_BIN_PATH=%KAFKA_BIN_PATH:~0,-1%

)

set BASE_DIR=%KAFKA_BIN_PATH%\..

 

Moreover, windows version doesn't have log4j properties separated for
starting zookeeper/kafka and those for executing tool tasks, so like Unix
versions, there should be something like:

 

IF ["%KAFKA_LOG4J_OPTS%"] EQU [""] (

            set
KAFKA_LOG4J_OPTS=-Dlog4j.configuration=file:"%BASE_DIR%/config/tools-log4j.p
roperties"

)

IF ["%KAFKA_OPTS%"] EQU [""] (

            set KAFKA_OPTS=-Xmx512M -server

)

 

.and then somewhere later to include it in execution call.

set COMMAND= %JAVA% %KAFKA_OPTS% %KAFKA_LOG4J_OPTS% %KAFKA_JMX_OPTS% -cp
%CLASSPATH% %*

 

Zookeeper and Kafka startup scripts should override log4j tool settings by
having for eg.:

 

@echo off

if not defined KAFKA_BIN_PATH ( 

  set KAFKA_BIN_PATH=%~dp0

)

if "%KAFKA_BIN_PATH:~-1%" == "\" (

  set KAFKA_BIN_PATH=%KAFKA_BIN_PATH:~0,-1%

)

set
KAFKA_LOG4J_OPTS=-Dlog4j.configuration=file:"%KAFKA_BIN_PATH%\..\config\log4
j.properties"

%KAFKA_BIN_PATH%\kafka-run-class.bat
org.apache.zookeeper.server.quorum.QuorumPeerMain %*

 

-Vjeran

Reply via email to