4c88f6e2629dc165876ce3873c53c55866b6e288
[demos/kafka/wordcount] / README.sh
1 #!/bin/bash
2
3 FORTUNE=juplo/wordcount--fortune:1.0.0
4 RECORDER=juplo/wordcount--recorder:1.1.2
5 USERS=juplo/wordcount--users:1.0.5
6 SPLITTER=juplo/wordcount--splitter:1.1.5
7 COUNTER=juplo/wordcount--counter:1.2.14
8 TOP10=juplo/wordcount--top10:1.1.2
9 QUERY=juplo/wordcount--query:1.0.5
10
11 if [ "$1" = "cleanup" ]
12 then
13   docker compose down -v --remove-orphans
14   docker image rm $FORTUNE
15   docker image rm $RECORDER
16   docker image rm $USERS
17   docker image rm $SPLITTER
18   docker image rm $COUNTER
19   docker image rm $TOP10
20   docker image rm $QUERY
21   exit
22 fi
23
24 if [[
25   $(docker image ls -q $FORTUNE) == "" ||
26   $(docker image ls -q $RECORDER) == "" ||
27   $(docker image ls -q $USERS) == "" ||
28   $(docker image ls -q $SPLITTER) == "" ||
29   $(docker image ls -q $COUNTER) == "" ||
30   $(docker image ls -q $TOP10) == "" ||
31   $(docker image ls -q $QUERY) == "" ||
32   "$1" = "build"
33 ]]
34 then
35   mvn clean package || exit
36   docker compose rm -svf recorder users splitter counter top10 query
37   ( cd fortune; ./README.sh $FORTUNE; )
38   mvn -f recorder/pom.xml docker:build
39   mvn -f users/pom.xml docker:build
40   mvn -f splitter/pom.xml docker:build
41   mvn -f counter/pom.xml docker:build
42   mvn -f top10/pom.xml docker:build
43   mvn -f query/pom.xml docker:build
44 else
45   echo "Using existing images:"
46   docker image ls $FORTUNE
47   docker image ls $RECORDER
48   docker image ls $USERS
49   docker image ls $SPLITTER
50   docker image ls $COUNTER
51   docker image ls $TOP10
52   docker image ls $QUERY
53 fi
54
55
56 docker compose up setup
57
58 echo "Starting the service 'users'..."
59 docker compose up -d users
60 while [ "$(http users.localhost/actuator/health 2> /dev/null | jq -r .status 2> /dev/null)" != "UP" ]; do echo "Waiting for service users..."; sleep 1; done
61 http -v post users.localhost username=bart firstName=Bart lastName=Simpson sex=MALE
62 http -v post users.localhost username=nerd firstName=Jane lastName=Doe sex=FEMALE
63 http -v post users.localhost username=riddler firstName=Rumpel lastName=Stilzchen sex=MALE
64
65 echo "Starting the other instances..."
66 docker compose up -d recordings
67 docker compose up -d splitter
68 docker compose up -d counter
69 docker compose up -d top10
70 docker compose up -d query
71
72 echo "Starting the simulated users..."
73 docker compose up -d bart nerd riddler
74
75 while [ "$(http query.localhost/actuator/health 2>/dev/null | jq -r .status 2> /dev/null)" != "UP" ]; do echo "Waiting for service query..."; sleep 1; done
76 http -v query.localhost/bart
77 sleep 1
78 http -v query.localhost/bart
79 sleep 1
80 http -v query.localhost/bart
81 sleep 1
82 http -v query.localhost/bart
83 sleep 1
84 http -v query.localhost/bart
85 sleep 1
86 http -v query.localhost/bart
87 sleep 1
88 http -v query.localhost/bart
89 http -v query.localhost/nerd
90 http -v query.localhost/riddler
91
92 # docker compose up -d --scale query=5 query
93 http -v --follow query.localhost/bart
94 sleep 1
95 http -v --follow query.localhost/bart
96 sleep 1
97 http -v --follow query.localhost/bart
98 sleep 1
99 http -v --follow query.localhost/bart
100 sleep 1
101 http -v --follow query.localhost/bart
102 sleep 1
103 http -v --follow query.localhost/bart
104 sleep 1
105 http -v --follow query.localhost/bart
106
107 http -v --follow query.localhost/nerd
108 http -v --follow query.localhost/nerd
109 http -v --follow query.localhost/nerd
110 http -v --follow query.localhost/nerd
111 http -v --follow query.localhost/nerd
112
113 http -v --follow query.localhost/riddler
114 http -v --follow query.localhost/riddler
115 http -v --follow query.localhost/riddler
116 http -v --follow query.localhost/riddler
117 http -v --follow query.localhost/riddler