Class WindowsHWDiskStore

java.lang.Object
oshi.hardware.common.AbstractHWDiskStore
oshi.hardware.common.platform.windows.WindowsHWDiskStore
All Implemented Interfaces:
HWDiskStore

@ThreadSafe public abstract class WindowsHWDiskStore extends AbstractHWDiskStore
Common Windows hard disk implementation shared between JNA and FFM.
  • Field Details

  • Constructor Details

    • WindowsHWDiskStore

      protected WindowsHWDiskStore(String name, String model, String serial, long size)
  • Method Details

    • getReads

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

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

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

      public long getWriteBytes()
      Description copied from interface: HWDiskStore
      The number of bytes written to the disk
      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.
      Returns:
      the current disk queue length
    • getTransferTime

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

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

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

      protected void setPartitionList(List<HWPartition> partitionList)
      Sets the partition list for this disk.
      Parameters:
      partitionList - the partition list
    • setDiskStats

      protected void setDiskStats(WindowsHWDiskStore.DiskStats stats, String index)
      Sets all disk statistics from a DiskStats object for the given index.
      Parameters:
      stats - the disk stats
      index - the disk index key
    • updateAttributes

      public boolean updateAttributes()
      Description copied from interface: HWDiskStore
      Make a best effort to update all the statistics about the drive without needing to recreate the drive list. This method provides for more frequent periodic updates of individual drive statistics but may be less efficient to use if updating all drives. It will not detect if a removable drive has been removed and replaced by a different drive in between method calls.
      Returns:
      True if the update was (probably) successful, false if the disk was not found
    • queryReadWriteStats

      protected abstract WindowsHWDiskStore.DiskStats queryReadWriteStats(String index)
      Queries performance counter data for disk read/write stats.
      Parameters:
      index - The disk index to query, or null for all disks
      Returns:
      A non-null WindowsHWDiskStore.DiskStats object; its maps (e.g. WindowsHWDiskStore.DiskStats.getReadMap()) are never null but may be empty if no counters matched the given index
    • populateDiskStats

      protected static WindowsHWDiskStore.DiskStats populateDiskStats(String index, Pair<List<String>, Map<PhysicalDisk.PhysicalDiskProperty, List<Long>>> instanceValuePair)
      Populates a DiskStats object from performance counter data.
      Parameters:
      index - The disk index to filter on, or null for all
      instanceValuePair - The raw PDH counter data
      Returns:
      A populated DiskStats object
    • mapDriveToPartition

      protected static void mapDriveToPartition(WindowsHWDiskStore.PartitionMaps maps, String antecedent, String dependent)
      Populates the drive-to-partition map from WMI association data.
      Parameters:
      maps - The PartitionMaps to populate
      antecedent - The antecedent device ID string
      dependent - The dependent device ID string
    • mapPartitionToLogicalDrive

      protected static void mapPartitionToLogicalDrive(WindowsHWDiskStore.PartitionMaps maps, String antecedent, String dependent, long size)
      Populates the partition-to-logical-drive map from WMI association data.
      Parameters:
      maps - The PartitionMaps to populate
      antecedent - The antecedent device ID string
      dependent - The dependent device ID string
      size - The partition size
    • buildPartitionList

      protected static List<HWPartition> buildPartitionList(WindowsHWDiskStore.PartitionMaps maps, String diskName)
      Builds an unmodifiable sorted partition list from the maps.
      Parameters:
      maps - The partition maps
      diskName - The disk name to look up
      Returns:
      A sorted unmodifiable list of partitions
    • getIndexFromName

      protected static String getIndexFromName(String s)
      Parse a drive name like "0 C:" to just the index "0"
      Parameters:
      s - A drive name to parse
      Returns:
      The first space-delimited value