Top Description Fields Constructors Methods
org.wildfly.common.cpu

public Class ProcessorInfo

extends Object
Class Inheritance
Imports
java.io.BufferedReader, .FileInputStream, .IOException, .InputStreamReader, java.nio.charset.Charset, java.security.AccessController, .PrivilegedAction, java.util.Locale

Provides general information about the processors on this host.
Author
Jason T. Greene

Field Summary

Modifier and TypeField and Description
private static final Charset
private static final byte[]
private static final String

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static int

Returns:

the available processors on this system.
availableProcessors
()

Returns the number of processors available to this process.

private static int
private static boolean
private static int
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ASCIIback to summary
private static final Charset ASCII
BITSback to summary
private static final byte[] BITS
CPUS_ALLOWEDback to summary
private static final String CPUS_ALLOWED

Constructor Detail

ProcessorInfoback to summary
private ProcessorInfo()

Method Detail

availableProcessorsback to summary
public static int availableProcessors()

Returns the number of processors available to this process. 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. Calls should be limited accordingly.
Note tha on Linux, both SMT units (Hyper-Threading) and CPU cores are counted as a processor.

Returns:int

the available processors on this system.

determineProcessorsback to summary
private static int determineProcessors()
isLinuxback to summary
private static boolean isLinux()
readCPUMaskback to summary
private static int readCPUMask() throws IOException