Skip to content

Commit 8f05852

Browse files
author
Aleksandar Osenov
committed
Reverting back to zookeper
1 parent 010582c commit 8f05852

File tree

7 files changed

+33
-8
lines changed

7 files changed

+33
-8
lines changed

devicehive-backend/src/main/resources/application.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ devicehive.cache.commands.ttl.seconds=120
3030
logging.level.com.devicehive=info
3131

3232
bootstrap.servers=127.0.0.1:9092
33+
zookeeper.connect=127.0.0.1:2181
3334
num.partitions=3
3435
replication.factor=1
3536

devicehive-frontend/src/main/resources/application.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ app.executor.size=20
4444

4545
# Kafka properties
4646
bootstrap.servers=127.0.0.1:9092
47+
zookeeper.connect=127.0.0.1:2181
4748
num.partitions=3
4849
replication.factor=1
4950
response.topic.perfix=response_topic_

devicehive-shim-kafka-impl/src/main/resources/kafka.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,6 @@ max.block.ms=60000
3737
buffer.memory=33554432
3838
retention.ms=120000
3939
linger.ms=0
40+
41+
zookeeper.sessionTimeout=10000
42+
zookeeper.connectionTimeout=8000

dockerfiles/devicehive-auth/devicehive-start.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,12 @@ fi
3333

3434
if [ "$SPRING_PROFILES_ACTIVE" = "rpc-client" ]
3535
then
36-
if [ -z "$DH_KAFKA_BOOTSTRAP_SERVERS" ] && [ -z "$DH_KAFKA_ADDRESS" ]
36+
if [ -z "$DH_ZK_ADDRESS" ] \
37+
|| ( [ -z "$DH_KAFKA_BOOTSTRAP_SERVERS" ] && [ -z "$DH_KAFKA_ADDRESS" ] )
3738
then
3839
echo "Some of required environment variables are not set or empty."
3940
echo "Please check following vars are passed to container:"
41+
echo "- DH_ZK_ADDRESS"
4042
echo "And one of variants of Kafka bootstrap parameters:"
4143
echo "- DH_KAFKA_BOOTSTRAP_SERVERS for multiple servers"
4244
echo "or"
@@ -50,28 +52,31 @@ then
5052
fi
5153
fi
5254

53-
# Check Kafka and Postgres are ready
55+
# Check if Zookeper, Kafka and Postgres are ready
5456
while true; do
5557
if [ "$SPRING_PROFILES_ACTIVE" = "rpc-client" ]
5658
then
59+
nc -v -z -w1 "$DH_ZK_ADDRESS" "${DH_ZK_PORT:=2181}"
60+
result_zk=$?
5761
FIRST_KAFKA_SERVER="${DH_KAFKA_BOOTSTRAP_SERVERS%%,*}"
5862
nc -v -z -w1 "${FIRST_KAFKA_SERVER%%:*}" $(expr $FIRST_KAFKA_SERVER : '.*:\([0-9]*\)')
5963
result_kafka=$?
6064
else
65+
result_zk=0
6166
result_kafka=0
6267
fi
6368
nc -v -z -w1 "$DH_POSTGRES_ADDRESS" "${DH_POSTGRES_PORT:=5432}"
6469
result_postgres=$?
6570

66-
if [ "$result_kafka" -eq 0 ] && [ "$result_postgres" -eq 0 ]; then
71+
if [ "$result_kafka" -eq 0 ] && [ "$result_postgres" -eq 0 ] && [ "$result_zk" -eq 0 ]; then
6772
break
6873
fi
6974
sleep 3
7075
done
7176
KAFKA_PARAMETERS=""
7277
if [ "$SPRING_PROFILES_ACTIVE" = "rpc-client" ]
7378
then
74-
KAFKA_PARAMETERS="-Dbootstrap.servers=${DH_KAFKA_BOOTSTRAP_SERVERS}"
79+
KAFKA_PARAMETERS="-Dbootstrap.servers=${DH_KAFKA_BOOTSTRAP_SERVERS} -Dzookeeper.connect=${DH_ZK_ADDRESS}:${DH_ZK_PORT:-2181} -Dzookeeper.connectionTimeout=${DH_ZK_CONNECTIONTIMEOUT:-8000} -Dzookeeper.sessionTimeout=${DH_ZK_SESSIONTIMEOUT:-10000}"
7580
fi
7681

