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