Skip to content

feat(java): add cluster metadata and leader redirection to TCP client#3745

Open
mmodzelewski wants to merge 1 commit into
masterfrom
java-leader-aware
Open

feat(java): add cluster metadata and leader redirection to TCP client#3745
mmodzelewski wants to merge 1 commit into
masterfrom
java-leader-aware

Conversation

@mmodzelewski

Copy link
Copy Markdown
Member

Java clients connected to a VSR follower had no way to discover
the cluster leader, so operations against a multi-node cluster
failed until the user manually pointed the client at the right
node.

Add the GET_CLUSTER_METADATA command with cluster roster models
and a binary deserializer. After login the async TCP client
fetches the roster and, when a healthy leader with an enabled
TCP endpoint lives elsewhere, reconnects to it and replays the
login. Redirections are capped at 3 consecutive hops so two
nodes both claiming leadership cannot ping-pong a client, and
every failure on the redirect path is non-fatal: the client
stays on the current node. Mirrors the Rust and Go SDKs.

Covered by a leader_redirection BDD scenario wired into the
cluster docker-compose setup.

Java clients connected to a VSR follower had no way to discover
the cluster leader, so operations against a multi-node cluster
failed until the user manually pointed the client at the right
node.

Add the GET_CLUSTER_METADATA command with cluster roster models
and a binary deserializer. After login the async TCP client
fetches the roster and, when a healthy leader with an enabled
TCP endpoint lives elsewhere, reconnects to it and replays the
login. Redirections are capped at 3 consecutive hops so two
nodes both claiming leadership cannot ping-pong a client, and
every failure on the redirect path is non-fatal: the client
stays on the current node. Mirrors the Rust and Go SDKs.

Covered by a leader_redirection BDD scenario wired into the
cluster docker-compose setup.
@github-actions github-actions Bot added the S-waiting-on-review PR is waiting on a reviewer label Jul 24, 2026
@mmodzelewski mmodzelewski added the java Issues related to Java SDK label Jul 24, 2026
@codecov

codecov Bot commented Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.63158% with 66 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.63%. Comparing base (64ae1e9) to head (da553e2).

Files with missing lines Patch % Lines
...ache/iggy/client/async/tcp/AsyncIggyTcpClient.java 47.77% 43 Missing and 4 partials ⚠️
.../apache/iggy/client/async/tcp/LeaderAwareness.java 92.63% 5 Missing and 2 partials ⚠️
...ache/iggy/client/async/tcp/AsyncTcpConnection.java 86.95% 3 Missing ⚠️
...lient/async/tcp/PersonalAccessTokensTcpClient.java 78.57% 2 Missing and 1 partial ⚠️
...g/apache/iggy/client/async/tcp/UsersTcpClient.java 84.21% 2 Missing and 1 partial ⚠️
...he/iggy/client/async/tcp/LoginRedirectionHook.java 0.00% 1 Missing ⚠️
.../java/org/apache/iggy/cluster/ClusterNodeRole.java 90.90% 1 Missing ⚠️
...ava/org/apache/iggy/cluster/ClusterNodeStatus.java 92.85% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             master    #3745    +/-   ##
==========================================
  Coverage     74.62%   74.63%            
- Complexity      969     1046    +77     
==========================================
  Files          1305     1313     +8     
  Lines        149590   149865   +275     
  Branches     125024   125046    +22     
==========================================
+ Hits         111631   111846   +215     
- Misses        34460    34513    +53     
- Partials       3499     3506     +7     
Components Coverage Δ
Rust Core 74.95% <ø> (ø)
Java SDK 63.67% <82.63%> (+0.95%) ⬆️
C# SDK 72.26% <ø> (ø)
Python SDK 92.27% <ø> (ø)
PHP SDK 84.52% <ø> (ø)
Node SDK 92.11% <ø> (ø)
Go SDK 43.08% <ø> (ø)
Files with missing lines Coverage Δ
...in/java/org/apache/iggy/client/ConnectionInfo.java 100.00% <100.00%> (ø)
...iggy/client/async/tcp/ConsumerGroupsTcpClient.java 100.00% <100.00%> (ø)
...ggy/client/async/tcp/ConsumerOffsetsTcpClient.java 92.85% <100.00%> (+0.26%) ⬆️
...pache/iggy/client/async/tcp/MessagesTcpClient.java 97.43% <100.00%> (+0.06%) ⬆️
...che/iggy/client/async/tcp/PartitionsTcpClient.java 100.00% <100.00%> (ø)
...apache/iggy/client/async/tcp/StreamsTcpClient.java 100.00% <100.00%> (ø)
.../apache/iggy/client/async/tcp/SystemTcpClient.java 100.00% <100.00%> (ø)
.../apache/iggy/client/async/tcp/TopicsTcpClient.java 95.83% <100.00%> (+0.48%) ⬆️
...he/iggy/client/blocking/http/SystemHttpClient.java 64.28% <100.00%> (+5.95%) ⬆️
...apache/iggy/client/blocking/tcp/IggyTcpClient.java 63.26% <100.00%> (+0.76%) ⬆️
... and 14 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

java Issues related to Java SDK S-waiting-on-review PR is waiting on a reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant