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

    • PHYSICALDRIVE_PREFIX

      protected static final String PHYSICALDRIVE_PREFIX
      The prefix for physical drive paths.
      See Also:
    • DEVICE_ID

      protected static final Pattern DEVICE_ID
      Pattern to extract DeviceID from WMI association strings.
    • GUID_BUFSIZE

      protected static final int GUID_BUFSIZE
      Buffer size for volume GUID paths.
      See Also:
    • LABEL_BUFSIZE

      protected static final int LABEL_BUFSIZE
      Buffer size for volume labels.
      See Also:
  • Constructor Details

    • WindowsHWDiskStore

      protected WindowsHWDiskStore(String name, String model, String serial, long size)
      Constructor.
      Parameters:
      name - the name
      model - the model
      serial - the serial
      size - the size
    • WindowsHWDiskStore

      protected WindowsHWDiskStore(String name, String model, String serial, long size, String diskType)
      Constructor.
      Parameters:
      name - the name
      model - the model
      serial - the serial
      size - the size
      diskType - the diskType
  • Method Details

    • 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
    • parseWindowsMediaType

      protected static String parseWindowsMediaType(String mediaType)
      Parses the WMI MediaType string into a disk type.
      Parameters:
      mediaType - the WMI MediaType value from Win32_DiskDrive
      Returns:
      the disk type string