Class WindowsHWDiskStore
java.lang.Object
oshi.hardware.common.AbstractHWDiskStore
oshi.hardware.common.platform.windows.WindowsHWDiskStore
- All Implemented Interfaces:
HWDiskStore
Common Windows hard disk implementation shared between JNA and FFM.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static final classMaps to store read/write bytes per drive indexprotected static final classMaps for the partition structure -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedWindowsHWDiskStore(String name, String model, String serial, long size) -
Method Summary
Modifier and TypeMethodDescriptionprotected static List<HWPartition> buildPartitionList(WindowsHWDiskStore.PartitionMaps maps, String diskName) Builds an unmodifiable sorted partition list from the maps.longThe length of the disk queue (#I/O's in progress).protected static StringParse a drive name like "0 C:" to just the index "0"The partitions on this disk.longThe number of bytes read from the disklonggetReads()The number of reads from the disklongThe time this disk's statistics were updated.longThe time spent reading or writing, in milliseconds.longThe number of bytes written to the disklongThe number of writes to the diskprotected static voidmapDriveToPartition(WindowsHWDiskStore.PartitionMaps maps, String antecedent, String dependent) Populates the drive-to-partition map from WMI association data.protected static voidmapPartitionToLogicalDrive(WindowsHWDiskStore.PartitionMaps maps, String antecedent, String dependent, long size) Populates the partition-to-logical-drive map from WMI association data.protected static WindowsHWDiskStore.DiskStatspopulateDiskStats(String index, Pair<List<String>, Map<PhysicalDisk.PhysicalDiskProperty, List<Long>>> instanceValuePair) Populates a DiskStats object from performance counter data.protected abstract WindowsHWDiskStore.DiskStatsqueryReadWriteStats(String index) Queries performance counter data for disk read/write stats.protected voidsetDiskStats(WindowsHWDiskStore.DiskStats stats, String index) Sets all disk statistics from a DiskStats object for the given index.protected voidsetPartitionList(List<HWPartition> partitionList) Sets the partition list for this disk.booleanMake a best effort to update all the statistics about the drive without needing to recreate the drive list.
-
Field Details
-
PHYSICALDRIVE_PREFIX
- See Also:
-
DEVICE_ID
-
GUID_BUFSIZE
protected static final int GUID_BUFSIZE- See Also:
-
LABEL_BUFSIZE
protected static final int LABEL_BUFSIZE- See Also:
-
-
Constructor Details
-
WindowsHWDiskStore
-
-
Method Details
-
getReads
public long getReads()Description copied from interface:HWDiskStoreThe number of reads from the disk- Returns:
- the reads
-
getReadBytes
public long getReadBytes()Description copied from interface:HWDiskStoreThe number of bytes read from the disk- Returns:
- the bytes read
-
getWrites
public long getWrites()Description copied from interface:HWDiskStoreThe number of writes to the disk- Returns:
- the writes
-
getWriteBytes
public long getWriteBytes()Description copied from interface:HWDiskStoreThe number of bytes written to the disk- Returns:
- the bytes written
-
getCurrentQueueLength
public long getCurrentQueueLength()Description copied from interface:HWDiskStoreThe 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:HWDiskStoreThe time spent reading or writing, in milliseconds.- Returns:
- the transfer time
-
getTimeStamp
public long getTimeStamp()Description copied from interface:HWDiskStoreThe time this disk's statistics were updated.- Returns:
- the timeStamp, in milliseconds since the epoch.
-
getPartitions
Description copied from interface:HWDiskStoreThe partitions on this disk.- Returns:
- an
UnmodifiableListof the partitions on this drive.
-
setPartitionList
Sets the partition list for this disk.- Parameters:
partitionList- the partition list
-
setDiskStats
Sets all disk statistics from a DiskStats object for the given index.- Parameters:
stats- the disk statsindex- the disk index key
-
updateAttributes
public boolean updateAttributes()Description copied from interface:HWDiskStoreMake 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
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.DiskStatsobject; 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 allinstanceValuePair- 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 populateantecedent- The antecedent device ID stringdependent- 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 populateantecedent- The antecedent device ID stringdependent- The dependent device ID stringsize- 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 mapsdiskName- The disk name to look up- Returns:
- A sorted unmodifiable list of partitions
-
getIndexFromName
-