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
broker — LiteEventDispatcher.ClientEventSet
Description
The
ClientEventSetinner class inLiteEventDispatchercurrently uses a fixed-capacityLinkedBlockingQueuewhose capacity is determined at construction time:This means the
maxClientEventCountconfiguration cannot be changed at runtime — a broker restart is required for any adjustment to take effect.Additionally,
isLowWaterMark()relies onremainingCapacity():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
LinkedBlockingQueueand enforce the capacity limit dynamically via a soft-cap check inoffer():Update
isLowWaterMark()to use the dynamically resolvedmaxCapacitydirectly:Benefits
maxClientEventCountcan be adjusted without broker restartAffected Module
broker—LiteEventDispatcher.ClientEventSet