Skip to content

Commit 7636b32

Browse files
committed
Add transport version
1 parent d28b2af commit 7636b32

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

server/src/main/java/org/elasticsearch/TransportVersions.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ static TransportVersion def(int id) {
219219
public static final TransportVersion REPO_ANALYSIS_COPY_BLOB = def(9_048_00_0);
220220
public static final TransportVersion AMAZON_BEDROCK_TASK_SETTINGS = def(9_049_00_0);
221221
public static final TransportVersion ESQL_REPORT_SHARD_PARTITIONING = def(9_050_00_0);
222+
public static final TransportVersion WRITE_LOAD_INCLUDES_BUFFER_WRITES = def(9_051_00_0);
222223

223224
/*
224225
* STOP! READ THIS FIRST! No, really,

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
import static org.elasticsearch.TransportVersions.INDEXING_STATS_INCLUDES_RECENT_WRITE_LOAD;
2929
import static org.elasticsearch.TransportVersions.INDEX_STATS_AND_METADATA_INCLUDE_PEAK_WRITE_LOAD;
30+
import static org.elasticsearch.TransportVersions.WRITE_LOAD_INCLUDES_BUFFER_WRITES;
3031

3132
public class IndexingStats implements Writeable, ToXContentFragment {
3233

@@ -76,7 +77,7 @@ public Stats(StreamInput in) throws IOException {
7677
// When getting stats from an older version which doesn't have the recent indexing load, better to fall back to the
7778
// unweighted write load, rather that assuming zero load:
7879
recentIndexingLoad = totalActiveTimeInNanos > 0
79-
? (double) totalIndexingLoadSinceShardStartedInNanos / totalActiveTimeInNanos
80+
? (double) totalIndexingTimeSinceShardStartedInNanos / totalActiveTimeInNanos
8081
: 0;
8182
}
8283
if (in.getTransportVersion().onOrAfter(INDEX_STATS_AND_METADATA_INCLUDE_PEAK_WRITE_LOAD)) {
@@ -88,6 +89,13 @@ public Stats(StreamInput in) throws IOException {
8889
? (double) totalIndexingTimeSinceShardStartedInNanos / totalActiveTimeInNanos
8990
: 0;
9091
}
92+
if (in.getTransportVersion().onOrAfter(WRITE_LOAD_INCLUDES_BUFFER_WRITES)) {
93+
totalIndexingLoadSinceShardStartedInNanos = in.readLong();
94+
} else {
95+
// When getting stats from an older version which doesn't have the more accurate indexing load, better to fall back to the
96+
// indexing time, rather that assuming zero load:
97+
totalIndexingLoadSinceShardStartedInNanos = totalActiveTimeInNanos > 0 ? totalIndexingTimeSinceShardStartedInNanos : 0;
98+
}
9199
}
92100

93101
public Stats(
@@ -300,6 +308,9 @@ public void writeTo(StreamOutput out) throws IOException {
300308
if (out.getTransportVersion().onOrAfter(INDEX_STATS_AND_METADATA_INCLUDE_PEAK_WRITE_LOAD)) {
301309
out.writeDouble(peakIndexingLoad);
302310
}
311+
if (out.getTransportVersion().onOrAfter(WRITE_LOAD_INCLUDES_BUFFER_WRITES)) {
312+
out.writeLong(totalIndexingLoadSinceShardStartedInNanos);
313+
}
303314
}
304315

305316
@Override

0 commit comments

Comments
 (0)