chore(install): Improved array splitting for kafka
Signed-off-by: rjshrjndrn <rjshrjndrn@gmail.com>
This commit is contained in:
parent
490c12cc5d
commit
15bcb90417
1 changed files with 18 additions and 18 deletions
|
|
@ -6,40 +6,40 @@ set -e
|
|||
RETENTION_TIME=${RETENTION_TIME:-345600000}
|
||||
|
||||
topics=(
|
||||
"raw"
|
||||
"raw-ios"
|
||||
"trigger"
|
||||
"cache"
|
||||
"analytics"
|
||||
"storage-failover"
|
||||
"quickwit"
|
||||
"raw"
|
||||
"raw-ios"
|
||||
"trigger"
|
||||
"cache"
|
||||
"analytics"
|
||||
"storage-failover"
|
||||
"quickwit"
|
||||
)
|
||||
|
||||
touch /tmp/config.txt
|
||||
|
||||
if [[ $KAFKA_SSL == "true" ]]; then
|
||||
echo 'security.protocol=SSL' > /tmp/config.txt
|
||||
echo 'security.protocol=SSL' >/tmp/config.txt
|
||||
fi
|
||||
|
||||
function init() {
|
||||
echo "Initializing kafka"
|
||||
for topic in ${topics[*]}; do
|
||||
echo "Creating topic: $topic"
|
||||
# TODO: Have to check an idempotent way of creating topics.
|
||||
kafka-topics.sh --create --bootstrap-server ${KAFKA_HOST}:${KAFKA_PORT} --replication-factor 2 --partitions 16 --topic ${topic} --command-config /tmp/config.txt || true
|
||||
kafka-configs.sh --bootstrap-server ${KAFKA_HOST}:${KAFKA_PORT} --entity-type topics --alter --add-config retention.ms=${RETENTION_TIME} --entity-name=${topic} --command-config /tmp/config.txt || true
|
||||
done
|
||||
echo "Initializing kafka"
|
||||
for topic in "${topics[@]}"; do
|
||||
echo "Creating topic: $topic"
|
||||
# TODO: Have to check an idempotent way of creating topics.
|
||||
kafka-topics.sh --create --bootstrap-server ${KAFKA_HOST}:${KAFKA_PORT} --replication-factor 2 --partitions 16 --topic ${topic} --command-config /tmp/config.txt || true
|
||||
kafka-configs.sh --bootstrap-server ${KAFKA_HOST}:${KAFKA_PORT} --entity-type topics --alter --add-config retention.ms=${RETENTION_TIME} --entity-name=${topic} --command-config /tmp/config.txt || true
|
||||
done
|
||||
}
|
||||
|
||||
# /bin/bash kafka.sh migrate $migration_versions
|
||||
case "$1" in
|
||||
migrate)
|
||||
migrate)
|
||||
init
|
||||
;;
|
||||
init)
|
||||
init)
|
||||
init
|
||||
;;
|
||||
*)
|
||||
*)
|
||||
echo "Unknown operation for kafka migration; exiting."
|
||||
exit 1
|
||||
;;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue