Skip to content

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

@f1amingo

Description

@f1amingo

Description

The ClientEventSet inner class in LiteEventDispatcher currently uses a fixed-capacity LinkedBlockingQueue whose capacity is determined at construction time:

events = new LinkedBlockingQueue<>(LiteMetadataUtil.getMaxClientEventCount(group, brokerController));

This means the maxClientEventCount configuration cannot be changed at runtime — a broker restart is required for any adjustment to take effect.

Additionally, isLowWaterMark() relies on remainingCapacity():

return (double) used / (used + events.remainingCapacity()) < LOW_WATER_MARK;

Since the queue capacity is fixed, remainingCapacity() reflects the static bound rather than the intended dynamic limit, which can lead to incorrect watermark calculations.

Proposed Change

Replace the fixed-capacity queue with a logically unbounded LinkedBlockingQueue and enforce the capacity limit dynamically via a soft-cap check in offer():

events = new LinkedBlockingQueue<>(Integer.MAX_VALUE);
public boolean offer(String event) {
    if (events.size() >= getMaxCapacity()) {
        return false;
    }
    // ...
}

Update isLowWaterMark() to use the dynamically resolved maxCapacity directly:

public boolean isLowWaterMark() {
    int used = events.size();
    int maxCapacity = getMaxCapacity();
    return maxCapacity <= 0 || (double) used / maxCapacity < LOW_WATER_MARK;
}

Benefits

  • Runtime config hot-reload: maxClientEventCount can be adjusted without broker restart
  • Correct watermark calculation: Uses the current dynamic limit instead of the static queue capacity
  • Backward compatible: The soft-cap behavior is functionally equivalent to the previous fixed-cap approach

Affected Module

  • brokerLiteEventDispatcher.ClientEventSet

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions