Top Fields Constructors Methods
jdk.internal.platform.cgroupv2

public Class CgroupV2Subsystem

extends Object
implements CgroupSubsystem
Class Inheritance
All Implemented Interfaces
jdk.internal.platform.CgroupSubsystem, jdk.internal.platform.Metrics
Imports
java.io.IOException, .UncheckedIOException, java.nio.file.Paths, java.util.concurrent.TimeUnit, java.util.function.Function, java.util.stream.Collectors, jdk.internal.platform.CgroupInfo, .CgroupSubsystem, .CgroupSubsystemController, .CgroupUtil

Field Summary

Modifier and TypeField and Description
private static final Object
private static volatile CgroupV2Subsystem
private static final int[]
private static final long[]
private static final long
private static final int
private static final String
private final CgroupSubsystemController

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public long
getBlkIOServiceCount()

Implements jdk.internal.platform.Metrics.getBlkIOServiceCount.

Returns the number of block I/O requests to the disk that have been issued by the Isolation Group.
public long
getBlkIOServiced()

Implements jdk.internal.platform.Metrics.getBlkIOServiced.

Returns the number of block I/O bytes that have been transferred to/from the disk by the Isolation Group.
public long
getCpuNumPeriods()

Implements jdk.internal.platform.Metrics.getCpuNumPeriods.

Returns the number of time-slice periods that have elapsed if a CPU quota has been setup for the Isolation Group
public long
getCpuNumThrottled()

Implements jdk.internal.platform.Metrics.getCpuNumThrottled.

Returns the number of time-slice periods that the group has been throttled or limited due to the group exceeding its quota if a CPU quota has been setup for the Isolation Group.
public long
getCpuPeriod()

Implements jdk.internal.platform.Metrics.getCpuPeriod.

Returns the length of the scheduling period, in microseconds, for processes within the Isolation Group.
public long
getCpuQuota()

Implements jdk.internal.platform.Metrics.getCpuQuota.

Returns the total available run-time allowed, in microseconds, during each scheduling period for all tasks in the Isolation Group.
private int[]
getCpuSet(String cpuSetVal)

public int[]
getCpuSetCpus()

Implements jdk.internal.platform.Metrics.getCpuSetCpus.

Returns the CPUS that are available for execution of processes in the current Isolation Group.
public int[]
getCpuSetMems()

Implements jdk.internal.platform.Metrics.getCpuSetMems.

Returns the memory nodes that are available for use by processes in the current Isolation Group.
public long
getCpuShares()

Implements jdk.internal.platform.Metrics.getCpuShares.

Returns the relative weighting of processes with the Isolation Group used for prioritizing the scheduling of processes across all Isolation Groups running on a host.
public long
getCpuSystemUsage()

Implements jdk.internal.platform.Metrics.getCpuSystemUsage.

Returns the aggregate system time, in nanoseconds, consumed by all tasks in the Isolation Group.
public long
getCpuThrottledTime()

Implements jdk.internal.platform.Metrics.getCpuThrottledTime.

Returns the total time duration, in nanoseconds, that the group has been throttled or limited due to the group exceeding its quota if a CPU quota has been setup for the Isolation Group.
public long
getCpuUsage()

Implements jdk.internal.platform.Metrics.getCpuUsage.

Returns the aggregate time, in nanoseconds, consumed by all tasks in the Isolation Group.
public long
getCpuUserUsage()

Implements jdk.internal.platform.Metrics.getCpuUserUsage.

Returns the aggregate user time, in nanoseconds, consumed by all tasks in the Isolation Group.
public long
getEffectiveCpuCount()

Implements jdk.internal.platform.Metrics.getEffectiveCpuCount.

Returns the number of effective processors that this Isolation group has available to it.
public int[]
getEffectiveCpuSetCpus()

Implements jdk.internal.platform.Metrics.getEffectiveCpuSetCpus.

Returns the CPUS that are available and online for execution of processes within the current Isolation Group.
public int[]
getEffectiveCpuSetMems()

Implements jdk.internal.platform.Metrics.getEffectiveCpuSetMems.

Returns the memory nodes that are available and online for use by processes within the current Isolation Group.
private long
getFromCpuMax(int tokenIdx)

public static CgroupSubsystem

Returns:

A singleton CgroupSubsystem instance, never null.
getInstance
(CgroupInfo anyController)

Get the singleton instance of a cgroups v2 subsystem.

