@@ -174,6 +174,8 @@ public static class DeviceStats implements Writeable, ToXContentFragment {
174
174
final long previousWritesCompleted ;
175
175
final long currentSectorsWritten ;
176
176
final long previousSectorsWritten ;
177
+ final long currentIOTime ;
178
+ final long previousIOTime ;
177
179
178
180
public DeviceStats (
179
181
final int majorDeviceNumber ,
@@ -183,6 +185,7 @@ public DeviceStats(
183
185
final long currentSectorsRead ,
184
186
final long currentWritesCompleted ,
185
187
final long currentSectorsWritten ,
188
+ final long currentIOTime ,
186
189
final DeviceStats previousDeviceStats ) {
187
190
this (
188
191
majorDeviceNumber ,
@@ -195,7 +198,9 @@ public DeviceStats(
195
198
currentSectorsRead ,
196
199
previousDeviceStats != null ? previousDeviceStats .currentSectorsRead : -1 ,
197
200
currentWritesCompleted ,
198
- previousDeviceStats != null ? previousDeviceStats .currentWritesCompleted : -1 );
201
+ previousDeviceStats != null ? previousDeviceStats .currentWritesCompleted : -1 ,
202
+ currentIOTime ,
203
+ previousDeviceStats != null ? previousDeviceStats .currentIOTime : -1 );
199
204
}
200
205
201
206
private DeviceStats (
@@ -209,7 +214,9 @@ private DeviceStats(
209
214
final long currentSectorsRead ,
210
215
final long previousSectorsRead ,
211
216
final long currentWritesCompleted ,
212
- final long previousWritesCompleted ) {
217
+ final long previousWritesCompleted ,
218
+ final long currentIOTime ,
219
+ final long previousIOTime ) {
213
220
this .majorDeviceNumber = majorDeviceNumber ;
214
221
this .minorDeviceNumber = minorDeviceNumber ;
215
222
this .deviceName = deviceName ;
@@ -221,6 +228,8 @@ private DeviceStats(
221
228
this .previousSectorsRead = previousSectorsRead ;
222
229
this .currentSectorsWritten = currentSectorsWritten ;
223
230
this .previousSectorsWritten = previousSectorsWritten ;
231
+ this .currentIOTime = currentIOTime ;
232
+ this .previousIOTime = previousIOTime ;
224
233
}
225
234
226
235
public DeviceStats (StreamInput in ) throws IOException {
@@ -235,6 +244,13 @@ public DeviceStats(StreamInput in) throws IOException {
235
244
previousSectorsRead = in .readLong ();
236
245
currentSectorsWritten = in .readLong ();
237
246
previousSectorsWritten = in .readLong ();
247
+ if (in .getVersion ().onOrAfter (Version .V_7_14_0 )) {
248
+ currentIOTime = in .readLong ();
249
+ previousIOTime = in .readLong ();
250
+ } else {
251
+ currentIOTime = -1 ;
252
+ previousIOTime = -1 ;
253
+ }
238
254
}
239
255
240
256
@ Override
@@ -250,6 +266,10 @@ public void writeTo(StreamOutput out) throws IOException {
250
266
out .writeLong (previousSectorsRead );
251
267
out .writeLong (currentSectorsWritten );
252
268
out .writeLong (previousSectorsWritten );
269
+ if (out .getVersion ().onOrAfter (Version .V_7_14_0 )) {
270
+ out .writeLong (currentIOTime );
271
+ out .writeLong (previousIOTime );
272
+ }
253
273
}
254
274
255
275
public long operations () {
@@ -283,6 +303,12 @@ public long writeKilobytes() {
283
303
return (currentSectorsWritten - previousSectorsWritten ) / 2 ;
284
304
}
285
305
306
+ public long ioTimeInMillis () {
307
+ if (previousIOTime == -1 ) return -1 ;
308
+
309
+ return (currentIOTime - previousIOTime );
310
+ }
311
+
286
312
@ Override
287
313
public XContentBuilder toXContent (XContentBuilder builder , Params params ) throws IOException {
288
314
builder .field ("device_name" , deviceName );
@@ -291,6 +317,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
291
317
builder .field (IoStats .WRITE_OPERATIONS , writeOperations ());
292
318
builder .field (IoStats .READ_KILOBYTES , readKilobytes ());
293
319
builder .field (IoStats .WRITE_KILOBYTES , writeKilobytes ());
320
+ builder .field (IoStats .IO_TIMEMS , ioTimeInMillis ());
294
321
return builder ;
295
322
}
296
323
@@ -303,13 +330,16 @@ public static class IoStats implements Writeable, ToXContentFragment {
303
330
private static final String WRITE_OPERATIONS = "write_operations" ;
304
331
private static final String READ_KILOBYTES = "read_kilobytes" ;
305
332
private static final String WRITE_KILOBYTES = "write_kilobytes" ;
333
+ private static final String IO_TIMEMS = "io_time_in_millis" ;
334
+
306
335
307
336
final DeviceStats [] devicesStats ;
308
337
final long totalOperations ;
309
338
final long totalReadOperations ;
310
339
final long totalWriteOperations ;
311
340
final long totalReadKilobytes ;
312
341
final long totalWriteKilobytes ;
342
+ final long totalIOTimeInMillis ;
313
343
314
344
public IoStats (final DeviceStats [] devicesStats ) {
315
345
this .devicesStats = devicesStats ;
@@ -318,18 +348,21 @@ public IoStats(final DeviceStats[] devicesStats) {
318
348
long totalWriteOperations = 0 ;
319
349
long totalReadKilobytes = 0 ;
320
350
long totalWriteKilobytes = 0 ;
351
+ long totalIOTimeInMillis = 0 ;
321
352
for (DeviceStats deviceStats : devicesStats ) {
322
353
totalOperations += deviceStats .operations () != -1 ? deviceStats .operations () : 0 ;
323
354
totalReadOperations += deviceStats .readOperations () != -1 ? deviceStats .readOperations () : 0 ;
324
355
totalWriteOperations += deviceStats .writeOperations () != -1 ? deviceStats .writeOperations () : 0 ;
325
356
totalReadKilobytes += deviceStats .readKilobytes () != -1 ? deviceStats .readKilobytes () : 0 ;
326
357
totalWriteKilobytes += deviceStats .writeKilobytes () != -1 ? deviceStats .writeKilobytes () : 0 ;
358
+ totalIOTimeInMillis += deviceStats .ioTimeInMillis () != -1 ? deviceStats .ioTimeInMillis () : 0 ;
327
359
}
328
360
this .totalOperations = totalOperations ;
329
361
this .totalReadOperations = totalReadOperations ;
330
362
this .totalWriteOperations = totalWriteOperations ;
331
363
this .totalReadKilobytes = totalReadKilobytes ;
332
364
this .totalWriteKilobytes = totalWriteKilobytes ;
365
+ this .totalIOTimeInMillis = totalIOTimeInMillis ;
333
366
}
334
367
335
368
public IoStats (StreamInput in ) throws IOException {
@@ -344,6 +377,11 @@ public IoStats(StreamInput in) throws IOException {
344
377
this .totalWriteOperations = in .readLong ();
345
378
this .totalReadKilobytes = in .readLong ();
346
379
this .totalWriteKilobytes = in .readLong ();
380
+ if (in .getVersion ().onOrAfter (Version .V_7_14_0 )) {
381
+ this .totalIOTimeInMillis = in .readLong ();
382
+ } else {
383
+ this .totalIOTimeInMillis = -1 ;
384
+ }
347
385
}
348
386
349
387
@ Override
@@ -357,6 +395,9 @@ public void writeTo(StreamOutput out) throws IOException {
357
395
out .writeLong (totalWriteOperations );
358
396
out .writeLong (totalReadKilobytes );
359
397
out .writeLong (totalWriteKilobytes );
398
+ if (out .getVersion ().onOrAfter (Version .V_7_14_0 )) {
399
+ out .writeLong (totalIOTimeInMillis );
400
+ }
360
401
}
361
402
362
403
public DeviceStats [] getDevicesStats () {
@@ -383,6 +424,10 @@ public long getTotalWriteKilobytes() {
383
424
return totalWriteKilobytes ;
384
425
}
385
426
427
+ public long getTotalIOTimeMillis () {
428
+ return totalIOTimeInMillis ;
429
+ }
430
+
386
431
@ Override
387
432
public XContentBuilder toXContent (XContentBuilder builder , Params params ) throws IOException {
388
433
if (devicesStats .length > 0 ) {
@@ -400,6 +445,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
400
445
builder .field (WRITE_OPERATIONS , totalWriteOperations );
401
446
builder .field (READ_KILOBYTES , totalReadKilobytes );
402
447
builder .field (WRITE_KILOBYTES , totalWriteKilobytes );
448
+ builder .field (IO_TIMEMS , totalIOTimeInMillis );
403
449
builder .endObject ();
404
450
}
405
451
return builder ;
0 commit comments