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 up setup
-docker-compose up -d gateway requests-1 requests-2
+docker-compose up -d gateway requests-1 requests-2 adder-1 adder-2
while ! [[ $(http 0:8080/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Waiting for gateway..."; sleep 1; done
while ! [[ $(http 0:8081/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Waiting for requests-1..."; sleep 1; done
while ! [[ $(http 0:8082/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Waiting for requests-2..."; sleep 1; done
+while ! [[ $(http 0:8091/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Waiting for adder-1..."; sleep 1; done
+while ! [[ $(http 0:8092/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Waiting for adder-2..."; sleep 1; done
-docker-compose up -d peter klaus
+echo 6 | http -v :8080/peter
+echo 6 | http -v :8080/klaus
-docker-compose up -d adder-1
-while ! [[ $(http 0:8091/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Waiting for adder-1..."; sleep 1; done
while [[ "$(http :8091/results | jq -r .)" == "{}" ]]; do echo "Waiting for some results to show up on adder-1..."; sleep 1; done
-http -v --pretty none -S :8091/results
-echo
-
-sleep 3
echo "Resultate für adder-1"
-http -v --pretty none -S :8091/results
-echo
+http -v :8091/results
-echo "Resultate für peter von adder-1"
-http :8091/results/peter | jq .[].sum | uniq
-echo "Resultate für klaus von adder-1"
-http :8091/results/klaus | jq .[].sum | uniq
-
-
-docker-compose up -d adder-2
-while ! [[ $(http 0:8092/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Waiting for adder-2..."; sleep 1; done
while [[ "$(http :8092/results | jq -r .)" == "{}" ]]; do echo "Waiting for some results to show up on adder-2..."; sleep 1; done
-http -v --pretty none -S :8092/results
-echo
-
-sleep 3
echo "Resultate für adder-2"
-http -v --pretty none -S :8092/results
-echo
-
-echo "Resultate für peter von adder-1"
-http :8091/results/peter | jq .[].sum | uniq
-echo "Resultate für klaus von adder-1"
-http :8091/results/klaus | jq .[].sum | uniq
-
-echo "Resultate für peter von adder-2"
-http :8092/results/peter | jq .[].sum | uniq
-echo "Resultate für klaus von adder-2"
-http :8092/results/klaus | jq .[].sum | uniq
+http -v :8092/results
docker-compose stop adder-1
-until [ $(http --check-status :8092/results/peter 2> /dev/null) ]; do echo "Waiting for some results for peter to show up on adder-2..."; sleep 1; done
-until [ $(http --check-status :8092/results/klaus 2> /dev/null) ]; do echo "Waiting for some results for peter to show up on adder-2..."; sleep 1; done
+echo 66 | http -v :8080/peter
+echo 66 | http -v :8080/klaus
+sleep 1
echo "Resultate für adder-2"
-http -v --pretty none -S :8092/results
-echo
-
-echo "Resultate für peter von adder-2"
-http :8092/results/peter | jq .[].sum | uniq
-echo "Resultate für klaus von adder-2"
-http :8092/results/klaus | jq .[].sum | uniq
+http -v :8092/results
-docker-compose kill -s 9 peter klaus
+docker-compose start adder-1
+while ! [[ $(http 0:8091/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Waiting for adder-1..."; sleep 1; done
+while [[ "$(http :8091/results | jq -r .)" == "{}" ]];
+do
+ echo "Waiting for some results to show up on adder-1...";
+ echo 666 | http -v :8080/peter
+ echo 666 | http -v :8080/klaus
+ sleep 1;
+done
+echo "Resultate für adder-1"
+http -v :8091/results
+echo "Resultate für adder-2"
+http -v :8092/results
{
Integer partition = tp.partition();
log.info("{} - adding partition: {}", id, partition);
- this.partitions.add(partition);
- StateDocument document =
- stateRepository
- .findById(Integer.toString(partition))
- .orElse(new StateDocument(partition));
- recordHandler.addPartition(partition, document.state);
- for (String user : document.state.keySet())
- {
- log.info(
- "{} - Restored state for partition={}|user={}: {}",
- id,
- partition,
- user,
- document.state.get(user));
- }
- adderResults.addPartition(partition, document.results);
});
}
{
Integer partition = tp.partition();
log.info("{} - removing partition: {}", id, partition);
- this.partitions.remove(partition);
- Map<String, AdderResult> state = recordHandler.removePartition(partition);
+ Map<String, AdderResult> state = recordHandler.getState(partition).getState();
for (String user : state.keySet())
{
log.info(
user,
state.get(user));
}
- Map<String, List<AdderResult>> results = adderResults.removePartition(partition);
- stateRepository.save(new StateDocument(partition, state, results));
});
}
}