private long
getLongVal(String file, long defaultValue)

private long
public long
getMemoryAndSwapLimit()

Implements jdk.internal.platform.Metrics.getMemoryAndSwapLimit.

Note that for cgroups v2 the actual limits set for swap and memory live in two different files, memory.swap.max and memory.max respectively.
public long
getMemoryAndSwapUsage()

Implements jdk.internal.platform.Metrics.getMemoryAndSwapUsage.

Note that for cgroups v2 the actual values set for swap usage and memory usage live in two different files, memory.current and memory.swap.current respectively.
public long
getMemoryFailCount()

Implements jdk.internal.platform.Metrics.getMemoryFailCount.

Returns the number of times that user memory requests in the Isolation Group have exceeded the memory limit.
public long
getMemoryLimit()

Implements jdk.internal.platform.Metrics.getMemoryLimit.

Returns the maximum amount of physical memory, in bytes, that can be allocated in the Isolation Group.
public long
getMemorySoftLimit()

Implements jdk.internal.platform.Metrics.getMemorySoftLimit.

Returns the hint to the operating system that allows groups to specify the minimum amount of physical memory that they need to achieve reasonable performance in low memory systems.
public long
getMemoryUsage()

Implements jdk.internal.platform.Metrics.getMemoryUsage.

Returns the amount of physical memory, in bytes, that is currently allocated in the current Isolation Group.
public long[]
getPerCpuUsage()

Implements jdk.internal.platform.Metrics.getPerCpuUsage.

Returns the aggregate time, in nanoseconds, consumed by all tasks in the Isolation Group, separated by CPU.
public long
getPidsCurrent()

Implements jdk.internal.platform.Metrics.getPidsCurrent.

Returns the current number of tasks in the Isolation Group.
public long
getPidsMax()

Implements jdk.internal.platform.Metrics.getPidsMax.

Returns the maximum number of tasks that may be created in the Isolation Group.
public String
getProvider()

Implements jdk.internal.platform.Metrics.getProvider.

Returns the interface responsible for providing the platform metrics.
private static String[]
private static String[]
public long
getTcpMemoryUsage()

Implements jdk.internal.platform.Metrics.getTcpMemoryUsage.

Returns the amount of networking physical memory, in bytes, that is currently allocated in the current Isolation Group.
private static Long
ioStatLineToLong(String line, String[] matchNames)

public static Long
public static Long
private static long
private long
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

EMPTY_STRback to summary
private static final Object EMPTY_STR
INSTANCEback to summary
private static volatile CgroupV2Subsystem INSTANCE
INT_ARRAY_UNAVAILABLEback to summary
private static final int[] INT_ARRAY_UNAVAILABLE
LONG_ARRAY_NOT_SUPPORTEDback to summary
private static final long[] LONG_ARRAY_NOT_SUPPORTED
NO_SWAPback to summary
private static final long NO_SWAP
PER_CPU_SHARESback to summary
private static final int PER_CPU_SHARES
PROVIDER_NAMEback to summary
private static final String PROVIDER_NAME
unifiedback to summary
private final CgroupSubsystemController unified

Constructor Detail

CgroupV2Subsystemback to summary
private CgroupV2Subsystem(CgroupSubsystemController unified)

Method Detail

getBlkIOServiceCountback to summary
public long getBlkIOServiceCount()

Implements jdk.internal.platform.Metrics.getBlkIOServiceCount.

Doc from jdk.internal.platform.Metrics.getBlkIOServiceCount.

Returns the number of block I/O requests to the disk that have been issued by the Isolation Group.

Returns:long

The count of requests or -1 if the metric is not available. Returns -2 if this metric is not supported.

Annotations
@Override
getBlkIOServicedback to summary
public long getBlkIOServiced()

Implements jdk.internal.platform.Metrics.getBlkIOServiced.

Doc from jdk.internal.platform.Metrics.getBlkIOServiced.

Returns the number of block I/O bytes that have been transferred to/from the disk by the Isolation Group.

Returns:long

The number of bytes transferred or -1 if the metric is not available. Returns -2 if this metric is not supported.

Annotations
@Override
getCpuNumPeriodsback to summary
public long getCpuNumPeriods()

Implements jdk.internal.platform.Metrics.getCpuNumPeriods.

Doc from jdk.internal.platform.Metrics.getCpuNumPeriods.

Returns the number of time-slice periods that have elapsed if a CPU quota has been setup for the Isolation Group

