Skip to content

Commit 668b334

Browse files
committed
working flink-data-generator project
1 parent df73fd0 commit 668b334

File tree

27 files changed

+1102
-182
lines changed

27 files changed

+1102
-182
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,8 @@ on:
1010
workflow_dispatch: # Allows manual triggering
1111

1212
jobs:
13-
lint:
14-
name: 🧹 Code Quality Checks
15-
runs-on: ubuntu-latest
16-
steps:
17-
- name: 📥 Checkout code
18-
uses: actions/checkout@v4
19-
20-
- name: ☕ Set up JDK 21
21-
uses: actions/setup-java@v4
22-
with:
23-
java-version: '21'
24-
distribution: 'temurin'
25-
cache: 'gradle'
26-
27-
- name: 🛠️ Setup Gradle
28-
uses: gradle/gradle-build-action@v3
29-
with:
30-
gradle-version: wrapper
31-
32-
- name: 🔍 Check code style
33-
run: ./gradlew checkstyleMain checkstyleTest --no-daemon
34-
35-
- name: 🔍 Check for deprecated API usage
36-
run: ./gradlew spotbugsMain spotbugsTest --no-daemon
37-
3813
build:
3914
name: 🚀 Build and Test
40-
needs: lint
4115
runs-on: ${{ matrix.os }}
4216
strategy:
4317
matrix:

.windsurfrules

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,10 @@
3333
## brew (for mac)
3434

3535
- use brew for installing dependencies
36-
- prefer to use Brewfile for managing dependencies
36+
- prefer to use Brewfile for managing dependencies
37+
38+
## Flink
39+
40+
use Apache Kafka® and Kafka Streams version 3.8.0+
41+
use Apache Flink version v 1.20
42+
for org.apache.flink:flink-connector-kafka dependency use version 3.4.0-1.20 <- this is correct version format

Brewfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ brew "fd" # Better find
1818
brew "ripgrep" # Better grep
1919

2020
# Terraform for infrastructure
21-
brew "terraform"
21+
tap "hashicorp/tap"
22+
brew "hashicorp/tap/terraform"
2223

2324
# Kafka tools
2425
brew "kcat" # Kafka cat utility

Makefile

Lines changed: 117 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# 🛠️ Flink for Java Workshop - Setup Makefile 🛠️
22

