X-Git-Url: https://juplo.de/gitweb/?a=blobdiff_plain;ds=inline;f=README.sh;h=25e36da1f0cfd33cc8f305b2ed2080a333d18ee2;hb=refs%2Fheads%2Fmaster;hp=050f3397e3825dc8935eeb2375274008e619bcba;hpb=d92b59d5e31afbd4cbdf4486c398ce9a1e52ef4c;p=demos%2Fkafka%2Fwordcount diff --git a/README.sh b/README.sh index 050f339..62805c6 100755 --- a/README.sh +++ b/README.sh @@ -1,21 +1,25 @@ #!/bin/bash -FORTUNE=juplo/wordcount--fortune:1.0.0 -RECORDER=juplo/wordcount--recorder:1.0.0 -USERS=juplo/wordcount--users:1.0.0 -COUNTER=juplo/wordcount--counter:1.0.0 -TOP10=juplo/wordcount--top10:1.0.0 -QUERY=juplo/wordcount--query:1.0.2 +FORTUNE=juplo/wordcount--fortune:1.0.1 +RECORDER=juplo/wordcount--recorder:1.2.2 +USERS=juplo/wordcount--users:1.0.7 +SPLITTER=juplo/wordcount--splitter:1.2.2 +COUNTER=juplo/wordcount--counter:1.4.2 +TOP10=juplo/wordcount--top10:1.4.2 +QUERY=juplo/wordcount--query:2.1.2 +POPULAR=juplo/wordcount--popular:1.3.2 if [ "$1" = "cleanup" ] then - docker-compose down -v + docker compose down -v --remove-orphans docker image rm $FORTUNE docker image rm $RECORDER docker image rm $USERS + docker image rm $SPLITTER docker image rm $COUNTER docker image rm $TOP10 docker image rm $QUERY + docker image rm $POPULAR exit fi @@ -23,43 +27,149 @@ if [[ $(docker image ls -q $FORTUNE) == "" || $(docker image ls -q $RECORDER) == "" || $(docker image ls -q $USERS) == "" || + $(docker image ls -q $SPLITTER) == "" || $(docker image ls -q $COUNTER) == "" || $(docker image ls -q $TOP10) == "" || $(docker image ls -q $QUERY) == "" || + $(docker image ls -q $POPULAR) == "" || "$1" = "build" ]] then - git submodule update --init - mvn clean package || exit - docker-compose rm -svf recorder users counter top10 query + docker compose rm -svf bart riddler nerd recorder users splitter counter top10 query popular +fi + +if [[ $(docker image ls -q $FORTUNE) == "" || "$1" = "build" ]] +then + echo "Building image $FORTUNE" ( cd fortune; ./README.sh $FORTUNE; ) - mvn -f recorder/pom.xml docker:build - mvn -f users/pom.xml docker:build - mvn -f counter/pom.xml docker:build - mvn -f top10/pom.xml docker:build - mvn -f query/pom.xml docker:build else - echo "Using existing images:" - docker image ls $FORTUNE - docker image ls $RECORDER - docker image ls $USERS - docker image ls $COUNTER - docker image ls $TOP10 - docker image ls $QUERY + echo -n "Using existing image for $FORTUNE: " + docker image ls --format json $FORTUNE | jq -r '(.ID + " - " + .CreatedSince)' +fi + +if [[ $(docker image ls -q $RECORDER) == "" || "$1" = "build" ]] +then + echo "Building image $RECORDER" + mvn -f recorder/pom.xml clean package docker:build +else + echo -n "Using existing image for $RECORDER: " + docker image ls --format json $RECORDER | jq -r '(.ID + " - " + .CreatedSince)' +fi + +if [[ $(docker image ls -q $USERS) == "" || "$1" = "build" ]] +then + echo "Building image $USERS" + mvn -f users/pom.xml clean package docker:build +else + echo -n "Using existing image for $USERS: " + docker image ls --format json $USERS | jq -r '(.ID + " - " + .CreatedSince)' fi +if [[ $(docker image ls -q $SPLITTER) == "" || "$1" = "build" ]] +then + echo "Building image $SPLITTER" + mvn -f splitter/pom.xml clean package docker:build +else + echo -n "Using existing image for $SPLITTER: " + docker image ls --format json $SPLITTER | jq -r '(.ID + " - " + .CreatedSince)' +fi + +if [[ $(docker image ls -q $COUNTER) == "" || "$1" = "build" ]] +then + echo "Building image $COUNTER" + mvn -f counter/pom.xml clean package docker:build +else + echo -n "Using existing image for $COUNTER: " + docker image ls --format json $COUNTER | jq -r '(.ID + " - " + .CreatedSince)' +fi + +if [[ $(docker image ls -q $TOP10) == "" || "$1" = "build" ]] +then + echo "Building image $TOP10" + mvn -f top10/pom.xml clean package docker:build +else + echo -n "Using existing image for $TOP10: " + docker image ls --format json $TOP10 | jq -r '(.ID + " - " + .CreatedSince)' +fi + +if [[ $(docker image ls -q $QUERY) == "" || "$1" = "build" ]] +then + echo "Building image $QUERY" + mvn -f query/pom.xml clean package docker:build +else + echo -n "Using existing image for $QUERY: " + docker image ls --format json $QUERY | jq -r '(.ID + " - " + .CreatedSince)' +fi + +if [[ $(docker image ls -q $POPULAR) == "" || "$1" = "build" ]] +then + echo "Building image $POPULAR" + mvn -f popular/pom.xml clean package docker:build +else + echo -n "Using existing image for $POPULAR: " + docker image ls --format json $POPULAR | jq -r '(.ID + " - " + .CreatedSince)' +fi + + +docker compose up setup + +echo "Starting the service 'users'..." +docker compose up -d users +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 +http -v post users.localhost username=bart firstName=Bart lastName=Simpson sex=MALE +http -v post users.localhost username=nerd firstName=Jane lastName=Doe sex=FEMALE +http -v post users.localhost username=riddler firstName=Rumpel lastName=Stilzchen sex=MALE + +echo "Starting the other instances..." +docker compose up -d recorder +docker compose up -d splitter +docker compose up -d counter +docker compose up -d top10 +docker compose up -d query + +echo "Starting the simulated users..." +docker compose up -d bart nerd riddler -docker-compose up -d zookeeper kafka cli +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 +http -v query.localhost/bart +sleep 1 +http -v query.localhost/bart +sleep 1 +http -v query.localhost/bart +sleep 1 +http -v query.localhost/bart +sleep 1 +http -v query.localhost/bart +sleep 1 +http -v query.localhost/bart +sleep 1 +http -v query.localhost/bart +http -v query.localhost/nerd +http -v query.localhost/riddler -echo "Waiting for the Kafka-Cluster to become ready..." -docker-compose exec cli cub kafka-ready -b kafka:9092 1 60 > /dev/null 2>&1 || exit 1 -docker-compose exec cli zookeeper-shell zookeeper:2181 ls /brokers/ids +# docker compose up -d --scale query=5 query +http -v --follow query.localhost/bart +sleep 1 +http -v --follow query.localhost/bart +sleep 1 +http -v --follow query.localhost/bart +sleep 1 +http -v --follow query.localhost/bart +sleep 1 +http -v --follow query.localhost/bart +sleep 1 +http -v --follow query.localhost/bart +sleep 1 +http -v --follow query.localhost/bart -docker-compose up -d users -while [ "$(http :8082/actuator/health | jq -r .status 2> /dev/null)" != "UP" ]; do echo "Waiting for service users..."; sleep 1; done -http -v post :8082/users username=bart firstName=Bart lastName=Simpson sex=MALE -http -v post :8082/users username=nerd firstName=Jane lastName=Doe sex=FEMALE -http -v post :8082/users username=riddler firstName=Rumpel lastName=Stilzchen sex=MALE +http -v --follow query.localhost/nerd +http -v --follow query.localhost/nerd +http -v --follow query.localhost/nerd +http -v --follow query.localhost/nerd +http -v --follow query.localhost/nerd -echo "Starting all instances..." -docker-compose up -d +http -v --follow query.localhost/riddler +http -v --follow query.localhost/riddler +http -v --follow query.localhost/riddler +http -v --follow query.localhost/riddler +http -v --follow query.localhost/riddler