Using names instead of numbers as key for the messages
[demos/kafka/deduplication] / README.sh
1 #!/bin/bash
2
3 if [ "$1" = "cleanup" ]
4 then
5   docker-compose down
6   mvn clean
7   rm *.txt
8   exit
9 fi
10
11 if [[ $(docker image ls -q juplo/deduplicator:streams) == "" ]]
12 then
13   mvn package
14   docker build -t juplo/deduplicator:streams .
15 else
16   echo "Using image existing image:"
17   docker image ls juplo/deduplicator:streams
18 fi
19
20 docker-compose up -d zookeeper kafka
21
22 if [ ! -e data.txt ];
23 then
24   echo ./create-data.sh
25 fi
26
27 while ! [[ $(zookeeper-shell zookeeper:2181 ls /brokers/ids 2> /dev/null) =~ 1001 ]];
28 do
29   echo "Waiting for kafka...";
30   sleep 1;
31 done
32
33 kafka-topics --create --zookeeper zookeeper:2181 --replication-factor 1 --partitions 3 --topic input
34 kafka-topics --create --zookeeper zookeeper:2181 --replication-factor 1 --partitions 3 --topic output
35
36 docker-compose up -d deduplicator
37
38 while ! [[ $(http :8080/actuator/health 2>/dev/null | jq -r .components.streams.status) == "RUNNING" ]];
39 do
40   echo "Waiting for Streams-Application...";
41   sleep 1;
42 done
43
44 cat data.txt | kafkacat -K: -b localhost:9092 -t input
45
46 kafkacat -C -b localhost:9092 -t input -e | wc -l
47 kafkacat -C -b localhost:9092 -t output -e | wc -l
48
49 kafkacat -C -b localhost:9092 -t output -e  -f'%k:%s\n' | awk -F: '/^peter/ { print $2 }' > result_peter.txt
50 kafkacat -C -b localhost:9092 -t output -e  -f'%k:%s\n' | awk -F: '/^franz/ { print $2 }' > result_franz.txt
51 kafkacat -C -b localhost:9092 -t output -e  -f'%k:%s\n' | awk -F: '/^ute/   { print $2 }' > result_ute.txt
52 kafkacat -C -b localhost:9092 -t output -e  -f'%k:%s\n' | awk -F: '/^klaus/ { print $2 }' > result_klaus.txt
53 kafkacat -C -b localhost:9092 -t output -e  -f'%k:%s\n' | awk -F: '/^paul/  { print $2 }' > result_paul.txt
54 kafkacat -C -b localhost:9092 -t output -e  -f'%k:%s\n' | awk -F: '/^petra/ { print $2 }' > result_petra.txt
55 kafkacat -C -b localhost:9092 -t output -e  -f'%k:%s\n' | awk -F: '/^siggi/ { print $2 }' > result_siggi.txt