33
# Colors for better readability
4-
BLUE=\033[0;34m
5-
GREEN=\033[0;32m
6-
YELLOW=\033[1;33m
7-
RED=\033[0;31m
8-
BOLD=\033[1m
9-
RESET=\033[0m
4+
BLUE:=$(shell printf "\033[0;34m")
5+
GREEN:=$(shell printf "\033[0;32m")
6+
YELLOW:=$(shell printf "\033[1;33m")
7+
RED:=$(shell printf "\033[0;31m")
8+
BOLD:=$(shell printf "\033[1m")
9+
RESET:=$(shell printf "\033[0m")
1010

1111
# Emojis for better readability
1212
CHECK=✅
@@ -17,33 +17,59 @@ ROCKET=🚀
1717
COFFEE=☕
1818
CLOCK=🕒
1919
CLOUD=☁️
20+
STAR=⭐
21+
TERRAFORM=🌐
2022

2123
# Default target
2224
.PHONY: help
2325
help:
2426
@echo "${BLUE}${ROCKET} Flink for Java Workshop - Setup Makefile ${RESET}"
2527
@echo ""
2628
@echo "${GREEN}${BOLD}Available targets:${RESET}"
27-
@echo " ${YELLOW}setup-mac${RESET} - Install all required dependencies on macOS using Brewfile"
28-
@echo " ${YELLOW}setup-linux${RESET} - Install all required dependencies on Linux"
29-
@echo " ${YELLOW}setup-terraform${RESET} - Setup Terraform for Confluent Cloud"
30-
@echo " ${YELLOW}terraform-init${RESET} - Initialize Terraform"
31-
@echo " ${YELLOW}terraform-plan${RESET} - Plan Terraform changes"
32-
@echo " ${YELLOW}terraform-apply${RESET} - Apply Terraform changes"
33-
@echo " ${YELLOW}terraform-destroy${RESET} - Destroy Terraform-managed infrastructure"
34-
@echo " ${YELLOW}terraform-output${RESET} - Generate cloud.properties from Terraform output"
35-
@echo " ${YELLOW}tf-init${RESET} - Shorthand for terraform-init"
36-
@echo " ${YELLOW}tf-plan${RESET} - Shorthand for terraform-plan"
37-
@echo " ${YELLOW}tf-apply${RESET} - Shorthand for terraform-apply"
38-
@echo " ${YELLOW}tf-destroy${RESET} - Shorthand for terraform-destroy"
39-
@echo " ${YELLOW}tf-out${RESET} - Shorthand for terraform-output"
40-
@echo " ${YELLOW}cc-setup${RESET} - Complete Confluent Cloud setup (init, plan, apply, output)"
41-
@echo " ${YELLOW}cc-teardown${RESET} - Teardown Confluent Cloud infrastructure"
42-
@echo " ${YELLOW}clean${RESET} - Clean up temporary files"
43-
@echo " ${YELLOW}check-prereqs${RESET} - Check if all prerequisites are installed"
44-
@echo " ${YELLOW}update-brew-deps${RESET} - Update Homebrew dependencies using Brewfile"
45-
@echo " ${YELLOW}ci-checks${RESET} - Run CI checks locally"
46-
@echo " ${YELLOW}docker-build${RESET} - Build Docker image locally"
29+
@echo ""
30+
@echo "${YELLOW}${STAR} Environment Setup:${RESET}"
31+
@echo "${BLUE}${INFO} 🔧 setup-mac${RESET} - Install all required dependencies on macOS using Brewfile"
32+
@echo "${BLUE}${INFO} 🔧 setup-linux${RESET} - Install all required dependencies on Linux"
33+
@echo "${BLUE}${INFO} 🔍 check-prereqs${RESET} - Check if all prerequisites are installed"
34+
@echo "${BLUE}${INFO} 🔄 update-brew-deps${RESET} - Update Homebrew dependencies using Brewfile"
35+
@echo ""
36+
@echo "${YELLOW}${STAR} Build & Run:${RESET}"
37+
@echo "${BLUE}${INFO} 🏗️ build${RESET} - Build the entire project with Gradle"
38+
@echo "${BLUE}${INFO} 🏗️ build-data-generator${RESET} - Build the Flink Data Generator"
39+
@echo "${BLUE}${INFO} 🚀 run-streaming${RESET} - Run the Flink Streaming application"
40+
@echo "${BLUE}${INFO} 🚀 run-sql${RESET} - Run the Flink SQL application"
41+
@echo "${BLUE}${INFO} 🧪 ci-checks${RESET} - Run CI checks locally"
42+
@echo ""
43+
@echo "${YELLOW}${STAR} Data Generator:${RESET}"
44+
@echo "${BLUE}${INFO} 🚀 run-data-generator-local${RESET} - Run the Flink Data Generator in local environment"
45+
@echo "${BLUE}${INFO} ☁️ run-data-generator-cloud${RESET} - Run the Flink Data Generator in cloud environment"
46+
@echo "${BLUE}${INFO} 🚀 run-data-generator-with-props${RESET} - Run with custom properties (PROPS=path/to/properties)"
47+
@echo ""
48+
@echo "${YELLOW}${STAR} Docker Management:${RESET}"
49+
@echo "${BLUE}${INFO} 🐳 docker-up${RESET} - Start all containers"
50+
@echo "${BLUE}${INFO} 🐳 docker-down${RESET} - Stop and remove all containers"
51+
@echo "${BLUE}${INFO} 🐳 docker-restart${RESET} - Restart all containers"
52+
@echo "${BLUE}${INFO} 🐳 docker-ps${RESET} - List running containers and their status"
53+
@echo "${BLUE}${INFO} 🐳 docker-logs${RESET} - View logs (optionally for a specific service with SERVICE=name)"
54+
@echo "${BLUE}${INFO} 🐳 docker-build${RESET} - Build Docker image locally"
55+
@echo ""
56+
@echo "${YELLOW}${STAR} Terraform & Confluent Cloud:${RESET}"
57+
@echo "${BLUE}${INFO} ☁️ setup-terraform${RESET} - Setup Terraform for Confluent Cloud (using HashiCorp's official tap)"
58+
@echo "${BLUE}${INFO} ☁️ terraform-init${RESET} - Initialize Terraform"
59+
@echo "${BLUE}${INFO} ☁️ terraform-plan${RESET} - Plan Terraform changes"
60+
@echo "${BLUE}${INFO} ☁️ terraform-apply${RESET} - Apply Terraform changes"
61+
@echo "${BLUE}${INFO} ☁️ terraform-destroy${RESET} - Destroy Terraform-managed infrastructure"
62+
@echo "${BLUE}${INFO} ☁️ terraform-output${RESET} - Generate cloud.properties from Terraform output"
63+
@echo "${BLUE}${INFO} ☁️ cc-setup${RESET} - Complete Confluent Cloud setup (init, plan, apply, output)"
64+
@echo "${BLUE}${INFO} ☁️ cc-teardown${RESET} - Teardown Confluent Cloud infrastructure"
65+
@echo "${BLUE}${INFO} ☁️ tf-init${RESET} - Shorthand for terraform-init"
66+
@echo "${BLUE}${INFO} ☁️ tf-plan${RESET} - Shorthand for terraform-plan"
67+
@echo "${BLUE}${INFO} ☁️ tf-apply${RESET} - Shorthand for terraform-apply"
68+
@echo "${BLUE}${INFO} ☁️ tf-destroy${RESET} - Shorthand for terraform-destroy"
69+
@echo "${BLUE}${INFO} ☁️ tf-out${RESET} - Shorthand for terraform-output"
70+
@echo ""
71+
@echo "${YELLOW}${STAR} Cleanup:${RESET}"
72+
@echo "${BLUE}${INFO} 🧹 clean${RESET} - Clean up temporary files"
4773
@echo ""
4874
@echo "${BLUE}${INFO} For more information, see README.adoc${RESET}"
4975

@@ -57,10 +83,8 @@ update-brew-deps:
5783
fi
5884
@echo "${BLUE}${INFO} Updating Homebrew...${RESET}"
5985
brew update
60-
@echo "${BLUE}${INFO} Tapping Confluent repository...${RESET}"
61-
brew tap confluentinc/tap
6286
@echo "${BLUE}${INFO} Updating dependencies from Brewfile...${RESET}"
63-
brew bundle || echo "${YELLOW}${WARNING} Some Brewfile installations failed. Check output for details.${RESET}"
87+
brew bundle || { printf "${YELLOW}${WARNING} Some Brewfile installations failed. Check output for details.${RESET}\n"; }
6488
@echo "${GREEN}${CHECK} Homebrew dependencies updated!${RESET}"
6589

6690
# Check prerequisites
@@ -123,17 +147,14 @@ check-prereqs:
123147
.PHONY: setup-mac
124148
setup-mac:
125149
@echo "${BLUE}${ROCKET} Setting up dependencies on macOS...${RESET}"
126-
@echo "${YELLOW}${INFO} Installing/Updating Homebrew packages using Brewfile...${RESET}"
127150
@if ! command -v brew >/dev/null 2>&1; then \
128151
echo "${RED}${ERROR} Homebrew is not installed. Please install it first: https://brew.sh${RESET}"; \
129152
exit 1; \
130153
fi
131154
@echo "${BLUE}${INFO} Updating Homebrew...${RESET}"
132155
brew update
133-
@echo "${BLUE}${INFO} Tapping Confluent repository...${RESET}"
134-
brew tap confluentinc/tap
135156
@echo "${BLUE}${INFO} Installing dependencies from Brewfile...${RESET}"
136-
brew bundle || echo "${YELLOW}${WARNING} Some Brewfile installations failed. Check output for details.${RESET}"
157+
@brew bundle || { printf "${YELLOW}${WARNING} Some Brewfile installations failed. Check output for details.${RESET}\n"; }
137158
@echo "${BLUE}${INFO} Checking for SDKMAN installation...${RESET}"
138159
@if [ -d "$$HOME/.sdkman" ]; then \
139160
echo "${GREEN}${CHECK} SDKMAN is already installed${RESET}"; \
@@ -170,7 +191,7 @@ setup-linux:
170191
sudo usermod -aG docker $USER
171192
# Install Terraform
172193
@echo "${BLUE}${INFO} Installing Terraform...${RESET}"
173-
sudo apt-get install -y software-properties-common
194+
sudo apt-get install -y software-properties-common gnupg
174195
wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
175196
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
176197
sudo apt-get update
@@ -195,7 +216,7 @@ setup-linux:
195216
.PHONY: setup-terraform
196217
setup-terraform:
197218
@echo "${BLUE}${CLOUD} Setting up Terraform for Confluent Cloud...${RESET}"
198-
@echo "${YELLOW}${INFO} Please enter your Confluent Cloud credentials:${RESET}"
219+
@echo "${YELLOW}${INFO} Please enter your Confluent Cloud credentials and organization ID. This will be used to create a new environment and service account.${RESET}"
199220
@read -p "Confluent Cloud API Key: " API_KEY; \
200221
read -p "Confluent Cloud API Secret: " API_SECRET; \
201222
echo "export CONFLUENT_CLOUD_API_KEY=$$API_KEY" > .env; \
@@ -311,22 +332,41 @@ run-sql:
311332
@echo "${BLUE}${ROCKET} Running Flink SQL application...${RESET}"
312333
./gradlew :flink-sql:run
313334

314-
# Start local Docker environment
315-
.PHONY: start-docker
316-
start-docker:
317-
@echo "${BLUE}${ROCKET} Starting Docker environment...${RESET}"
318-
docker-compose up -d
319-
@echo "${GREEN}${CHECK} Docker environment started!${RESET}"
335+
# Docker Compose targets
336+
.PHONY: docker-up docker-down docker-ps docker-logs docker-restart
337+
338+
docker-up:
339+
@echo "${BLUE}${ROCKET} Starting Docker containers...${RESET}"
340+
@if ! command -v docker >/dev/null 2>&1; then \
341+
echo "${RED}${ERROR} Docker is not installed${RESET}"; \
342+
exit 1; \
343+
fi
344+
docker compose up -d
345+
@echo "${GREEN}${CHECK} Docker containers started successfully!${RESET}"
320346
@echo "${YELLOW}${INFO} Kafka is available at localhost:29092${RESET}"
321347
@echo "${YELLOW}${INFO} Schema Registry is available at http://localhost:8081${RESET}"
322-
@echo "${YELLOW}${INFO} Flink Dashboard is available at http://localhost:8080${RESET}"
323348

324-
# Stop local Docker environment
325-
.PHONY: stop-docker
326-
stop-docker:
327-
@echo "${BLUE}${INFO} Stopping Docker environment...${RESET}"
328-
docker-compose down
329-
@echo "${GREEN}${CHECK} Docker environment stopped!${RESET}"
349+
docker-down:
350+
@echo "${BLUE}${INFO} Stopping Docker containers...${RESET}"
351+
docker compose down
352+
@echo "${GREEN}${CHECK} Docker containers stopped successfully!${RESET}"
353+
354+
docker-ps:
355+
@echo "${BLUE}${INFO} Listing running Docker containers...${RESET}"
356+
docker compose ps
357+
358+
docker-logs:
359+
@echo "${BLUE}${INFO} Showing Docker container logs...${RESET}"
360+
@if [ -z "$(SERVICE)" ]; then \
361+
docker compose logs -f; \
362+
else \
363+
docker compose logs -f $(SERVICE); \
364+
fi
365+
366+
docker-restart:
367+
@echo "${BLUE}${ROCKET} Restarting Docker containers...${RESET}"
368+
docker compose restart
369+
@echo "${GREEN}${CHECK} Docker containers restarted successfully!${RESET}"
330370

331371
# Run CI checks locally
332372
.PHONY: ci-checks
@@ -357,6 +397,35 @@ docker-build:
357397
@echo "${GREEN}${CHECK} Docker image built successfully!${RESET}"
358398
@echo "${YELLOW}${INFO} Run with: docker run -it flink-for-java-workshop:local${RESET}"
359399

400+
# Flink Data Generator targets
401+
.PHONY: build-data-generator
402+
build-data-generator:
403+
@echo "${BLUE}${ROCKET} Building Flink Data Generator...${RESET}"
404+
./gradlew :flink-data-generator:build
405+
@echo "${GREEN}${CHECK} Flink Data Generator built successfully!${RESET}"
406+
407+
.PHONY: run-data-generator-local
408+
run-data-generator-local:
409+
@echo "${BLUE}${ROCKET} Running Flink Data Generator in local environment...${RESET}"
410+
./gradlew :flink-data-generator:run --args="--env local"
411+
@echo "${GREEN}${CHECK} Flink Data Generator completed!${RESET}"
412+
413+
.PHONY: run-data-generator-cloud
414+
run-data-generator-cloud:
415+
@echo "${BLUE}${CLOUD} Running Flink Data Generator in cloud environment...${RESET}"
416+
./gradlew :flink-data-generator:run --args="--env cloud"
417+
@echo "${GREEN}${CHECK} Flink Data Generator completed!${RESET}"
418+
419+
.PHONY: run-data-generator-with-props
420+
run-data-generator-with-props:
421+
@echo "${BLUE}${ROCKET} Running Flink Data Generator with custom properties...${RESET}"
422+
@if [ -z "$(PROPS)" ]; then \
423+
echo "${RED}${ERROR} Please specify properties file with PROPS=path/to/properties.${RESET}"; \
424+
exit 1; \
425+
fi
426+
./gradlew :flink-data-generator:run --args="--properties $(PROPS)"
427+
@echo "${GREEN}${CHECK} Flink Data Generator completed!${RESET}"
428+
360429
# Clean up
361430
.PHONY: clean
362431
clean:

build.gradle.kts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ allprojects {
2222
subprojects {
2323
apply(plugin = "java")
2424

25-
val flinkVersion = "1.18.1"
26-
val confluentVersion = "7.6.0"
25+
val flinkVersion = "1.20.0"
26+
val confluentVersion = "7.9.0"
2727
val junitVersion = "5.10.2"
2828
val logbackVersion = "1.4.14"
2929
val slf4jVersion = "2.0.11"
@@ -67,8 +67,8 @@ configure(subprojects.filter { it.name == "flink-streaming" || it.name == "flink
6767
apply(plugin = "application")
6868
apply(plugin = "com.github.johnrengelman.shadow")
6969

70-
val flinkVersion = "1.18.1"
71-
val confluentVersion = "7.6.0"
70+
val flinkVersion = "1.20.0"
71+
val confluentVersion = "7.9.0"
7272

7373
dependencies {
7474
// Common modules
@@ -81,7 +81,7 @@ configure(subprojects.filter { it.name == "flink-streaming" || it.name == "flink
8181
implementation("org.apache.flink:flink-runtime-web:$flinkVersion")
8282

8383
// Flink Connectors
84-
implementation("org.apache.flink:flink-connector-kafka:3.0.2-1.18")
84+
implementation("org.apache.flink:flink-connector-kafka:3.4.0-1.20")
8585
implementation("org.apache.flink:flink-connector-files:$flinkVersion")
8686

8787
// Confluent
@@ -94,7 +94,7 @@ configure(subprojects.filter { it.name == "flink-streaming" || it.name == "flink
9494
// Configuration specific to the flink-sql module
9595
project(":flink-sql") {
9696
dependencies {
97-
val flinkVersion = "1.18.1"
97+
val flinkVersion = "1.20.0"
9898

9999
// Flink Table API & SQL
100100
implementation("org.apache.flink:flink-table-api-java-bridge:$flinkVersion")

common/models/build.gradle.kts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,31 @@
1+
plugins {
2+
id("com.github.davidmc24.gradle.plugin.avro") version "1.9.1"
3+
}
4+
15
dependencies {
26
// Add model-specific dependencies here
37
implementation("org.apache.avro:avro:1.11.3")
48
}
9+
10+
repositories {
11+
mavenCentral()
12+
maven {
13+
url = uri("https://packages.confluent.io/maven/")
14+
}
15+
}
16+
17+
avro {
18+
setCreateSetters(true)
19+
setCreateOptionalGetters(false)
20+
setGettersReturnOptional(false)
21+
setOptionalGettersForNullableFieldsOnly(false)
22+
setFieldVisibility("PRIVATE")
23+
}
24+
25+
sourceSets {
26+
main {
27+
java {
28+
srcDir("build/generated-main-avro-java")
29+
}
30+
}
31+
}

common/utils/build.gradle.kts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
dependencies {
2-
// Add utils-specific dependencies here
3-
implementation("com.google.guava:guava:32.1.3-jre")
2+
// Test dependencies
3+
testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.0")
4+
testImplementation("org.junit.jupiter:junit-jupiter-params:5.10.0")
5+
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.10.0")
6+
testImplementation("org.assertj:assertj-core:3.24.2")
7+
}
8+
9+
tasks.test {
10+
useJUnitPlatform()
411
}

0 commit comments

Comments
 (0)