Skip to content

[ISSUE #10387] Support runtime hot-reload of maxClientEventCount in LiteEventDispatcher.ClientEventSet#10388

Open
f1amingo wants to merge 1 commit into
apache:developfrom
f1amingo:feature/lite-event-dispatcher
Open

[ISSUE #10387] Support runtime hot-reload of maxClientEventCount in LiteEventDispatcher.ClientEventSet#10388
f1amingo wants to merge 1 commit into
apache:developfrom
f1amingo:feature/lite-event-dispatcher

Conversation

@f1amingo
Copy link
Copy Markdown
Contributor

@f1amingo f1amingo commented May 27, 2026

Which Issue(s) This PR Fixes

Brief Description

ClientEventSet in LiteEventDispatcher previously used a fixed-capacity LinkedBlockingQueue whose capacity was bound at construction time, which meant the broker had to be restarted whenever maxClientEventCount was changed. isLowWaterMark() also relied on remainingCapacity() — for a fixed queue, this is a static number rather than the intended dynamic limit.

This PR introduces a TTL-based capacity cache combined with a dynamic soft-cap pattern:

  1. Hard-ceiling unbounded queue: Replace the fixed-capacity constructor with new LinkedBlockingQueue<>(100_000) as a safety hard ceiling.

  2. TTL-based capacity cache: Add a maxCapacityCache field that is lazily refreshed every liteEventCapacityCacheTtlMs (default 5s, configurable in BrokerConfig), avoiding per-offer SubscriptionGroupConfig lookup/parsing on the hot dispatch path while still supporting runtime hot-reload.

  3. Dynamic soft-cap in offer(): Check events.size() >= getMaxCapacity() instead of remainingCapacity() == 0, so the effective limit tracks the cached config value.

  4. Correct watermark calculation: Compute isLowWaterMark() from dynamic maxCapacity directly, with a maxCapacity <= 0 boundary guard.

  5. New config: Add BrokerConfig.liteEventCapacityCacheTtlMs (default 5000ms) to control the refresh interval of the capacity cache.

  6. Test fix: Use doReturn(...).when(spy)... instead of when(spy.method()).thenReturn(...) to avoid invoking real methods on the spy object.

How Did You Test This Change?

  • Updated LiteEventDispatcherTest spy stub style to doReturn to prevent real method invocation on inner-class spy objects.
  • Existing LiteEventDispatcherTest cases covering offer, isLowWaterMark, and the full dispatch flow continue to pass locally.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 27, 2026

Codecov Report

❌ Patch coverage is 52.94118% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 48.88%. Comparing base (051ba27) to head (d7eda2f).
⚠️ Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
...ache/rocketmq/broker/lite/LiteEventDispatcher.java 61.53% 2 Missing and 3 partials ⚠️
.../java/org/apache/rocketmq/common/BrokerConfig.java 25.00% 3 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop   #10388      +/-   ##
=============================================
- Coverage      48.89%   48.88%   -0.01%     
+ Complexity     13452    13448       -4     
=============================================
  Files           1376     1376              
  Lines         100527   100540      +13     
  Branches       12983    12984       +1     
=============================================
- Hits           49154    49153       -1     
+ Misses         45383    45360      -23     
- Partials        5990     6027      +37     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@f1amingo f1amingo force-pushed the feature/lite-event-dispatcher branch 2 times, most recently from b57b10e to d7eda2f Compare May 27, 2026 09:32
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.

[Enhancement] LiteEventDispatcher ClientEventSet does not support runtime config change for event queue limit

2 participants