Added actuators and implemented an indicator that reports the streams-state
[demos/kafka/deduplication] / README.sh
1 #!/bin/bash
2
3 if [ "$1" = "cleanup" ]
4 then
5   docker-compose down
6   mvn clean
7   exit
8 fi
9
10 if [[ $(docker image ls -q juplo/deduplicator:streams) == "" ]]
11 then
12   mvn package
13   docker build -t juplo/deduplicator:streams .
14 else
15   echo "Using image existing image:"
16   docker image ls juplo/deduplicator:streams
17 fi
18
19 docker-compose up -d zookeeper kafka
20
21 while ! [[ $(zookeeper-shell zookeeper:2181 ls /brokers/ids 2> /dev/null) =~ 1001 ]];
22 do
23   echo "Waiting for kafka...";
24   sleep 1;
25 done
26
27 kafka-topics --create --zookeeper zookeeper:2181 --replication-factor 1 --partitions 3 --topic input
28 kafka-topics --create --zookeeper zookeeper:2181 --replication-factor 1 --partitions 3 --topic output
29
30 docker-compose up -d deduplicator
31
32 while ! [[ $(http :8080/actuator/health 2>/dev/null | jq -r .components.streams.status) == "RUNNING" ]];
33 do
34   echo "Waiting for Streams-Application...";
35   sleep 1;
36 done
37
38 cat data.txt | kafkacat -K: -b localhost:9092 -t input
39
40 kafkacat -C -b localhost:9092 -t input -e | wc -l
41 kafkacat -C -b localhost:9092 -t output -e | wc -l
42
43 kafkacat -C -b localhost:9092 -t output -e  -f'%k:%s\n' | grep ^0 > result_0.txt
44 kafkacat -C -b localhost:9092 -t output -e  -f'%k:%s\n' | grep ^1 > result_1.txt
45 kafkacat -C -b localhost:9092 -t output -e  -f'%k:%s\n' | grep ^2 > result_2.txt
46 kafkacat -C -b localhost:9092 -t output -e  -f'%k:%s\n' | grep ^3 > result_3.txt
47 kafkacat -C -b localhost:9092 -t output -e  -f'%k:%s\n' | grep ^4 > result_4.txt
48 kafkacat -C -b localhost:9092 -t output -e  -f'%k:%s\n' | grep ^5 > result_5.txt
49 kafkacat -C -b localhost:9092 -t output -e  -f'%k:%s\n' | grep ^6 > result_6.txt