75 lines
3.0 KiB
Bash
Executable File
75 lines
3.0 KiB
Bash
Executable File
#! /bin/bash
|
|
|
|
function variables {
|
|
echo "Setting environment variables..."
|
|
export KAFKA_CREATE_TOPICS="${KAFKA_CREATE_TOPICS:-my-topic-1:20:1;my-topic-2:20:1;testtopic:5:1;qmp.state.config:1:1;qmp.state.throttle:1:1;isolation-service.key.rotation:20:1}"
|
|
export SCHEMAS_LOCATION="${SCHEMAS_LOCATION:-$(dirname "${BASH_SOURCE[0]}")}"
|
|
export SCHEMA_REGISTRY_URL="${SCHEMA_REGISTRY_URL:-localhost:8081}"
|
|
export QPL_BULK_BOOTSTRAP_SERVERS="${QPL_BULK_BOOTSTRAP_SERVERS:-core-kafka:9092}"
|
|
export QPL_DURABLE_BOOTSTRAP_SERVERS="${QPL_DURABLE_BOOTSTRAP_SERVERS:-$QPL_BULK_BOOTSTRAP_SERVERS}"
|
|
export QCL_BULK_BOOTSTRAP_SERVERS="${QCL_BULK_BOOTSTRAP_SERVERS:-$QPL_BULK_BOOTSTRAP_SERVERS}"
|
|
export QCL_RECORD_STATE_BOOTSTRAP_SERVERS="${QCL_RECORD_STATE_BOOTSTRAP_SERVERS:-$QPL_BULK_BOOTSTRAP_SERVERS}"
|
|
export QCL_BACKGROUND_JOB_BOOTSTRAP_SERVERS="${QCL_BACKGROUND_JOB_BOOTSTRAP_SERVERS:-$QPL_BULK_BOOTSTRAP_SERVERS}"
|
|
export QCL_IDEMPOTENT_BACKGROUND_JOB_BOOTSTRAP_SERVERS="${QCL_IDEMPOTENT_BACKGROUND_JOB_BOOTSTRAP_SERVERS:-$QPL_BULK_BOOTSTRAP_SERVERS}"
|
|
export JMX_PORT="${JMX_PORT:-9999}"
|
|
}
|
|
|
|
function start {
|
|
if [ "$(cat /etc/hosts | grep core-kafka)" == "" ]; then
|
|
echo "WARNING: Need 127.0.0.1 core-kafka in /etc/hosts"
|
|
fi
|
|
variables
|
|
echo "Starting docker..."
|
|
docker-compose up
|
|
}
|
|
|
|
function stop {
|
|
echo "Stopping docker..."
|
|
docker-compose down
|
|
}
|
|
|
|
function initCluster {
|
|
echo "Initializing cluster at localhost:9000"
|
|
res="$(curl -X POST \
|
|
-F 'name=local' \
|
|
-F 'zkHosts=core-zookeeper%3A2181%2Fqmp%2Flocal' \
|
|
-F 'kafkaVersion=0.9.0.1' \
|
|
-F 'jmxEnabled=true' \
|
|
-F 'jmxUser=' \
|
|
-F 'jmxPass=' \
|
|
-F 'pollConsumers=true' \
|
|
-F 'tuning.brokerViewUpdatePeriodSeconds=30' \
|
|
-F 'tuning.clusterManagerThreadPoolSize=2' \
|
|
-F 'tuning.clusterManagerThreadPoolQueueSize=100' \
|
|
-F 'tuning.kafkaCommandThreadPoolSize=2' \
|
|
-F 'tuning.kafkaCommandThreadPoolQueueSize=100' \
|
|
-F 'tuning.logkafkaCommandThreadPoolSize=2' \
|
|
-F 'tuning.logkafkaCommandThreadPoolQueueSize=100' \
|
|
-F 'tuning.logkafkaUpdatePeriodSeconds=30' \
|
|
-F 'tuning.partitionOffsetCacheTimeoutSecs=5' \
|
|
-F 'tuning.brokerViewThreadPoolSize=2' \
|
|
-F 'tuning.brokerViewThreadPoolQueueSize=1000' \
|
|
-F 'tuning.offsetCacheThreadPoolSize=2' \
|
|
-F 'tuning.offsetCacheThreadPoolQueueSize=1000' \
|
|
-F 'tuning.kafkaAdminClientThreadPoolSize=2' \
|
|
-F 'tuning.kafkaAdminClientThreadPoolQueueSize=1000' \
|
|
-F 'securityProtocol=PLAINTEXT' \
|
|
http://localhost:9000/clusters)"
|
|
echo $res
|
|
}
|
|
|
|
srcdir="$(pwd)"
|
|
cd "$(dirname ${BASH_SOURCE[0]})"
|
|
|
|
echo "Would you like to set environment variables, start docker, stop docker, or initialize the cluster?"
|
|
select opt in "start" "stop" "env"; do
|
|
case $opt,$REPLY in
|
|
*start*,*|*,*start*) start ; break;;
|
|
*stop*,*|*,*stop*) stop ; break;;
|
|
*env*,*|*,*env*) variables ; break;;
|
|
*) break;;
|
|
esac
|
|
done
|
|
|
|
cd "$srcdir"
|