Skip to content

Commit 388939e

Browse files
Added code to spin up and test the mm2 feature
1 parent 70af460 commit 388939e

4 files changed

Lines changed: 16 additions & 4 deletions

File tree

Dockerfile.mm2

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM apache/kafka:4.0.0
2+
3+
# Copy your freshly compiled custom JAR engine modifications directly from the sibling build paths
4+
COPY connect/mirror/build/libs/connect-mirror-*.jar /opt/kafka/libs/
5+
COPY connect/mirror-client/build/libs/connect-mirror-client-*.jar /opt/kafka/libs/
6+
7+
# Create a placeholder directory to ensure smooth volume mount overrides
8+
RUN mkdir -p /opt/kafka/config/

docker-compose.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ services:
9292
]
9393

9494
mirror-maker:
95-
build: ../kafka
95+
build:
96+
context: ../kafka
97+
dockerfile: ../challenge-env/Dockerfile.mm2
9698

9799
depends_on:
98100
- primary

mm2.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ primary->standby.emit.heartbeats.enabled=true
1313
primary->standby.emit.heartbeats.interval.seconds=5
1414

1515
primary->standby.sync.topic.acls.enabled=false
16+
# Force the internal replication consumer to crash on out-of-range/truncation gaps
17+
primary->standby.consumer.auto.offset.reset = none
1618

1719
replication.factor=1
1820

run_challenge.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ SUCCESS_S1=0
4242
for i in {1..15}
4343
do
4444
# Dynamically query the Standby broker for the current log end offset instead of raw directory size
45-
STANDBY_OFFSET=$(docker-compose exec -T standby /opt/kafka/bin/kafka-run-class.sh kafka.tools.GetOffsetShell --bootstrap-server localhost:9094 --topic primary.commit-log --time -1 | awk -F ':' '{print $3}' | tr -d '\r\n ')
45+
STANDBY_OFFSET=$(docker-compose exec -T standby /opt/kafka/bin/kafka-run-class.sh org.apache.kafka.tools.GetOffsetShell --bootstrap-server localhost:9094 --topic primary.commit-log --time -1 | awk -F ':' '{print $3}' | tr -d '\r\n ')
4646
: "${STANDBY_OFFSET:=0}"
4747

4848
echo "Attempt $i/15 -> Standby Replicated Offset: $STANDBY_OFFSET messages"
@@ -76,7 +76,7 @@ docker-compose exec -T primary bash -c "for x in {1..200}; do echo '{\"event_id\
7676

7777
echo "Querying primary cluster log end offset dynamically..."
7878
# Dynamically fetch the current highest active offset from the broker
79-
HIGH_WATERMARK=$(docker-compose exec -T primary /opt/kafka/bin/kafka-run-class.sh kafka.tools.GetOffsetShell --bootstrap-server localhost:9092 --topic commit-log --time -1 | awk -F ':' '{print $3}' | tr -d '\r\n ')
79+
HIGH_WATERMARK=$(docker-compose exec -T primary /opt/kafka/bin/kafka-run-class.sh org.apache.kafka.tools.GetOffsetShell --bootstrap-server localhost:9092 --topic commit-log --time -1 | awk -F ':' '{print $3}' | tr -d '\r\n ')
8080

8181
# Fallback mechanism if GetOffsetShell output parsing is empty
8282
if [ -z "$HIGH_WATERMARK" ]; then
@@ -149,7 +149,7 @@ docker-compose exec -T primary bash -c "for x in {1..100}; do echo '{\"event_id\
149149
echo "Allowing MirrorMaker 2 automated recovery to stabilize..."
150150
sleep 25
151151

152-
POST_RESET_OFFSET=$(docker-compose exec -T standby /opt/kafka/bin/kafka-run-class.sh kafka.tools.GetOffsetShell --bootstrap-server localhost:9094 --topic primary.commit-log --time -1 | awk -F ':' '{print $3}' | tr -d '\r\n ')
152+
POST_RESET_OFFSET=$(docker-compose exec -T standby /opt/kafka/bin/kafka-run-class.sh org.apache.kafka.tools.GetOffsetShell --bootstrap-server localhost:9094 --topic primary.commit-log --time -1 | awk -F ':' '{print $3}' | tr -d '\r\n ')
153153
: "${POST_RESET_OFFSET:=0}"
154154

155155
echo "Standby Cluster Log Offset post-reset verification: $POST_RESET_OFFSET messages"

0 commit comments

Comments
 (0)