APIdia Launch Partner
Top Description Methods
jdk.internal.platform

public Interface Metrics

Known Direct Subinterfaces
jdk.internal.platform.CgroupSubsystem, jdk.internal.platform.CgroupV1Metrics
Known Direct Implementers
jdk.internal.platform.CgroupMetrics
Imports
java.lang.reflect.Method

Operating System Metrics class

Implementation Note

Some of the APIs within this class return metrics for an "Isolation Group" or "Container". When the term "Isolation Group" is used in the API description, this refers to either:

  1. All processes, including the current process within a container.
  2. All processes, including the current process running together isolated from other non-isolated processes.
  3. All processes running on a host when that there is no isolation in effect.
Author
bobv
Since
11

Method Summary

Modifier and TypeMethod and Description
public long

Returns:

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

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

public long

Returns:

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

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

public long

Returns:

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

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

public long

Returns:

count of throttled periods, -1 if the metric is not available or -2 if it is not supported.
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

Returns:

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

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

public long

Returns:

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

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

public int[]

Returns:

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

Returns the CPUS that are available for execution of processes in the current Isolation Group.

public int[]

Returns:

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

Returns the memory nodes that are available for use by processes in the current Isolation Group.

public long

Returns:

shares value, -1 if the metric is not available or -2 if cpu shares are not supported.
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

Returns:

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

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

public long

Returns:

Throttled time in nanoseconds, -1 if the metric is not available or -2 if it is not supported.
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

Returns:

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

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

public long

Returns:

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

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

public long

Returns:

The number of effective CPUs.
getEffectiveCpuCount
()

Returns the number of effective processors that this Isolation group has available to it.

public int[]

Returns:

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

Returns the CPUS that are available and online for execution of processes within the current Isolation Group.

public int[]

Returns:

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

Returns the memory nodes that are available and online for use by processes within the current Isolation Group.

public long

Returns:

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

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

public long

Returns:

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

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

public long

Returns:

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

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

public long

Returns:

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

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

public long

Returns:

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.
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

Returns:

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

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

public long[]

Returns:

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.
getPerCpuUsage
()

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

public long

Returns:

The current number of tasks or -2 if not supported
getPidsCurrent
()

Returns the current number of tasks in the Isolation Group.

public long

Returns:

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

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

public String

Returns:

The name of the provider.
getProvider
()

Returns the interface responsible for providing the platform metrics.

public long

Returns:

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

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

public boolean

Returns:

true when the JVM runs in containerized mode. false otherwise.
isContainerized
()

Determines whether or not the underlying system has useful metrics (a.k.a. is containerized).

public static Metrics

Returns:

Metrics object or null if not supported on this platform.
systemMetrics
()

Returns an instance of the Metrics class.

Method Detail

getBlkIOServiceCountback to summary
public long 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.

getBlkIOServicedback to summary
public long 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.

getCpuNumPeriodsback to summary
public long 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.

getCpuNumThrottledback to summary
public long 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.

getCpuPeriodback to summary
public long 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.

getCpuQuotaback to summary
public long 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.

getCpuSetCpusback to summary
public int[] 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.

getCpuSetMemsback to summary
public int[] 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.

getCpuSharesback to summary
public long 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.

Implementation Note

Popular container orchestration systems have standardized shares to be multiples of 1024, where 1024 is interpreted as 1 CPU share of execution. Users can distribute CPU resources to multiple Isolation Groups by specifying the CPU share weighting needed by each process. To request 2 CPUS worth of execution time, CPU shares would be set to 2048.

Returns:long

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

getCpuSystemUsageback to summary
public long 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.

getCpuThrottledTimeback to summary
public long 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.

getCpuUsageback to summary
public long 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.

getCpuUserUsageback to summary
public long 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.

getEffectiveCpuCountback to summary
public long 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.

getEffectiveCpuSetCpusback to summary
public int[] 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.

getEffectiveCpuSetMemsback to summary
public int[] 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.

getMemoryAndSwapLimitback to summary
public long getMemoryAndSwapLimit()

Returns the maximum amount of physical memory and swap space, 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 set or -2 if this metric is not supported.

getMemoryAndSwapUsageback to summary
public long getMemoryAndSwapUsage()

Returns the amount of physical memory and swap space, 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.

getMemoryFailCountback to summary
public long 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.

getMemoryLimitback to summary
public long 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.

getMemorySoftLimitback to summary
public long 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.

getMemoryUsageback to summary
public long 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.

getPerCpuUsageback to summary
public long[] 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.

getPidsCurrentback to summary
public long getPidsCurrent()

Returns the current number of tasks in the Isolation Group.

Returns:long

The current number of tasks or -2 if not supported

getPidsMaxback to summary
public long 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.

getProviderback to summary
public String getProvider()

Returns the interface responsible for providing the platform metrics.

Implementation Note

Metrics are currently only supported Linux. The provider for Linux is cgroups (version 1 or 2).

Returns:String

The name of the provider.

getTcpMemoryUsageback to summary
public long 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.

isContainerizedback to summary
public boolean isContainerized()

Determines whether or not the underlying system has useful metrics (a.k.a. is containerized).

Implementation Note

Note that Metrics on some systems aren't useful. For example on a regular Linux system with cgroups present, with no limits enforced and not running in a container, Metric aren't useful. This can be used in order to determine if the system is containerized.

Returns:boolean

true when the JVM runs in containerized mode. false otherwise.

systemMetricsback to summary
public static Metrics systemMetrics()

Returns an instance of the Metrics class.

Returns:Metrics

Metrics object or null if not supported on this platform.