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
FieldsModifier and TypeFieldDescriptionprotected static final PatternPattern to extract DeviceID from WMI association strings.protected static final intBuffer size for volume GUID paths.protected static final intBuffer size for volume labels.protected static final StringThe prefix for physical drive paths.Fields inherited from class AbstractHWDiskStore
currentQueueLength, partitionList, readBytes, reads, timeStamp, transferTime, writeBytes, writesModifier and TypeFieldDescriptionprotected longprotected final AtomicReference<List<HWPartition>> protected longprotected longprotected longprotected longprotected longprotected long -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedWindowsHWDiskStore(String name, String model, String serial, long size) Constructor.protectedWindowsHWDiskStore(String name, String model, String serial, long size, String diskType) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected static List<HWPartition> buildPartitionList(WindowsHWDiskStore.PartitionMaps maps, String diskName) Builds an unmodifiable sorted partition list from the maps.protected static StringParse a drive name like "0 C:" to just the index "0"protected 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 StringparseWindowsMediaType(String mediaType) Parses the WMI MediaType string into a disk type.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.booleanMake a best effort to update all the statistics about the drive without needing to recreate the drive list.Methods inherited from class AbstractHWDiskStore
getCurrentQueueLength, getDiskType, getModel, getName, getPartitions, getReadBytes, getReads, getSerial, getSize, getTimeStamp, getTransferTime, getWriteBytes, getWrites, setDiskStats, setPartitionList, toStringModifier and TypeMethodDescriptionlongThe length of the disk queue (#I/O's in progress).The type of the disk, such as SSD, HDD, Removable, Virtual, or Unknown.getModel()The disk modelgetName()The disk nameThe partitions on this disk.longThe number of bytes read from the disklonggetReads()The number of reads from the diskThe disk serial number, if available.longgetSize()The size of 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 voidsetDiskStats(long reads, long readBytes, long writes, long writeBytes, long currentQueueLength, long transferTime, long timeStamp) Sets the disk statistics.protected voidsetPartitionList(List<HWPartition> partitionList) Sets the partition list.toString()
-
Field Details
-
PHYSICALDRIVE_PREFIX
-
DEVICE_ID
Pattern to extract DeviceID from WMI association strings. -
GUID_BUFSIZE
protected static final int GUID_BUFSIZEBuffer size for volume GUID paths.- See Also:
-
LABEL_BUFSIZE
protected static final int LABEL_BUFSIZEBuffer size for volume labels.- See Also:
-
-
Constructor Details
-
WindowsHWDiskStore
-
WindowsHWDiskStore
-
-
Method Details
-
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
-
parseWindowsMediaType
-