7782
echo "Starting DeviceHive auth"

dockerfiles/devicehive-backend/devicehive-start.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ if [ -z "$DH_POSTGRES_ADDRESS" ] \
1717
|| [ -z "$DH_POSTGRES_DB" ] \
1818
|| [ -z "$REDIS_MASTER_HOST" ] \
1919
|| [ -z "$REDIS_MASTER_PORT" ] \
20+
|| [ -z "$DH_ZK_ADDRESS" ] \
2021
|| ( [ -z "$DH_KAFKA_BOOTSTRAP_SERVERS" ] && [ -z "$DH_KAFKA_ADDRESS" ] )
2122
then
2223
echo "Some of required environment variables are not set or empty."
@@ -27,6 +28,7 @@ then
2728
echo "- DH_POSTGRES_DB"
2829
echo "- REDIS_MASTER_HOST"
2930
echo "- REDIS_MASTER_PORT"
31+
echo "- DH_ZK_ADDRESS"
3032
echo "And one of variants of Kafka bootstrap parameters:"
3133
echo "- DH_KAFKA_BOOTSTRAP_SERVERS for multiple servers"
3234
echo "or"
@@ -39,15 +41,17 @@ then
3941
DH_KAFKA_BOOTSTRAP_SERVERS="${DH_KAFKA_ADDRESS}:${DH_KAFKA_PORT:-9092}"
4042
fi
4143

42-
# Check Kafka and Postgres are ready
44+
# Check if Zookeper, Kafka and Postgres are ready
4345
while true; do
46+
nc -v -z -w1 "$DH_ZK_ADDRESS" "${DH_ZK_PORT:=2181}"
47+
result_zk=$?
4448
FIRST_KAFKA_SERVER="${DH_KAFKA_BOOTSTRAP_SERVERS%%,*}"
4549
nc -v -z -w1 "${FIRST_KAFKA_SERVER%%:*}" $(expr $FIRST_KAFKA_SERVER : '.*:\([0-9]*\)')
4650
result_kafka=$?
4751
nc -v -z -w1 "$DH_POSTGRES_ADDRESS" "${DH_POSTGRES_PORT:=5432}"
4852
result_postgres=$?
4953

50-
if [ "$result_kafka" -eq 0 ] && [ "$result_postgres" -eq 0 ]; then
54+
if [ "$result_kafka" -eq 0 ] && [ "$result_postgres" -eq 0 ] && [ "$result_zk" -eq 0 ]; then
5155
break
5256
fi
5357
sleep 3
@@ -72,6 +76,9 @@ java -server -Xms1g -Xmx2g -XX:+UseG1GC -XX:MaxGCPauseMillis=20 -XX:+DisableExpl
7276
-Dspring.datasource.url="jdbc:postgresql://${DH_POSTGRES_ADDRESS}:${DH_POSTGRES_PORT}/${DH_POSTGRES_DB}" \
7377
-Dspring.datasource.username="${DH_POSTGRES_USERNAME}" \
7478
-Dspring.datasource.password="${DH_POSTGRES_PASSWORD}" \
79+
-Dzookeeper.connect="${DH_ZK_ADDRESS}:${DH_ZK_PORT}" \
80+
-Dzookeeper.connectionTimeout="${DH_ZK_CONNECTIONTIMEOUT:-8000}" \
81+
-Dzookeeper.sessionTimeout="${DH_ZK_SESSIONTIMEOUT:-10000}" \
7582
"./devicehive-backend-${DH_VERSION}-boot.jar" &
7683
PID=$!
7784
wait $PID

