@@ -235,6 +235,14 @@ public static class DeviceStats implements Writeable, ToXContentFragment {
235235 final long previousWritesCompleted ;
236236 final long currentSectorsWritten ;
237237 final long previousSectorsWritten ;
238+ final long currentReadTime ;
239+ final long previousReadTime ;
240+ final long currentWriteTime ;
241+ final long previousWriteTime ;
242+ final long currentQueueSize ;
243+ final long previousQueueSize ;
244+ final long currentIOTime ;
245+ final long previousIOTime ;
238246
239247 public DeviceStats (
240248 final int majorDeviceNumber ,
@@ -244,6 +252,10 @@ public DeviceStats(
244252 final long currentSectorsRead ,
245253 final long currentWritesCompleted ,
246254 final long currentSectorsWritten ,
255+ final long currentReadTime ,
256+ final long currentWriteTime ,
257+ final long currrentQueueSize ,
258+ final long currentIOTime ,
247259 final DeviceStats previousDeviceStats
248260 ) {
249261 this (
@@ -257,7 +269,15 @@ public DeviceStats(
257269 currentSectorsRead ,
258270 previousDeviceStats != null ? previousDeviceStats .currentSectorsRead : -1 ,
259271 currentWritesCompleted ,
260- previousDeviceStats != null ? previousDeviceStats .currentWritesCompleted : -1
272+ previousDeviceStats != null ? previousDeviceStats .currentWritesCompleted : -1 ,
273+ currentReadTime ,
274+ previousDeviceStats != null ? previousDeviceStats .currentReadTime : -1 ,
275+ currentWriteTime ,
276+ previousDeviceStats != null ? previousDeviceStats .currentWriteTime : -1 ,
277+ currrentQueueSize ,
278+ previousDeviceStats != null ? previousDeviceStats .currentQueueSize : -1 ,
279+ currentIOTime ,
280+ previousDeviceStats != null ? previousDeviceStats .currentIOTime : -1
261281 );
262282 }
263283
@@ -272,7 +292,15 @@ private DeviceStats(
272292 final long currentSectorsRead ,
273293 final long previousSectorsRead ,
274294 final long currentWritesCompleted ,
275- final long previousWritesCompleted
295+ final long previousWritesCompleted ,
296+ final long currentReadTime ,
297+ final long previousReadTime ,
298+ final long currentWriteTime ,
299+ final long previousWriteTime ,
300+ final long currentQueueSize ,
301+ final long previousQueueSize ,
302+ final long currentIOTime ,
303+ final long previousIOTime
276304 ) {
277305 this .majorDeviceNumber = majorDeviceNumber ;
278306 this .minorDeviceNumber = minorDeviceNumber ;
@@ -285,6 +313,14 @@ private DeviceStats(
285313 this .previousSectorsRead = previousSectorsRead ;
286314 this .currentSectorsWritten = currentSectorsWritten ;
287315 this .previousSectorsWritten = previousSectorsWritten ;
316+ this .currentReadTime = currentReadTime ;
317+ this .previousReadTime = previousReadTime ;
318+ this .currentWriteTime = currentWriteTime ;
319+ this .previousWriteTime = previousWriteTime ;
320+ this .currentQueueSize = currentQueueSize ;
321+ this .previousQueueSize = previousQueueSize ;
322+ this .currentIOTime = currentIOTime ;
323+ this .previousIOTime = previousIOTime ;
288324 }
289325
290326 public DeviceStats (StreamInput in ) throws IOException {
@@ -299,6 +335,14 @@ public DeviceStats(StreamInput in) throws IOException {
299335 previousSectorsRead = in .readLong ();
300336 currentSectorsWritten = in .readLong ();
301337 previousSectorsWritten = in .readLong ();
338+ currentReadTime = in .readLong ();
339+ previousReadTime = in .readLong ();
340+ currentWriteTime = in .readLong ();
341+ previousWriteTime = in .readLong ();
342+ currentQueueSize = in .readLong ();
343+ previousQueueSize = in .readLong ();
344+ currentIOTime = in .readLong ();
345+ previousIOTime = in .readLong ();
302346 }
303347
304348 @ Override
@@ -314,6 +358,14 @@ public void writeTo(StreamOutput out) throws IOException {
314358 out .writeLong (previousSectorsRead );
315359 out .writeLong (currentSectorsWritten );
316360 out .writeLong (previousSectorsWritten );
361+ out .writeLong (currentReadTime );
362+ out .writeLong (previousReadTime );
363+ out .writeLong (currentWriteTime );
364+ out .writeLong (previousWriteTime );
365+ out .writeLong (currentQueueSize );
366+ out .writeLong (previousQueueSize );
367+ out .writeLong (currentIOTime );
368+ out .writeLong (previousIOTime );
317369 }
318370
319371 public long operations () {
@@ -346,6 +398,39 @@ public long writeKilobytes() {
346398 return (currentSectorsWritten - previousSectorsWritten ) / 2 ;
347399 }
348400
401+ /**
402+ * Total time taken for all read operations
403+ */
404+ public long readTime () {
405+ if (previousReadTime == -1 ) return -1 ;
406+ return currentReadTime - previousReadTime ;
407+ }
408+
409+ /**
410+ * Total time taken for all write operations
411+ */
412+ public long writeTime () {
413+ if (previousWriteTime == -1 ) return -1 ;
414+ return currentWriteTime - previousWriteTime ;
415+ }
416+
417+ /**
418+ * Queue size based on weighted time spent doing I/Os
419+ */
420+ public long queueSize () {
421+ if (previousQueueSize == -1 ) return -1 ;
422+ return currentQueueSize - previousQueueSize ;
423+ }
424+
425+ /**
426+ * Total time spent doing I/Os
427+ */
428+ public long ioTimeInMillis () {
429+ if (previousIOTime == -1 ) return -1 ;
430+
431+ return (currentIOTime - previousIOTime );
432+ }
433+
349434 @ Override
350435 public XContentBuilder toXContent (XContentBuilder builder , Params params ) throws IOException {
351436 builder .field ("device_name" , deviceName );
@@ -354,9 +439,12 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
354439 builder .field (IoStats .WRITE_OPERATIONS , writeOperations ());
355440 builder .field (IoStats .READ_KILOBYTES , readKilobytes ());
356441 builder .field (IoStats .WRITE_KILOBYTES , writeKilobytes ());
442+ builder .field (IoStats .READ_TIME , readTime ());
443+ builder .field (IoStats .WRITE_TIME , writeTime ());
444+ builder .field (IoStats .QUEUE_SIZE , queueSize ());
445+ builder .field (IoStats .IO_TIME_MS , ioTimeInMillis ());
357446 return builder ;
358447 }
359-
360448 }
361449
362450 /**
@@ -371,13 +459,21 @@ public static class IoStats implements Writeable, ToXContentFragment {
371459 private static final String WRITE_OPERATIONS = "write_operations" ;
372460 private static final String READ_KILOBYTES = "read_kilobytes" ;
373461 private static final String WRITE_KILOBYTES = "write_kilobytes" ;
462+ private static final String READ_TIME = "read_time" ;
463+ private static final String WRITE_TIME = "write_time" ;
464+ private static final String QUEUE_SIZE = "queue_size" ;
465+ private static final String IO_TIME_MS = "io_time_in_millis" ;
374466
375467 final DeviceStats [] devicesStats ;
376468 final long totalOperations ;
377469 final long totalReadOperations ;
378470 final long totalWriteOperations ;
379471 final long totalReadKilobytes ;
380472 final long totalWriteKilobytes ;
473+ final long totalReadTime ;
474+ final long totalWriteTime ;
475+ final long totalQueueSize ;
476+ final long totalIOTimeInMillis ;
381477
382478 public IoStats (final DeviceStats [] devicesStats ) {
383479 this .devicesStats = devicesStats ;
@@ -386,18 +482,30 @@ public IoStats(final DeviceStats[] devicesStats) {
386482 long totalWriteOperations = 0 ;
387483 long totalReadKilobytes = 0 ;
388484 long totalWriteKilobytes = 0 ;
485+ long totalReadTime = 0 ;
486+ long totalWriteTime = 0 ;
487+ long totalQueueSize = 0 ;
488+ long totalIOTimeInMillis = 0 ;
389489 for (DeviceStats deviceStats : devicesStats ) {
390490 totalOperations += deviceStats .operations () != -1 ? deviceStats .operations () : 0 ;
391491 totalReadOperations += deviceStats .readOperations () != -1 ? deviceStats .readOperations () : 0 ;
392492 totalWriteOperations += deviceStats .writeOperations () != -1 ? deviceStats .writeOperations () : 0 ;
393493 totalReadKilobytes += deviceStats .readKilobytes () != -1 ? deviceStats .readKilobytes () : 0 ;
394494 totalWriteKilobytes += deviceStats .writeKilobytes () != -1 ? deviceStats .writeKilobytes () : 0 ;
495+ totalReadTime += deviceStats .readTime () != -1 ? deviceStats .readTime () : 0 ;
496+ totalWriteTime += deviceStats .writeTime () != -1 ? deviceStats .writeTime () : 0 ;
497+ totalQueueSize += deviceStats .queueSize () != -1 ? deviceStats .queueSize () : 0 ;
498+ totalIOTimeInMillis += deviceStats .ioTimeInMillis () != -1 ? deviceStats .ioTimeInMillis () : 0 ;
395499 }
396500 this .totalOperations = totalOperations ;
397501 this .totalReadOperations = totalReadOperations ;
398502 this .totalWriteOperations = totalWriteOperations ;
399503 this .totalReadKilobytes = totalReadKilobytes ;
400504 this .totalWriteKilobytes = totalWriteKilobytes ;
505+ this .totalReadTime = totalReadTime ;
506+ this .totalWriteTime = totalWriteTime ;
507+ this .totalQueueSize = totalQueueSize ;
508+ this .totalIOTimeInMillis = totalIOTimeInMillis ;
401509 }
402510
403511 public IoStats (StreamInput in ) throws IOException {
@@ -412,6 +520,17 @@ public IoStats(StreamInput in) throws IOException {
412520 this .totalWriteOperations = in .readLong ();
413521 this .totalReadKilobytes = in .readLong ();
414522 this .totalWriteKilobytes = in .readLong ();
523+ if (in .getVersion ().onOrAfter (Version .V_3_0_0 )) {
524+ this .totalReadTime = in .readLong ();
525+ this .totalWriteTime = in .readLong ();
526+ this .totalQueueSize = in .readLong ();
527+ this .totalIOTimeInMillis = in .readLong ();
528+ } else {
529+ this .totalReadTime = 0 ;
530+ this .totalWriteTime = 0 ;
531+ this .totalQueueSize = 0 ;
532+ this .totalIOTimeInMillis = 0 ;
533+ }
415534 }
416535
417536 @ Override
@@ -425,6 +544,12 @@ public void writeTo(StreamOutput out) throws IOException {
425544 out .writeLong (totalWriteOperations );
426545 out .writeLong (totalReadKilobytes );
427546 out .writeLong (totalWriteKilobytes );
547+ if (out .getVersion ().onOrAfter (Version .V_3_0_0 )) {
548+ out .writeLong (totalReadTime );
549+ out .writeLong (totalWriteTime );
550+ out .writeLong (totalQueueSize );
551+ out .writeLong (totalIOTimeInMillis );
552+ }
428553 }
429554
430555 public DeviceStats [] getDevicesStats () {
@@ -451,6 +576,34 @@ public long getTotalWriteKilobytes() {
451576 return totalWriteKilobytes ;
452577 }
453578
579+ /**
580+ * Sum of read time across all devices
581+ */
582+ public long getTotalReadTime () {
583+ return totalReadTime ;
584+ }
585+
586+ /**
587+ * Sum of write time across all devices
588+ */
589+ public long getTotalWriteTime () {
590+ return totalWriteTime ;
591+ }
592+
593+ /**
594+ * Sum of queue size across all devices
595+ */
596+ public long getTotalQueueSize () {
597+ return totalQueueSize ;
598+ }
599+
600+ /**
601+ * Sum of IO time across all devices
602+ */
603+ public long getTotalIOTimeMillis () {
604+ return totalIOTimeInMillis ;
605+ }
606+
454607 @ Override
455608 public XContentBuilder toXContent (XContentBuilder builder , Params params ) throws IOException {
456609 if (devicesStats .length > 0 ) {
@@ -468,11 +621,15 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
468621 builder .field (WRITE_OPERATIONS , totalWriteOperations );
469622 builder .field (READ_KILOBYTES , totalReadKilobytes );
470623 builder .field (WRITE_KILOBYTES , totalWriteKilobytes );
624+
625+ builder .field (READ_TIME , totalReadTime );
626+ builder .field (WRITE_TIME , totalWriteTime );
627+ builder .field (QUEUE_SIZE , totalQueueSize );
628+ builder .field (IO_TIME_MS , totalIOTimeInMillis );
471629 builder .endObject ();
472630 }
473631 return builder ;
474632 }
475-
476633 }
477634
478635 private final long timestamp ;
0 commit comments