Returns:long

count of elapsed periods, -1 if the metric is not available or -2 if the metric is not supported.

Annotations
@Override
getCpuNumThrottledback to summary
public long getCpuNumThrottled()

Implements jdk.internal.platform.Metrics.getCpuNumThrottled.

Doc from jdk.internal.platform.Metrics.getCpuNumThrottled.

Returns the number of time-slice periods that the group has been throttled or limited due to the group exceeding its quota if a CPU quota has been setup for the Isolation Group.

Returns:long

count of throttled periods, -1 if the metric is not available or -2 if it is not supported.

Annotations
@Override
getCpuPeriodback to summary
public long getCpuPeriod()

Implements jdk.internal.platform.Metrics.getCpuPeriod.

Doc from jdk.internal.platform.Metrics.getCpuPeriod.

Returns the length of the scheduling period, in microseconds, for processes within the Isolation Group.

Returns:long

time in microseconds, -1 if the metric is not available or -2 if the metric is not supported.

Annotations
@Override
getCpuQuotaback to summary
public long getCpuQuota()

Implements jdk.internal.platform.Metrics.getCpuQuota.

Doc from jdk.internal.platform.Metrics.getCpuQuota.

Returns the total available run-time allowed, in microseconds, during each scheduling period for all tasks in the Isolation Group.

Returns:long

time in microseconds, -1 if the quota is unlimited or -2 if not supported.

Annotations
@Override
getCpuSetback to summary
private int[] getCpuSet(String cpuSetVal)
getCpuSetCpusback to summary
public int[] getCpuSetCpus()

Implements jdk.internal.platform.Metrics.getCpuSetCpus.

Doc from jdk.internal.platform.Metrics.getCpuSetCpus.

Returns the CPUS that are available for execution of processes in the current Isolation Group. The size of the array is equal to the total number of CPUs and the elements in the array are the physical CPU numbers that are available. Some of the CPUs returned may be offline. To get the current online CPUs, use getEffectiveCpuSetCpus().

Returns:int[]

An array of available CPUs. Returns null if the metric is not available or the metric is not supported.

Annotations
@Override
getCpuSetMemsback to summary
public int[] getCpuSetMems()

Implements jdk.internal.platform.Metrics.getCpuSetMems.

Doc from jdk.internal.platform.Metrics.getCpuSetMems.

Returns the memory nodes that are available for use by processes in the current Isolation Group. The size of the array is equal to the total number of nodes and the elements in the array are the physical node numbers that are available. Some of the nodes returned may be offline. To get the current online memory nodes, use getEffectiveCpuSetMems().

Returns:int[]

An array of available memory nodes or null if the metric is not available or is not supported.

Annotations
@Override
getCpuSharesback to summary
public long getCpuShares()

Implements jdk.internal.platform.Metrics.getCpuShares.

Doc from jdk.internal.platform.Metrics.getCpuShares.

Returns the relative weighting of processes with the Isolation Group used for prioritizing the scheduling of processes across all Isolation Groups running on a host.

Returns:long

shares value, -1 if the metric is not available or -2 if cpu shares are not supported.

Annotations
@Override
getCpuSystemUsageback to summary
public long getCpuSystemUsage()

Implements jdk.internal.platform.Metrics.getCpuSystemUsage.

Doc from jdk.internal.platform.Metrics.getCpuSystemUsage.

Returns the aggregate system time, in nanoseconds, consumed by all tasks in the Isolation Group.

Returns:long

System time in nanoseconds, -1 if the metric is not available or -2 if the metric is not supported.

Annotations
@Override
getCpuThrottledTimeback to summary
public long getCpuThrottledTime()

Implements jdk.internal.platform.Metrics.getCpuThrottledTime.

Doc from jdk.internal.platform.Metrics.getCpuThrottledTime.

Returns the total time duration, in nanoseconds, that the group has been throttled or limited due to the group exceeding its quota if a CPU quota has been setup for the Isolation Group.

Returns:long

Throttled time in nanoseconds, -1 if the metric is not available or -2 if it is not supported.

Annotations
@Override
getCpuUsageback to summary
public long getCpuUsage()

Implements jdk.internal.platform.Metrics.getCpuUsage.

Doc from jdk.internal.platform.Metrics.getCpuUsage.

Returns the aggregate time, in nanoseconds, consumed by all tasks in the Isolation Group.

