Class AbstractHWDiskStore

java.lang.Object
oshi.hardware.common.AbstractHWDiskStore
All Implemented Interfaces:
HWDiskStore
Direct Known Subclasses:
AixHWDiskStore, FreeBsdHWDiskStore, LinuxHWDiskStore, MacHWDiskStore, NetBsdHWDiskStore, OpenBsdHWDiskStore, SolarisHWDiskStore, WindowsHWDiskStore

@ThreadSafe public abstract class AbstractHWDiskStore extends Object implements HWDiskStore
Common methods for platform HWDiskStore classes
  • Field Details

    • reads

      protected volatile long reads
    • readBytes

      protected volatile long readBytes
    • writes

      protected volatile long writes
    • writeBytes

      protected volatile long writeBytes
    • currentQueueLength

      protected volatile long currentQueueLength
    • transferTime

      protected volatile long transferTime
    • timeStamp

      protected volatile long timeStamp
    • partitionList

      protected final AtomicReference<List<HWPartition>> partitionList
  • Constructor Details

    • AbstractHWDiskStore

      protected AbstractHWDiskStore(String name, String model, String serial, long size)
      Creates an AbstractHWDiskStore with unknown disk type.
      Parameters:
      name - the disk name
      model - the disk model
      serial - the disk serial number
      size - the disk size in bytes
    • AbstractHWDiskStore

      protected AbstractHWDiskStore(String name, String model, String serial, long size, String diskType)
      Creates an AbstractHWDiskStore.
      Parameters:
      name - the disk name
      model - the disk model
      serial - the disk serial number
      size - the disk size in bytes
      diskType - the disk type (e.g., SSD, HDD)
  • Method Details

    • getName

      public String getName()
      Description copied from interface: HWDiskStore
      The disk name
      Specified by:
      getName in interface HWDiskStore
      Returns:
      the name
    • getModel

      public String getModel()
      Description copied from interface: HWDiskStore
      The disk model
      Specified by:
      getModel in interface HWDiskStore
      Returns:
      the model
    • getSerial

      public String getSerial()
      Description copied from interface: HWDiskStore
      The disk serial number, if available.
      Specified by:
      getSerial in interface HWDiskStore
      Returns:
      the serial number
    • getSize

      public long getSize()
      Description copied from interface: HWDiskStore
      The size of the disk
      Specified by:
      getSize in interface HWDiskStore
      Returns:
      the disk size, in bytes
    • getDiskType

      public String getDiskType()
      Description copied from interface: HWDiskStore
      The type of the disk, such as SSD, HDD, Removable, Virtual, or Unknown.
      Specified by:
      getDiskType in interface HWDiskStore
      Returns:
      the disk type string
    • getReads

      public long getReads()
      Description copied from interface: HWDiskStore
      The number of reads from the disk
      Specified by:
      getReads in interface HWDiskStore
      Returns:
      the reads
    • getReadBytes

      public long getReadBytes()
      Description copied from interface: HWDiskStore
      The number of bytes read from the disk
      Specified by:
      getReadBytes in interface HWDiskStore
      Returns:
      the bytes read
    • getWrites

      public long getWrites()
      Description copied from interface: HWDiskStore
      The number of writes to the disk
      Specified by:
      getWrites in interface HWDiskStore
      Returns:
      the writes
    • getWriteBytes

      public long getWriteBytes()
      Description copied from interface: HWDiskStore
      The number of bytes written to the disk
      Specified by:
      getWriteBytes in interface HWDiskStore
      Returns:
      the bytes written
    • getCurrentQueueLength

      public long getCurrentQueueLength()
      Description copied from interface: HWDiskStore
      The length of the disk queue (#I/O's in progress). Includes I/O requests that have been issued to the device driver but have not yet completed. Not supported on macOS.
      Specified by:
      getCurrentQueueLength in interface HWDiskStore
      Returns:
      the current disk queue length
    • getTransferTime

      public long getTransferTime()
      Description copied from interface: HWDiskStore
      The time spent reading or writing, in milliseconds.
      Specified by:
      getTransferTime in interface HWDiskStore
      Returns:
      the transfer time
    • getTimeStamp

      public long getTimeStamp()
      Description copied from interface: HWDiskStore
      The time this disk's statistics were updated.
      Specified by:
      getTimeStamp in interface HWDiskStore
      Returns:
      the timeStamp, in milliseconds since the epoch.
    • getPartitions

      public List<HWPartition> getPartitions()
      Description copied from interface: HWDiskStore
      The partitions on this disk.
      Specified by:
      getPartitions in interface HWDiskStore
      Returns:
      an UnmodifiableList of the partitions on this drive.
    • setDiskStats

      protected void setDiskStats(long reads, long readBytes, long writes, long writeBytes, long currentQueueLength, long transferTime, long timeStamp)
      Sets the disk statistics.
      Parameters:
      reads - number of reads
      readBytes - bytes read
      writes - number of writes
      writeBytes - bytes written
      currentQueueLength - current I/O queue length
      transferTime - time spent on transfers in ms
      timeStamp - timestamp of the measurement
    • setPartitionList

      protected void setPartitionList(List<HWPartition> partitionList)
      Sets the partition list.
      Parameters:
      partitionList - the partition list
    • toString

      public String toString()
      Overrides:
      toString in class Object