Skip to content

feat(java): implement Async Connection Pooling using FixedChannelPool#2606

Merged
mmodzelewski merged 3 commits intoapache:masterfrom
rythm-sachdeva:feature/async-connection-pool
Mar 9, 2026
Merged

feat(java): implement Async Connection Pooling using FixedChannelPool#2606
mmodzelewski merged 3 commits intoapache:masterfrom
rythm-sachdeva:feature/async-connection-pool

Conversation

@rythm-sachdeva
Copy link
Copy Markdown
Contributor

Description

Implements connection pooling for AsyncTcpConnection using Netty's FixedChannelPool to handle concurrent async operations efficiently.

Changes

  • Connection Pooling: Replaced single channel with FixedChannelPool for concurrent request handling
  • Pool Metrics: Added PoolMetrics class to track:
    • Active connections
    • Total requests and errors
    • Wait times (min/max/average in nanoseconds, microseconds, and milliseconds)
    • Error rate percentage
  • Configuration: Added TCPConnectionPoolConfig with builder pattern for customizing:
    • Max connections (default: 5)
    • Max pending acquires (default: 1000)
    • Acquire timeout (default: 3000ms)
  • Request Correlation: Implemented FIFO queue-based request/response matching using ConcurrentLinkedQueue
  • Broadcast Operations: Added broadcastAsync() method to execute commands across all pooled connections (useful for authentication)
  • Client Integration: Exposed pool configuration via AsyncIggyTcpClient.Builder.connectionPoolSize()

Implementation Details

  • Uses Netty's FixedChannelPool with ChannelHealthChecker.ACTIVE
  • Each channel has its own IggyResponseHandler with a response queue
  • Pool automatically releases channels after request completion
  • Handles connection errors gracefully with proper cleanup

Testing

  • Added integration test testConnectionPoolMetrics() to verify metrics tracking
  • Existing async integration tests validate concurrent operations
  • Pool properly handles concurrent sends and polls

@mmodzelewski mmodzelewski linked an issue Jan 27, 2026 that may be closed by this pull request
20 tasks
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 4, 2026

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs.

If you need a review, please ensure CI is green and the PR is rebased on the latest master. Don't hesitate to ping the maintainers - either @core on Discord or by mentioning them directly here on the PR.

Thank you for your contribution!

