public abstract class AbstractCentralProcessor extends Object implements CentralProcessor
CentralProcessor.TickType| Modifier and Type | Field and Description |
|---|---|
protected int |
logicalProcessorCount |
protected int |
physicalPackageCount |
protected int |
physicalProcessorCount |
| Constructor and Description |
|---|
AbstractCentralProcessor()
Create a Processor
|
| Modifier and Type | Method and Description |
|---|---|
protected abstract void |
calculateProcessorCounts()
Updates logical and physical processor counts
|
protected String |
createProcessorID(String stepping,
String model,
String family,
String[] flags)
Creates a Processor ID by encoding the stepping, model, family, and
feature flags.
|
String |
getFamily() |
String |
getIdentifier()
Identifier, eg.
|
int |
getLogicalProcessorCount()
Get the number of logical CPUs available for processing.
|
String |
getModel() |
String |
getName()
Name, eg.
|
int |
getPhysicalPackageCount()
Get the number of packages/sockets in the system.
|
int |
getPhysicalProcessorCount()
Get the number of physical CPUs/cores available for processing.
|
double[] |
getProcessorCpuLoadBetweenTicks()
Returns the "recent cpu usage" for all logical processors by counting
ticks for the processors from
CentralProcessor.getProcessorCpuLoadTicks() between
successive calls of this method, with a minimum interval slightly less
than 1 second. |
String |
getProcessorID()
Gets the Processor ID.
|
String |
getStepping() |
double |
getSystemCpuLoad()
Returns the "recent cpu usage" for the whole system from
OperatingSystemMXBean.getSystemCpuLoad() if a
user is running the Oracle JVM. |
double |
getSystemCpuLoadBetweenTicks()
Returns the "recent cpu usage" for the whole system by counting ticks
from
CentralProcessor.getSystemCpuLoadTicks() between successive calls of this
method, with a minimum interval slightly less than 1 second. |
double |
getSystemLoadAverage()
Returns the system load average for the last minute.
|
String |
getVendor()
Processor vendor.
|
long |
getVendorFreq()
Vendor frequency (in Hz), eg.
|
protected void |
initTicks()
Initializes tick arrays
|
boolean |
isCpu64bit()
Is CPU 64bit?
|
void |
setCpu64(boolean value)
Set flag is cpu is 64bit.
|
void |
setFamily(String family) |
void |
setIdentifier(String identifier)
Set processor identifier.
|
void |
setModel(String model) |
void |
setName(String name)
Set processor name.
|
void |
setProcessorID(String processorID)
Set processor ID
|
void |
setStepping(String stepping) |
void |
setVendor(String vendor)
Set processor vendor.
|
void |
setVendorFreq(long freq)
Set processor vendor frequency (in Hz).
|
String |
toString() |
protected void |
updateProcessorTicks()
Updates per-processor tick information.
|
protected void |
updateSystemTicks()
Updates system tick information.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetContextSwitches, getInterrupts, getProcessorCpuLoadTicks, getSystemCpuLoadTicks, getSystemLoadAverage, getSystemSerialNumber, getSystemUptimeprotected int logicalProcessorCount
protected int physicalProcessorCount
protected int physicalPackageCount
protected void initTicks()
protected abstract void calculateProcessorCounts()
public String getVendor()
getVendor in interface CentralProcessorpublic void setVendor(String vendor)
setVendor in interface CentralProcessorvendor - Vendor.public String getName()
getName in interface CentralProcessorpublic void setName(String name)
setName in interface CentralProcessorname - Name.public String getProcessorID()
CentralProcessor.getIdentifier() . The remaining four
bytes are the contents of the EDX register, containing feature flags.
NOTE: The order of returned bytes is platform and software dependent.
Values may be in either Big Endian or Little Endian order.getProcessorID in interface CentralProcessorpublic void setProcessorID(String processorID)
setProcessorID in interface CentralProcessorprocessorID - The processor IDpublic long getVendorFreq()
getVendorFreq in interface CentralProcessorpublic void setVendorFreq(long freq)
setVendorFreq in interface CentralProcessorfreq - Frequency.public String getIdentifier()
getIdentifier in interface CentralProcessorpublic void setIdentifier(String identifier)
setIdentifier in interface CentralProcessoridentifier - Identifier.public boolean isCpu64bit()
isCpu64bit in interface CentralProcessorpublic void setCpu64(boolean value)
setCpu64 in interface CentralProcessorvalue - True if cpu is 64.public String getStepping()
getStepping in interface CentralProcessorpublic void setStepping(String stepping)
setStepping in interface CentralProcessorstepping - the stepping to setpublic String getModel()
getModel in interface CentralProcessorpublic void setModel(String model)
setModel in interface CentralProcessormodel - the model to setpublic String getFamily()
getFamily in interface CentralProcessorpublic void setFamily(String family)
setFamily in interface CentralProcessorfamily - the family to setpublic double getSystemCpuLoadBetweenTicks()
CentralProcessor.getSystemCpuLoadTicks() between successive calls of this
method, with a minimum interval slightly less than 1 second. If less than
one second has elapsed since the last call of this method, it will return
a calculation based on the tick counts and times of the previous two
calls. If at least a second has elapsed, it will return the average CPU
load for the interval and update the "last called" times. This method is
intended to be used for periodic polling at intervals of 1 second or
longer.getSystemCpuLoadBetweenTicks in interface CentralProcessorprotected void updateSystemTicks()
public double getSystemCpuLoad()
OperatingSystemMXBean.getSystemCpuLoad() if a
user is running the Oracle JVM. This value is a double in the [0.0,1.0]
interval. A value of 0.0 means that all CPUs were idle during the recent
period of time observed, while a value of 1.0 means that all CPUs were
actively running 100% of the time during the recent period being
observed. All values between 0.0 and 1.0 are possible depending of the
activities going on in the system. If the system recent cpu usage is not
available, the method returns a negative value. Calling this method
immediately upon instantiating the CentralProcessor may give
unreliable results. If a user is not running the Oracle JVM, this method
will default to the behavior and return value of
CentralProcessor.getSystemCpuLoadBetweenTicks().getSystemCpuLoad in interface CentralProcessorpublic double getSystemLoadAverage()
CentralProcessor.getSystemLoadAverage(int) with an
argument of 1 and returning the first value, and is retained for
compatibility.getSystemLoadAverage in interface CentralProcessorpublic double[] getProcessorCpuLoadBetweenTicks()
CentralProcessor.getProcessorCpuLoadTicks() between
successive calls of this method, with a minimum interval slightly less
than 1 second. If less than one second has elapsed since the last call of
this method, it will return a calculation based on the tick counts and
times of the previous two calls. If at least a second has elapsed, it
will return the average CPU load for the interval and update the "last
called" times. This method is intended to be used for periodic polling
(iterating over all processors) at intervals of 1 second or longer.getProcessorCpuLoadBetweenTicks in interface CentralProcessorprotected void updateProcessorTicks()
public int getLogicalProcessorCount()
getLogicalProcessorCount in interface CentralProcessorpublic int getPhysicalProcessorCount()
getPhysicalProcessorCount in interface CentralProcessorpublic int getPhysicalPackageCount()
getPhysicalPackageCount in interface CentralProcessorprotected String createProcessorID(String stepping, String model, String family, String[] flags)
stepping - The CPU steppingmodel - The CPU modelfamily - The CPU familyflags - A space-delimited list of CPU feature flagsCopyright © 2010–2018 oshi. All rights reserved.