diff options
author | 2018-08-24 00:35:14 -0400 | |
---|---|---|
committer | 2018-08-24 00:36:47 -0400 | |
commit | 437dbc12410e956076bc067b8cc9e67de2b35b37 (patch) | |
tree | e5cd1eb50b0b4929b0e556202fd715a219b2819d /src/main/docker/create-topics.sh | |
parent | c49d2f158d852d2f308b77abdbad2328daa2ef9c (diff) |
Create Kafka 0.11.0.1 docker image
Issue-ID: DMAAP-628
Change-Id: I3ad0c01d2778870734ccb1ed7daff39afbb18acc
Signed-off-by: sunil unnava <su622b@att.com>
Diffstat (limited to 'src/main/docker/create-topics.sh')
-rw-r--r-- | src/main/docker/create-topics.sh | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/main/docker/create-topics.sh b/src/main/docker/create-topics.sh new file mode 100644 index 0000000..34945b3 --- /dev/null +++ b/src/main/docker/create-topics.sh @@ -0,0 +1,36 @@ +#!/bin/bash + + +if [[ -z "$START_TIMEOUT" ]]; then + START_TIMEOUT=600 +fi + +start_timeout_exceeded=false +count=0 +step=10 +while netstat -lnt | awk '$4 ~ /:'$KAFKA_PORT'$/ {exit 1}'; do + echo "waiting for kafka to be ready" + sleep $step; + count=$(expr $count + $step) + if [ $count -gt $START_TIMEOUT ]; then + start_timeout_exceeded=true + break + fi +done + +if $start_timeout_exceeded; then + echo "Not able to auto-create topic (waited for $START_TIMEOUT sec)" + exit 1 +fi + +if [[ -n $KAFKA_CREATE_TOPICS ]]; then + IFS=','; for topicToCreate in $KAFKA_CREATE_TOPICS; do + echo "creating topics: $topicToCreate" + IFS=':' read -a topicConfig <<< "$topicToCreate" + if [ ${topicConfig[3]} ]; then + JMX_PORT='' $KAFKA_HOME/bin/kafka-topics.sh --create --zookeeper $KAFKA_ZOOKEEPER_CONNECT --replication-factor ${topicConfig[2]} --partitions ${topicConfig[1]} --topic "${topicConfig[0]}" --config cleanup.policy="${topicConfig[3]}" --if-not-exists + else + JMX_PORT='' $KAFKA_HOME/bin/kafka-topics.sh --create --zookeeper $KAFKA_ZOOKEEPER_CONNECT --replication-factor ${topicConfig[2]} --partitions ${topicConfig[1]} --topic "${topicConfig[0]}" --if-not-exists + fi + done +fi |