Skip to content

Commit 04558d5

Browse files
committed
Minimize the scope of retuned dto on a per shard basis
1 parent 984063f commit 04558d5

File tree

2 files changed

+6
-25
lines changed

2 files changed

+6
-25
lines changed

server/src/main/java/org/elasticsearch/index/search/stats/ShardSearchLoadRateService.java

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,41 +12,22 @@
1212
/**
1313
* Service interface for estimating the search load rate of a shard using provided search statistics.
1414
* <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,
1616
* to track and estimate the current load on a shard based on its search activity.
1717
*/
1818
public interface ShardSearchLoadRateService {
1919

2020
/**
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}
2222
* This can be used as a fallback or default when no actual load tracking is required.
2323
*/
24-
ShardSearchLoadRateService NOOP = (stats) -> SearchLoadRate.NO_OP;
24+
ShardSearchLoadRateService NOOP = (stats) -> 0.0;
2525

2626
/**
2727
* Computes the search load rate based on the provided shard-level search statistics.
2828
*
2929
* @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
3131
*/
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);
5233
}

server/src/main/java/org/elasticsearch/index/shard/IndexShard.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1424,7 +1424,7 @@ public SearchStats searchStats(String... groups) {
14241424
/**
14251425
* Returns the search load rate stats for this shard.
14261426
*/
1427-
public ShardSearchLoadRateService.SearchLoadRate getSearchLoadRate() {
1427+
public double getSearchLoadRate() {
14281428
return shardSearchLoadRateService.getSearchLoadRate(searchStats.stats().getTotal());
14291429
}
14301430

0 commit comments

Comments
 (0)