Package oshi.driver.windows.registry
Class HkeyPerformanceDataUtil
- java.lang.Object
-
- oshi.driver.windows.registry.HkeyPerformanceDataUtil
-
@ThreadSafe public final class HkeyPerformanceDataUtil extends java.lang.Object
Utility to read HKEY_PERFORMANCE_DATA information.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
COUNTER
private static java.util.Map<java.lang.String,java.lang.Integer>
COUNTER_INDEX_MAP
private static java.lang.String
HKEY_PERFORMANCE_TEXT
private static org.slf4j.Logger
LOG
private static int
maxPerfBufferSize
-
Constructor Summary
Constructors Modifier Constructor Description private
HkeyPerformanceDataUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static <T extends java.lang.Enum<T> & PerfCounterWildcardQuery.PdhCounterWildcardProperty>
Pair<java.lang.Integer,java.util.EnumMap<T,java.lang.Integer>>getCounterIndices(java.lang.String objectName, java.lang.Class<T> counterEnum)
Looks up the counter index values for the given counter object and the enum of counter names.private static java.util.Map<java.lang.String,java.lang.Integer>
mapCounterIndicesFromRegistry()
private static com.sun.jna.Memory
readPerfDataBuffer(java.lang.String objectName)
Read the performance data for a counter object from the registry.static <T extends java.lang.Enum<T> & PerfCounterWildcardQuery.PdhCounterWildcardProperty>
Triplet<java.util.List<java.util.Map<T,java.lang.Object>>,java.lang.Long,java.lang.Long>readPerfDataFromRegistry(java.lang.String objectName, java.lang.Class<T> counterEnum)
Reads and parses a block of performance data from the registry.
-
-
-
Field Detail
-
LOG
private static final org.slf4j.Logger LOG
-
HKEY_PERFORMANCE_TEXT
private static final java.lang.String HKEY_PERFORMANCE_TEXT
- See Also:
- Constant Field Values
-
COUNTER
private static final java.lang.String COUNTER
- See Also:
- Constant Field Values
-
COUNTER_INDEX_MAP
private static final java.util.Map<java.lang.String,java.lang.Integer> COUNTER_INDEX_MAP
-
maxPerfBufferSize
private static int maxPerfBufferSize
-
-
Method Detail
-
readPerfDataFromRegistry
public static <T extends java.lang.Enum<T> & PerfCounterWildcardQuery.PdhCounterWildcardProperty> Triplet<java.util.List<java.util.Map<T,java.lang.Object>>,java.lang.Long,java.lang.Long> readPerfDataFromRegistry(java.lang.String objectName, java.lang.Class<T> counterEnum)
Reads and parses a block of performance data from the registry.- Type Parameters:
T
- PDH Counters use an Enum to identify the fields to query in either the counter or WMI backup, and use the enum values as keys to retrieve the results.- Parameters:
objectName
- The counter object for which to fetch datacounterEnum
- Which counters to return data for- Returns:
- A triplet containing the results. The first element maps the input enum to the counter values where the
first enum will contain the instance name as a
String
, and the remaining values will either beLong
,Integer
, ornull
depending on whether the specified enum counter was present and the size of the counter value. The second element is a timestamp in 100nSec increments (Windows 1601 Epoch) while the third element is a timestamp in milliseconds since the 1970 Epoch.
-
getCounterIndices
private static <T extends java.lang.Enum<T> & PerfCounterWildcardQuery.PdhCounterWildcardProperty> Pair<java.lang.Integer,java.util.EnumMap<T,java.lang.Integer>> getCounterIndices(java.lang.String objectName, java.lang.Class<T> counterEnum)
Looks up the counter index values for the given counter object and the enum of counter names.- Type Parameters:
T
- An enum containing the counters, whose class is passed ascounterEnum
- Parameters:
objectName
- The counter object to look up the index forcounterEnum
- TheEnum
containing counters to look up the indices for. The first Enum value will be ignored.- Returns:
- A
Pair
containing the index of the counter object as the first element, and anEnumMap
mapping counter enum values to their index as the second element, if the lookup is successful; null otherwise.
-
readPerfDataBuffer
private static com.sun.jna.Memory readPerfDataBuffer(java.lang.String objectName)
Read the performance data for a counter object from the registry.- Parameters:
objectName
- The counter object for which to fetch data. It is the user's responsibility to ensure this key exists inCOUNTER_INDEX_MAP
.- Returns:
- A buffer containing the data if successful, null otherwise.
-
mapCounterIndicesFromRegistry
private static java.util.Map<java.lang.String,java.lang.Integer> mapCounterIndicesFromRegistry()
-
-