33
33
package org .opensearch .search .internal ;
34
34
35
35
import org .opensearch .LegacyESVersion ;
36
+ import org .opensearch .Version ;
36
37
import org .opensearch .action .IndicesRequest ;
37
38
import org .opensearch .action .OriginalIndices ;
38
39
import org .opensearch .action .search .SearchRequest ;
@@ -90,6 +91,8 @@ public class ShardSearchRequest extends TransportRequest implements IndicesReque
90
91
private final float indexBoost ;
91
92
private final Boolean requestCache ;
92
93
private final long nowInMillis ;
94
+ private long inboundNetworkTime ;
95
+ private long outboundNetworkTime ;
93
96
private final boolean allowPartialSearchResults ;
94
97
private final String [] indexRoutings ;
95
98
private final String preference ;
@@ -221,6 +224,8 @@ private ShardSearchRequest(
221
224
this .preference = preference ;
222
225
this .scroll = scroll ;
223
226
this .nowInMillis = nowInMillis ;
227
+ this .inboundNetworkTime = 0 ;
228
+ this .outboundNetworkTime = 0 ;
224
229
this .clusterAlias = clusterAlias ;
225
230
this .originalIndices = originalIndices ;
226
231
this .readerId = readerId ;
@@ -240,6 +245,10 @@ public ShardSearchRequest(StreamInput in) throws IOException {
240
245
indexBoost = in .readFloat ();
241
246
nowInMillis = in .readVLong ();
242
247
requestCache = in .readOptionalBoolean ();
248
+ if (in .getVersion ().onOrAfter (Version .V_2_0_0 )) {
249
+ inboundNetworkTime = in .readVLong ();
250
+ outboundNetworkTime = in .readVLong ();
251
+ }
243
252
clusterAlias = in .readOptionalString ();
244
253
if (in .getVersion ().onOrAfter (LegacyESVersion .V_7_0_0 )) {
245
254
allowPartialSearchResults = in .readBoolean ();
@@ -283,6 +292,8 @@ public ShardSearchRequest(ShardSearchRequest clone) {
283
292
this .aliasFilter = clone .aliasFilter ;
284
293
this .indexBoost = clone .indexBoost ;
285
294
this .nowInMillis = clone .nowInMillis ;
295
+ this .inboundNetworkTime = clone .inboundNetworkTime ;
296
+ this .outboundNetworkTime = clone .outboundNetworkTime ;
286
297
this .requestCache = clone .requestCache ;
287
298
this .clusterAlias = clone .clusterAlias ;
288
299
this .allowPartialSearchResults = clone .allowPartialSearchResults ;
@@ -317,6 +328,10 @@ protected final void innerWriteTo(StreamOutput out, boolean asKey) throws IOExce
317
328
out .writeVLong (nowInMillis );
318
329
}
319
330
out .writeOptionalBoolean (requestCache );
331
+ if (asKey == false && out .getVersion ().onOrAfter (Version .V_2_0_0 )) {
332
+ out .writeVLong (inboundNetworkTime );
333
+ out .writeVLong (outboundNetworkTime );
334
+ }
320
335
out .writeOptionalString (clusterAlias );
321
336
if (out .getVersion ().onOrAfter (LegacyESVersion .V_7_0_0 )) {
322
337
out .writeBoolean (allowPartialSearchResults );
@@ -395,6 +410,22 @@ public long nowInMillis() {
395
410
return nowInMillis ;
396
411
}
397
412
413
+ public long getInboundNetworkTime () {
414
+ return inboundNetworkTime ;
415
+ }
416
+
417
+ public void setInboundNetworkTime (long newTime ) {
418
+ this .inboundNetworkTime = newTime ;
419
+ }
420
+
421
+ public long getOutboundNetworkTime () {
422
+ return outboundNetworkTime ;
423
+ }
424
+
425
+ public void setOutboundNetworkTime (long newTime ) {
426
+ this .outboundNetworkTime = newTime ;
427
+ }
428
+
398
429
public Boolean requestCache () {
399
430
return requestCache ;
400
431
}
0 commit comments