public class CpuCoreSensor extends Object
This class derives from https://github.com/wildfly/wildfly-common/blob/master/src/main/java/org/wildfly/common/cpu/ProcessorInfo.java licensed under the Apache Software License 2.0.
| Constructor and Description |
|---|
CpuCoreSensor() |
| Modifier and Type | Method and Description |
|---|---|
static int |
availableProcessors()
Returns the number of processors available to this process.
|
protected static int |
readCPUMask(File file) |
public static int availableProcessors()
On most operating systems this method simply delegates to Runtime.availableProcessors(). However, on
Linux, this strategy is insufficient, since the JVM does not take into consideration the process' CPU set affinity
which is employed by cgroups and numactl. Therefore this method will analyze the Linux proc filesystem
to make the determination.
Since the CPU affinity of a process can be change at any time, this method does not cache the result.
Note that on Linux, both SMT units (Hyper-Threading) and CPU cores are counted as a processor.
This method is used to configure the default number of event loops. This settings can be overridden by the user.
protected static int readCPUMask(File file) throws IOException
IOExceptionCopyright © 2020. All rights reserved.