From 08fdf0d8270bc1a039d63448aa9357d62a5bd166 Mon Sep 17 00:00:00 2001 From: Viktor Gamov Date: Wed, 17 Apr 2024 00:11:28 -0400 Subject: [PATCH] Added server health checks, tune controller and broker health checks. --- Makefile | 45 ++++++++++++++++++++++++++++++++------------- docker-compose.yml | 23 +++++++++++++++-------- 2 files changed, 47 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index 03894e7..fde3dca 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,6 @@ +GREEN=\033[0;32m +NC=\033[0m # No Color + base: create tables import info schema: @@ -11,9 +14,10 @@ schema: -dimensions="" create: - docker compose build --no-cache +# docker compose build --no-cache docker compose up -d - @echo "Waiting for Pinot Controller to be ready..." + @echo "------------------------------------------------" + @echo "\nā³ Waiting for Pinot Controller to be ready..." @while true; do \ STATUS_CODE=$$(curl -s -o /dev/null -w '%{http_code}' \ 'http://localhost:9000/health'); \ @@ -23,9 +27,9 @@ create: sleep 2; \ echo "Waiting for Pinot Controller..."; \ done - @echo "šŸ· Pinot Controller is ready." + @printf "$(GREEN)āœ”$(NC) šŸ·šŸ•ŗ Pinot Controller is ready!\n" - @echo "Waiting for Pinot Broker to be ready..." + @echo "\nā³ Waiting for Pinot Broker to be ready..." @while true; do \ STATUS_CODE=$$(curl -s -o /dev/null -w '%{http_code}' \ 'http://localhost:8099/health'); \ @@ -35,14 +39,26 @@ create: sleep 1; \ echo "Waiting for Pinot Broker..."; \ done - @echo "šŸ· Pinot Broker is ready to receive queries." - - @echo "šŸŖ² Waiting for Kafka to be ready..." + @printf "$(GREEN)āœ”$(NC) šŸ·šŸ’ Pinot Broker is ready to receive queries!\n" + + @echo "\nā³ Waiting for Pinot Server to be ready..." + @while true; do \ + STATUS_CODE=$$(curl -s -o /dev/null -w '%{http_code}' \ + 'http://localhost:8097/health/readiness'); \ + if [ "$$STATUS_CODE" -eq 200 ]; then \ + break; \ + fi; \ + sleep 1; \ + echo "Waiting for Pinot Server..."; \ + done + @printf "$(GREEN)āœ”$(NC) šŸ·šŸ‘©ā€šŸ”§ Pinot Server is ready to receive requests!\n" + + @echo "\nā³ Waiting for Kafka to be ready..." @while ! nc -z localhost 9092; do \ sleep 1; \ echo "Waiting for Kafka..."; \ done - @echo "šŸŖ² Kafka is ready." + @printf "$(GREEN)āœ”$(NC) šŸŖ² Kafka is ready!\n" topic: docker exec kafka kafka-topics.sh \ @@ -51,21 +67,22 @@ topic: --topic movie_ratings tables: - docker exec pinot-controller ./bin/pinot-admin.sh \ + @echo "\n šŸŽ„ Creating movies table..." + @docker exec pinot-controller ./bin/pinot-admin.sh \ AddTable \ -tableConfigFile /tmp/pinot/table/movies.table.json \ -schemaFile /tmp/pinot/table/movies.schema.json \ -exec - sleep 5 - - docker exec pinot-controller ./bin/pinot-admin.sh \ + @echo "\n šŸæ Creating ratings table..." + @docker exec pinot-controller ./bin/pinot-admin.sh \ AddTable \ -tableConfigFile /tmp/pinot/table/ratings.table.json \ -schemaFile /tmp/pinot/table/ratings.schema.json \ -exec + import: - docker exec pinot-controller ./bin/pinot-admin.sh \ + @docker exec pinot-controller ./bin/pinot-admin.sh \ LaunchDataIngestionJob \ -jobSpecFile /tmp/pinot/table/jobspec.yaml @@ -91,7 +108,9 @@ validate: fi info: + @printf "\n==========================================================\n" @printf "šŸ· Pinot Query UI - \033[4mhttp://localhost:9000\033[0m\n" + @printf "==========================================================\n" destroy: docker compose down -v diff --git a/docker-compose.yml b/docker-compose.yml index 832879a..733c8cf 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -33,14 +33,14 @@ services: ports: - "9000:9000" environment: - JAVA_OPTS: "-Dplugins.dir=/opt/pinot/plugins -Xms1G -Xmx4G -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -Xloggc:gc-pinot-controller.log" + JAVA_OPTS: "-Dplugins.dir=/opt/pinot/plugins -Xms1G -Xmx4G -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -Xlog:gc:gc-pinot-controller.log" depends_on: - pinot-zookeeper healthcheck: test: [ "CMD-SHELL", "curl -f http://localhost:9000/health || exit 1" ] - interval: 30s + interval: 10s timeout: 10s - retries: 3 + retries: 5 start_period: 10s volumes: - ./table/:/tmp/pinot/table/ @@ -54,7 +54,7 @@ services: ports: - "8099:8099" environment: - JAVA_OPTS: "-Dplugins.dir=/opt/pinot/plugins -Xms4G -Xmx4G -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -Xloggc:gc-pinot-broker.log" + JAVA_OPTS: "-Dplugins.dir=/opt/pinot/plugins -Xms4G -Xmx4G -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -Xlog:gc:gc-pinot-broker.log" depends_on: pinot-controller: condition: service_healthy @@ -62,8 +62,8 @@ services: test: [ "CMD-SHELL", "curl -f http://localhost:8099/health || exit 1" ] interval: 30s timeout: 10s - retries: 3 - start_period: 10s + retries: 5 + start_period: 30s pinot-server: image: apachepinot/pinot:1.1.0-21-openjdk @@ -71,11 +71,18 @@ services: restart: unless-stopped container_name: "pinot-server" ports: + - "8097:8097" - "8098:8098" environment: - JAVA_OPTS: "-Dplugins.dir=/opt/pinot/plugins -Xms4G -Xmx16G -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -Xloggc:gc-pinot-server.log" + JAVA_OPTS: "-Dplugins.dir=/opt/pinot/plugins -Xms4G -Xmx16G -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -Xlog:gc:gc-pinot-server.log" + healthcheck: + test: [ "CMD-SHELL", "curl -f http://localhost:8097/health/readiness || exit 1" ] + interval: 30s + timeout: 10s + retries: 5 + start_period: 10s depends_on: - pinot-broker: + pinot-controller: condition: service_healthy kafka: