-
Notifications
You must be signed in to change notification settings - Fork 75
Use Java Client Side Car for Cassandra Dual writes #1256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Java Client Side Car for Cassandra Dual writes #1256
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1256 +/- ##
==========================================
- Coverage 47.22% 47.22% -0.01%
==========================================
Files 231 231
Lines 26698 26698
Branches 581 581
==========================================
- Hits 12609 12607 -2
- Misses 13368 13370 +2
Partials 721 721
🚀 New features to boost your workflow:
|
rohitwali
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the changes. mostly LGTM, couple of clarifications
bharadwaj-aditya
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of parameters to check. Looks fine overall.
69943e3 to
167755f
Compare
167755f to
4360c17
Compare
Swap Go Spanner Cassandra Proxy with Java Client.
Fixes b/471713394
Goal
Replace the
go-spanner-cassandraproxy with thejava-spanner-cassandraproxy in thesources/cassandraDocker image, while maintaining the existing dual-write proxy functionality (zdm-proxy). The Java Client being used will be maintained to accommodate newer options and features.Current Components of the Docker Image
golang:1.24-bullseyezdm-proxy(Go)go-spanner-cassandra(Go)alpine:3.22with binaries copied over.cassandra-spanner-proxywith CLI flags derived from environment variables.zdm-proxywith a config file.Proposed Changes
1. Dockerfile Restructuring (Multi-Stage Build)
We need a multi-stage build to handle both Go (for
zdm-proxy) and Java (forjava-spanner-cassandra) compilation.Stages:
golang:1.24-bullseye(Keep existing).zdm-proxyas before.maven:3.9-eclipse-temurin-17.java-spanner-cassandraclient requires Java 8 or later. We will use Java 17 LTS as it is a modern, widely supported standard that offers better performance and container support than Java 8.java-spanner-cassandraand runmvn clean installto produce the shaded process/launcher jar.alpine:3.22(Keep existing).openjdk17-jre(or headless version) +bash+gettext(forenvsubst).zdm-proxybinary from Go Builder.spanner-cassandra-launcher.jarfrom Java Builder.entrypoint.sh.spanner.yaml(template).2. Configuration Strategy
We will map the existing environment variables to the new Java Proxy's configuration format using a template and
envsubst. **This ensures that users do not need to change how they deploy the container.Current Configuration Flow (Old)
docker run:SPANNER_PROJECT,SPANNER_INSTANCE,SPANNER_DATABASE,GRPC_CHANNELS(optional).entrypoint.shreads these variables directly.entrypoint.shconstructs a command line string:/cassandra-spanner-proxy --db="projects/$SPANNER_PROJECT/instances/$SPANNER_INSTANCE/databases/$SPANNER_DATABASE" ...Proposed Configuration Flow (New)
SPANNER_PROJECT, etc.). No user-side change required.spanner-cassandra-config.yamltemplate into the image.entrypoint.shusesenvsubstto read the template and replace placeholders (e.g.,${SPANNER_PROJECT}) with actual values from the current environment.envsubstallows dynamic generation of the complex YAML structure required by the Java proxy, which is more robust than passing many-Dsystem properties for nested configs.entrypoint.shstarts the Java process pointing to the generated config file.java -DconfigFilePath=/app/generated-config.yaml -jar ...Configuration Flexibility (FAQ)
Q: Can a user have a config file in the code repo and only override a few parameters via env variables?
A: Yes. The config file in the repo (
sources/cassandra/spanner-cassandra-config.yaml) serves as the template.max_prepared_statements: 100) if they should always be the same.${SPANNER_PROJECT}) in the file.envsubstwill replace the placeholders with the actual environment variable values. Hardcoded values remain unchanged./app/spanner-cassandra-config.yaml, and the entrypoint will still process it withenvsubst(allowing them to use their own placeholders if desired).3. Entrypoint Script (
entrypoint.sh)Update
entrypoint.shto:generated-config.yamlfromspanner-cassandra-config.yamlusingenvsubst.zdm-proxy(unchanged).Detailed Steps
sources/cassandra/spanner-cassandra-config.yaml: Define the default template.sources/cassandra/Dockerfile:maven:3.9-eclipse-temurin-17build stage.openjdk17-jreandgettextin the final stage.sources/cassandra/entrypoint.sh:envsubststep.Questions/Notes
Tests
Basic
Test passes. As of now the test is manual as Spanner Emulator does not support Cassandra Adapter.
IOPS test with cassandra-stress
No regression in throughput with respect to main.
All latencies below are in milli seconds.