2727
2828import static org .elasticsearch .TransportVersions .INDEXING_STATS_INCLUDES_RECENT_WRITE_LOAD ;
2929import static org .elasticsearch .TransportVersions .INDEX_STATS_AND_METADATA_INCLUDE_PEAK_WRITE_LOAD ;
30+ import static org .elasticsearch .TransportVersions .WRITE_LOAD_INCLUDES_BUFFER_WRITES ;
3031
3132public 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