Top Description Fields Constructors Methods
io.vertx.core.impl.cpu

public Class CpuCoreSensor

extends Object
Class Inheritance
Imports
io.vertx.core.impl.launcher.commands.ExecUtils, java.io.*, java.nio.charset.Charset, .StandardCharsets, java.security.AccessController, .PrivilegedAction

Utility class providing the number of CPU cores available. On Linux, to handle CGroups, it reads and parses the /proc/self/status file.

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.

Authors
Jason T. Greene, Clement Escoffier

Field Summary

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

Constructor Summary

AccessConstructor and Description
public

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
protected static int
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

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

Constructor Detail

CpuCoreSensorback to summary
public CpuCoreSensor()

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.

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.

Returns:int

the available processors on this system.

determineProcessorsback to summary
private static int determineProcessors()
readCPUMaskback to summary
protected static int readCPUMask(File file) throws IOException