|
12 | 12 | /** |
13 | 13 | * Service interface for estimating the search load rate of a shard using provided search statistics. |
14 | 14 | * <p> |
15 | | - * Implementations may apply various heuristics or models, such as exponentially weighted moving averages, |
| 15 | + * Implementations may apply various heuristics or models, such as exponentially weighted moving rate, |
16 | 16 | * to track and estimate the current load on a shard based on its search activity. |
17 | 17 | */ |
18 | 18 | public interface ShardSearchLoadRateService { |
19 | 19 |
|
20 | 20 | /** |
21 | | - * A no-op implementation of {@code ShardSearchLoadRateService} that always returns {@link SearchLoadRate#NO_OP}. |
| 21 | + * A no-op implementation of {@code ShardSearchLoadRateService} that always returns {@code 0.0} |
22 | 22 | * This can be used as a fallback or default when no actual load tracking is required. |
23 | 23 | */ |
24 | | - ShardSearchLoadRateService NOOP = (stats) -> SearchLoadRate.NO_OP; |
| 24 | + ShardSearchLoadRateService NOOP = (stats) -> 0.0; |
25 | 25 |
|
26 | 26 | /** |
27 | 27 | * Computes the search load rate based on the provided shard-level search statistics. |
28 | 28 | * |
29 | 29 | * @param stats the search statistics for the shard, typically including metrics like query count, latency, etc. |
30 | | - * @return the {@link SearchLoadRate} representing the current estimated load on the shard |
| 30 | + * @return the {@code double} representing the calculated EWMR on the shard |
31 | 31 | */ |
32 | | - SearchLoadRate getSearchLoadRate(SearchStats.Stats stats); |
33 | | - |
34 | | - /** |
35 | | - * Represents the search load rate as computed over time using an exponentially weighted moving average (EWM). |
36 | | - * <p> |
37 | | - * This record captures the timing of the last update, the delta since the last observation, |
38 | | - * and the computed rate itself. |
39 | | - * |
40 | | - * @param lastTrackedTime the timestamp (e.g., in milliseconds or nanoseconds) of the last update |
41 | | - * @param delta the elapsed time since the previous update |
42 | | - * @param ewmRate the current exponentially weighted moving average rate |
43 | | - */ |
44 | | - record SearchLoadRate(long lastTrackedTime, long delta, double ewmRate) { |
45 | | - |
46 | | - /** |
47 | | - * A static no-op instance representing a default or zeroed state of {@code SearchLoadRate}. |
48 | | - * All numeric values are initialized to zero. |
49 | | - */ |
50 | | - public static final SearchLoadRate NO_OP = new SearchLoadRate(0, 0, 0.0); |
51 | | - } |
| 32 | + double getSearchLoadRate(SearchStats.Stats stats); |
52 | 33 | } |
0 commit comments