Returns:long

Time in nanoseconds, -1 if unknown or -2 if the metric is not supported.

Annotations
@Override
getCpuUserUsageback to summary
public long getCpuUserUsage()

Implements jdk.internal.platform.Metrics.getCpuUserUsage.

Doc from jdk.internal.platform.Metrics.getCpuUserUsage.

Returns the aggregate user time, in nanoseconds, consumed by all tasks in the Isolation Group.

Returns:long

User time in nanoseconds, -1 if the metric is not available or -2 if the metric is not supported.

Annotations
@Override
getEffectiveCpuCountback to summary
public long getEffectiveCpuCount()

Implements jdk.internal.platform.Metrics.getEffectiveCpuCount.

Doc from jdk.internal.platform.Metrics.getEffectiveCpuCount.

Returns the number of effective processors that this Isolation group has available to it. This effective processor count is computed based on the number of dedicated CPUs, CPU shares and CPU quotas in effect for this isolation group. This method returns the same value as java.lang.Runtime#availableProcessors().

Returns:long

The number of effective CPUs.

Annotations
@Override
getEffectiveCpuSetCpusback to summary
public int[] getEffectiveCpuSetCpus()

Implements jdk.internal.platform.Metrics.getEffectiveCpuSetCpus.

Doc from jdk.internal.platform.Metrics.getEffectiveCpuSetCpus.

Returns the CPUS that are available and online for execution of processes within the current Isolation Group. The size of the array is equal to the total number of CPUs and the elements in the array are the physical CPU numbers.

Returns:int[]

An array of available and online CPUs. Returns null if the metric is not available or the metric is not supported.

Annotations
@Override
getEffectiveCpuSetMemsback to summary
public int[] getEffectiveCpuSetMems()

Implements jdk.internal.platform.Metrics.getEffectiveCpuSetMems.

Doc from jdk.internal.platform.Metrics.getEffectiveCpuSetMems.

Returns the memory nodes that are available and online for use by processes within the current Isolation Group. The size of the array is equal to the total number of nodes and the elements in the array are the physical node numbers.

Returns:int[]

An array of available and online nodes or null if the metric is not available or is not supported.

Annotations
@Override
getFromCpuMaxback to summary
private long getFromCpuMax(int tokenIdx)
getInstanceback to summary
public static CgroupSubsystem getInstance(CgroupInfo anyController)

Get the singleton instance of a cgroups v2 subsystem. On initialization, a new object from the given cgroup information 'anyController' is being created. Note that the cgroup information has been parsed from cgroup interface files ahead of time. See CgroupSubsystemFactory.determineType() for the cgroup interface files parsing logic.

Returns:CgroupSubsystem

A singleton CgroupSubsystem instance, never null.

getLongValback to summary
private long getLongVal(String file, long defaultValue)
getLongValback to summary
private long getLongVal(String file)
getMemoryAndSwapLimitback to summary
public long getMemoryAndSwapLimit()

Implements jdk.internal.platform.Metrics.getMemoryAndSwapLimit.

Note that for cgroups v2 the actual limits set for swap and memory live in two different files, memory.swap.max and memory.max respectively. In order to properly report a cgroup v1 like compound value we need to sum the two values. Setting a swap limit without also setting a memory limit is not allowed.

Returns:long

Doc from jdk.internal.platform.Metrics.getMemoryAndSwapLimit.

The maximum amount of memory in bytes or -1 if there is no limit set or -2 if this metric is not supported.

Annotations
@Override
getMemoryAndSwapUsageback to summary
public long getMemoryAndSwapUsage()

Implements jdk.internal.platform.Metrics.getMemoryAndSwapUsage.

Note that for cgroups v2 the actual values set for swap usage and memory usage live in two different files, memory.current and memory.swap.current respectively. In order to properly report a cgroup v1 like compound value we need to sum the two values. Setting a swap limit without also setting a memory limit is not allowed.

Returns:long

Doc from jdk.internal.platform.Metrics.getMemoryAndSwapUsage.

The amount of memory in bytes allocated or -1 if the metric is not available. Returns -2 if this metric is not supported.

Annotations
@Override
getMemoryFailCountback to summary
public long getMemoryFailCount()

Implements jdk.internal.platform.Metrics.getMemoryFailCount.

Doc from jdk.internal.platform.Metrics.getMemoryFailCount.

Returns the number of times that user memory requests in the Isolation Group have exceeded the memory limit.