@github-actions github-actions Bot added the stale Inactive issue or pull request label Feb 4, 2026
@hubcio hubcio changed the title feat(java): Implemented Async Connection Pooling using FixedChannelPool (#2232) feat(java): implement Async Connection Pooling using FixedChannelPool Feb 4, 2026
@github-actions github-actions Bot removed the stale Inactive issue or pull request label Feb 5, 2026
@rythm-sachdeva rythm-sachdeva force-pushed the feature/async-connection-pool branch 2 times, most recently from 2cdb131 to 50e8a36 Compare February 7, 2026 06:56
@rythm-sachdeva
Copy link
Copy Markdown
Contributor Author

Hi @mmodzelewski Can you please review .

@mmodzelewski
Copy link
Copy Markdown
Member

Hi @mmodzelewski Can you please review .

Hey @rythm-sachdeva, I will, but I need some time. I might not get round to it until the beginning of next week.

@rythm-sachdeva rythm-sachdeva force-pushed the feature/async-connection-pool branch from 50e8a36 to ca4583f Compare February 17, 2026 15:08
@slbotbm
Copy link
Copy Markdown
Contributor

slbotbm commented Feb 17, 2026

@rythm-sachdeva Please see why CI is failing and fix the errors.

@mmodzelewski
Copy link
Copy Markdown
Member

@rythm-sachdeva Please see why CI is failing and fix the errors.

@rythm-sachdeva I've added a verification if all ByteBufs are properly released (not leaked) and it appears that the new code does not release all resources. See the logs, or run the tests locally, you'll see reports of the leaks in there.

@rythm-sachdeva rythm-sachdeva force-pushed the feature/async-connection-pool branch 4 times, most recently from 4eaf354 to 181682b Compare February 22, 2026 01:40
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 22, 2026

Codecov Report

❌ Patch coverage is 62.18905% with 76 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.11%. Comparing base (ae29f6c) to head (3cdbc18).
⚠️ Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
...ache/iggy/client/async/tcp/AsyncTcpConnection.java 63.19% 37 Missing and 16 partials ⚠️
...apache/iggy/client/async/tcp/IggyFrameEncoder.java 45.00% 10 Missing and 1 partial ⚠️
...gy/client/async/tcp/AsyncIggyTcpClientBuilder.java 0.00% 4 Missing and 2 partials ⚠️
...pache/iggy/client/async/tcp/IggyAuthenticator.java 76.00% 4 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #2606      +/-   ##
============================================
- Coverage     70.27%   68.11%   -2.16%     
- Complexity      739      763      +24     
============================================
  Files          1038     1052      +14     
  Lines         85756    84021    -1735     
  Branches      62144    60635    -1509     
============================================
- Hits          60263    57230    -3033     
- Misses        22992    24420    +1428     
+ Partials       2501     2371     -130     
Flag Coverage Δ
java 55.15% <62.18%> (+0.32%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ache/iggy/client/async/tcp/AsyncIggyTcpClient.java 98.48% <100.00%> (+0.09%) ⬆️
...gy/client/async/tcp/AsyncIggyTcpClientBuilder.java 77.27% <0.00%> (-12.21%) ⬇️
...pache/iggy/client/async/tcp/IggyAuthenticator.java 76.00% <76.00%> (ø)
...apache/iggy/client/async/tcp/IggyFrameEncoder.java 45.00% <45.00%> (ø)
...ache/iggy/client/async/tcp/AsyncTcpConnection.java 65.36% <63.19%> (+2.86%) ⬆️

... and 141 files with indirect coverage changes

🚀 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.

Copy link
Copy Markdown
Member

@mmodzelewski mmodzelewski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @rythm-sachdeva, I left a few comments, please let me know if you have any questions.

@rythm-sachdeva rythm-sachdeva force-pushed the feature/async-connection-pool branch from 181682b to a31643a Compare February 28, 2026 13:48
@mmodzelewski
Copy link
Copy Markdown
Member

Hi @rythm-sachdeva, please run tests/lints before pushing out the changes.

@rythm-sachdeva
Copy link
Copy Markdown
Contributor Author

Hi @rythm-sachdeva, please run tests/lints before pushing out the changes.

Sorry, will surely do it next time.

@mmodzelewski
Copy link
Copy Markdown
Member

@rythm-sachdeva please ping me when the PR is ready for review.

@rythm-sachdeva rythm-sachdeva force-pushed the feature/async-connection-pool branch from a31643a to 1c86e1a Compare March 4, 2026 04:32
@rythm-sachdeva
Copy link
Copy Markdown
Contributor Author

Hi @mmodzelewski can you check once I have updated the pr

@mmodzelewski
Copy link
Copy Markdown
Member

@rythm-sachdeva please fix the lints. I see that there's IllegalStateException in the code instead of Iggy's equivalent. Also, any commented out code should be removed.
And please remove PoolMetrics as I asked in the comment above.

@rythm-sachdeva
Copy link
Copy Markdown
Contributor Author

Sure @mmodzelewski will do that.

@rythm-sachdeva rythm-sachdeva force-pushed the feature/async-connection-pool branch 2 times, most recently from 499dca0 to 6e2ba9f Compare March 6, 2026 14:54
@rythm-sachdeva
Copy link
Copy Markdown
Contributor Author

Hi @mmodzelewski can you review once.

fix(java-sdk):Added Missing PoolMetrics and linting issues

fix(java):fixed connection error

fix(java):Fixed Linting Issues

fix(java):fixed builder issues

fix(java):fixed ci issues

fix(java): fixed memory leaks

fix(java):fixed memory leak at channelread0

fix(java):fixed broadcastasync memory leak

feat(java): Added attribute based channel login

fix(java): fixed error handling in inbound handler

fix(java):Fixed login issues

fix(java): Fixed connection pool login logout bugs

fix(java): fixed authentication bugs

fix(java): fixed checkStyle Errors
@rythm-sachdeva rythm-sachdeva force-pushed the feature/async-connection-pool branch from 6e2ba9f to 4670a84 Compare March 7, 2026 03:15
@rythm-sachdeva
Copy link
Copy Markdown
Contributor Author

Hi @mmodzelewski Can you please re run the workflow I have fixed check style errors

@mmodzelewski mmodzelewski merged commit 7d20f31 into apache:master Mar 9, 2026
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Java SDK] Implement Connection Pooling for Async Client

5 participants