Package oshi.hardware.platform.mac
Class MacHWDiskStore
- java.lang.Object
-
- oshi.hardware.common.AbstractHWDiskStore
-
- oshi.hardware.platform.mac.MacHWDiskStore
-
- All Implemented Interfaces:
HWDiskStore
@ThreadSafe public final class MacHWDiskStore extends AbstractHWDiskStore
Mac hard disk implementation.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
MacHWDiskStore.CFKey
-
Field Summary
Fields Modifier and Type Field Description private static com.sun.jna.platform.mac.CoreFoundation
CF
private long
currentQueueLength
private static com.sun.jna.platform.mac.DiskArbitration
DA
private static org.slf4j.Logger
LOG
private java.util.List<HWPartition>
partitionList
private long
readBytes
private long
reads
private long
timeStamp
private long
transferTime
private long
writeBytes
private long
writes
-
Constructor Summary
Constructors Modifier Constructor Description private
MacHWDiskStore(java.lang.String name, java.lang.String model, java.lang.String serial, long size, com.sun.jna.platform.mac.DiskArbitration.DASessionRef session, java.util.Map<java.lang.String,java.lang.String> mountPointMap, java.util.Map<MacHWDiskStore.CFKey,com.sun.jna.platform.mac.CoreFoundation.CFStringRef> cfKeyMap)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description long
getCurrentQueueLength()
The length of the disk queue (#I/O's in progress).static java.util.List<HWDiskStore>
getDisks()
Gets the disks on this machinejava.util.List<HWPartition>
getPartitions()
The partitions on this disk.long
getReadBytes()
The number of bytes read from the disklong
getReads()
The number of reads from the disklong
getTimeStamp()
The time this disk's statistics were updated.long
getTransferTime()
The time spent reading or writing, in milliseconds.long
getWriteBytes()
The number of bytes written to the disklong
getWrites()
The number of writes to the diskprivate static java.util.Map<MacHWDiskStore.CFKey,com.sun.jna.platform.mac.CoreFoundation.CFStringRef>
mapCFKeys()
Temporarily cache pointers to keys.boolean
updateAttributes()
Make a best effort to update all the statistics about the drive without needing to recreate the drive list.private boolean
updateDiskStats(com.sun.jna.platform.mac.DiskArbitration.DASessionRef session, java.util.Map<java.lang.String,java.lang.String> mountPointMap, java.util.Map<MacHWDiskStore.CFKey,com.sun.jna.platform.mac.CoreFoundation.CFStringRef> cfKeyMap)
-
-
-
Field Detail
-
CF
private static final com.sun.jna.platform.mac.CoreFoundation CF
-
DA
private static final com.sun.jna.platform.mac.DiskArbitration DA
-
LOG
private static final org.slf4j.Logger LOG
-
reads
private long reads
-
readBytes
private long readBytes
-
writes
private long writes
-
writeBytes
private long writeBytes
-
currentQueueLength
private long currentQueueLength
-
transferTime
private long transferTime
-
timeStamp
private long timeStamp
-
partitionList
private java.util.List<HWPartition> partitionList
-
-
Constructor Detail
-
MacHWDiskStore
private MacHWDiskStore(java.lang.String name, java.lang.String model, java.lang.String serial, long size, com.sun.jna.platform.mac.DiskArbitration.DASessionRef session, java.util.Map<java.lang.String,java.lang.String> mountPointMap, java.util.Map<MacHWDiskStore.CFKey,com.sun.jna.platform.mac.CoreFoundation.CFStringRef> cfKeyMap)
-
-
Method Detail
-
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 java.util.List<HWPartition> getPartitions()
Description copied from interface:HWDiskStore
The partitions on this disk.- Returns:
- an
UnmodifiableList
of the partitions on this drive.
-
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
-
updateDiskStats
private boolean updateDiskStats(com.sun.jna.platform.mac.DiskArbitration.DASessionRef session, java.util.Map<java.lang.String,java.lang.String> mountPointMap, java.util.Map<MacHWDiskStore.CFKey,com.sun.jna.platform.mac.CoreFoundation.CFStringRef> cfKeyMap)
-
getDisks
public static java.util.List<HWDiskStore> getDisks()
Gets the disks on this machine- Returns:
- a list of
HWDiskStore
objects representing the disks
-
mapCFKeys
private static java.util.Map<MacHWDiskStore.CFKey,com.sun.jna.platform.mac.CoreFoundation.CFStringRef> mapCFKeys()
Temporarily cache pointers to keys. The values from this map must be released after use.}- Returns:
- A map of keys in the
MacHWDiskStore.CFKey
enum to correspondingCoreFoundation.CFStringRef
.
-
-