Returns:long

The number of exceeded requests or -1 if the metric is not available. Returns -2 if the metric is not supported.

Annotations
@Override
getMemoryLimitback to summary
public long getMemoryLimit()

Implements jdk.internal.platform.Metrics.getMemoryLimit.

Doc from jdk.internal.platform.Metrics.getMemoryLimit.

Returns the maximum amount of physical memory, in bytes, that can be allocated in the Isolation Group.

Returns:long

The maximum amount of memory in bytes or -1 if there is no limit or -2 if this metric is not supported.

Annotations
@Override
getMemorySoftLimitback to summary
public long getMemorySoftLimit()

Implements jdk.internal.platform.Metrics.getMemorySoftLimit.

Doc from jdk.internal.platform.Metrics.getMemorySoftLimit.

Returns the hint to the operating system that allows groups to specify the minimum amount of physical memory that they need to achieve reasonable performance in low memory systems. This allows host systems to provide greater sharing of memory.

Returns:long

The minimum amount of physical memory, in bytes, that the operating system will try to maintain under low memory conditions. If this metric is not available, -1 will be returned. Returns -2 if the metric is not supported.

Annotations
@Override
getMemoryUsageback to summary
public long getMemoryUsage()

Implements jdk.internal.platform.Metrics.getMemoryUsage.

Doc from jdk.internal.platform.Metrics.getMemoryUsage.

Returns the amount of physical memory, in bytes, that is currently allocated in the current Isolation Group.

Returns:long

The amount of memory in bytes allocated or -1 if the metric is not available or -2 if the metric is not supported.

Annotations
@Override
getPerCpuUsageback to summary
public long[] getPerCpuUsage()

Implements jdk.internal.platform.Metrics.getPerCpuUsage.

Doc from jdk.internal.platform.Metrics.getPerCpuUsage.

Returns the aggregate time, in nanoseconds, consumed by all tasks in the Isolation Group, separated by CPU. If the current process is running within a container, the reported time will only be valid for processes running within the same container. The values are returned in an array, one entry for each physical processor on the system. Time values for processors unavailable to this Group are undefined.

Returns:long[]

long array of time values. The size of the array is equal to the total number of physical processors in the system. If this metric is not supported or not available, null will be returned.

Annotations
@Override
getPidsCurrentback to summary
public long getPidsCurrent()

Implements jdk.internal.platform.Metrics.getPidsCurrent.

Doc from jdk.internal.platform.Metrics.getPidsCurrent.

Returns the current number of tasks in the Isolation Group.

Returns:long

The current number of tasks or -2 if not supported

Annotations
@Override
getPidsMaxback to summary
public long getPidsMax()

Implements jdk.internal.platform.Metrics.getPidsMax.

Doc from jdk.internal.platform.Metrics.getPidsMax.

Returns the maximum number of tasks that may be created in the Isolation Group.

Returns:long

The maximum number of tasks, -1 if the quota is unlimited or -2 if not supported.

Annotations
@Override
getProviderback to summary
public String getProvider()

Implements jdk.internal.platform.Metrics.getProvider.

Doc from jdk.internal.platform.Metrics.getProvider.

Returns the interface responsible for providing the platform metrics.

Returns:String

The name of the provider.

Annotations
@Override
getRWBytesIOMatchTokenNamesback to summary
private static String[] getRWBytesIOMatchTokenNames()
getRWIOMatchTokenNamesback to summary
private static String[] getRWIOMatchTokenNames()
getTcpMemoryUsageback to summary
public long getTcpMemoryUsage()

Implements jdk.internal.platform.Metrics.getTcpMemoryUsage.

Doc from jdk.internal.platform.Metrics.getTcpMemoryUsage.

Returns the amount of networking physical memory, in bytes, that is currently allocated in the current Isolation Group.

Returns:long

The amount of memory in bytes allocated or -1 if the metric is not available. Returns -2 if this metric is not supported.

Annotations
@Override
ioStatLineToLongback to summary
private static Long ioStatLineToLong(String line, String[] matchNames)
lineToRandWIOsback to summary
public static Long lineToRandWIOs(String line)
lineToRBytesAndWBytesIOback to summary
public static Long lineToRBytesAndWBytesIO(String line)
longOrZeroback to summary
private static long longOrZero(String val)
sumTokensIOStatback to summary
private long sumTokensIOStat(Function<String, Long> mapFunc)