dockerfiles/devicehive-frontend/devicehive-start.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ if [ -z "$DH_POSTGRES_ADDRESS" ] \
1515
|| [ -z "$DH_POSTGRES_USERNAME" ] \
1616
|| [ -z "$DH_POSTGRES_PASSWORD" ] \
1717
|| [ -z "$DH_POSTGRES_DB" ] \
18+
|| [ -z "$DH_ZK_ADDRESS" ] \
1819
|| [ -z "$DH_BACKEND_ADDRESS" ] \
1920
|| [ -z "$DH_BACKEND_PORT" ] \
2021
|| [ -z "$REDIS_MASTER_HOST" ] \
@@ -29,6 +30,7 @@ then
2930
echo "- DH_POSTGRES_USERNAME"
3031
echo "- DH_POSTGRES_PASSWORD"
3132
echo "- DH_POSTGRES_DB"
33+
echo "- DH_ZK_ADDRESS"
3234
echo "- DH_BACKEND_ADDRESS"
3335
echo "- DH_BACKEND_PORT"
3436
echo "- REDIS_MASTER_HOST"
@@ -47,16 +49,18 @@ then
4749
DH_KAFKA_BOOTSTRAP_SERVERS="${DH_KAFKA_ADDRESS}:${DH_KAFKA_PORT:-9092}"
4850
fi
4951

50-
# Check if Kafka, Backend and Postgres are ready
52+
# Check if Zookeper, Kafka, Backend and Postgres are ready
5153
while true; do
54+
nc -v -z -w1 "$DH_ZK_ADDRESS" "${DH_ZK_PORT:=2181}"
55+
result_zk=$?
5256
FIRST_KAFKA_SERVER="${DH_KAFKA_BOOTSTRAP_SERVERS%%,*}"
5357
nc -v -z -w1 "${FIRST_KAFKA_SERVER%%:*}" $(expr $FIRST_KAFKA_SERVER : '.*:\([0-9]*\)')
5458
result_kafka=$?
5559
nc -v -z -w1 "$DH_POSTGRES_ADDRESS" "${DH_POSTGRES_PORT:=5432}"
5660
result_postgres=$?
5761
nc -v -z -w1 "$DH_BACKEND_ADDRESS" "${DH_BACKEND_PORT:=8000}"
5862
result_backend=$?
59-
if [ "$result_kafka" -eq 0 ] && [ "$result_postgres" -eq 0 ] && [ "$result_backend" -eq 0 ]; then
63+
if [ "$result_kafka" -eq 0 ] && [ "$result_postgres" -eq 0 ] && [ "$result_zk" -eq 0 ] && [ "$result_backend" -eq 0 ]; then
6064
break
6165
fi
6266
sleep 3
@@ -83,6 +87,9 @@ java -server -Xms1g -Xmx2g -XX:+UseG1GC -XX:MaxGCPauseMillis=20 -XX:+DisableExpl
8387
-Dspring.datasource.url="jdbc:postgresql://${DH_POSTGRES_ADDRESS}:${DH_POSTGRES_PORT:-5432}/${DH_POSTGRES_DB}" \
8488
-Dspring.datasource.username="${DH_POSTGRES_USERNAME}" \
8589
-Dspring.datasource.password="${DH_POSTGRES_PASSWORD}" \
90+
-Dzookeeper.connect="${DH_ZK_ADDRESS}:${DH_ZK_PORT:-2181}" \
91+
-Dzookeeper.connectionTimeout="${DH_ZK_CONNECTIONTIMEOUT:-8000}" \
92+
-Dzookeeper.sessionTimeout="${DH_ZK_SESSIONTIMEOUT:-10000}" \
8693
"./devicehive-frontend-${DH_VERSION}-boot.jar" &
8794
PID=$!
8895
wait "$PID"

dockerfiles/devicehive-kafka.Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ ENV KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=CLIENT:PLAINTEXT,EXTERNAL:PLAINTEXT
1414
ENV KAFKA_CFG_LISTENERS=CLIENT://:9092
1515
ENV KAFKA_CFG_ADVERTISED_LISTENERS=CLIENT://kafka:9092
1616
ENV KAFKA_CFG_INTER_BROKER_LISTENER_NAME=CLIENT
17+
ENV KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper:2181
1718
ENV ALLOW_PLAINTEXT_LISTENER=yes
1819

1920
USER root

0 commit comments

Comments
 (0)