< prev index next >
src/java.base/share/classes/jdk/internal/platform/Metrics.java
Print this page
@ rev 57586 : Review changes
|
o rev 57585 : 8231111: Cgroups v2: Rework Metrics in java.base so as to recognize unified hierarchy
| Reviewed-by: bobv
~
o rev 56863 : 8231111: Cgroups v2: Rework Metrics in java.base so as to recognize unified hierarchy
| Reviewed-by: bobv
~
*** 1,7 ****
/*
! * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 48,57 ****
--- 48,74 ----
*/
public interface Metrics {
/**
+ * Returned for metrics of type long if the underlying implementation
+ * has determined that no limit is being imposed.
+ */
+ public static final long LONG_RETVAL_UNLIMITED = -1;
+ /**
+ * Returned for metrics of type long if the underlying implementation
+ * doesn't support that metric.
+ */
+ public static final long LONG_RETVAL_NOT_SUPPORTED = -2;
+ public static final double DOUBLE_RETVAL_NOT_SUPPORTED = LONG_RETVAL_NOT_SUPPORTED;
+ /**
+ * Returned for metrics of type Boolean if the underlying implementation
+ * doesn't support that metric.
+ */
+ public static final Boolean BOOL_RETVAL_NOT_SUPPORTED = null;
+
+ /**
* Returns an instance of the Metrics class.
*
* @return Metrics object or null if not supported on this platform.
*/
public static Metrics systemMetrics() {
*** 70,80 ****
* Returns the interface responsible for providing the
* platform metrics.
*
* @implNote
* Metrics are currently only supported Linux.
! * The provider for Linux is cgroupsv1.
*
* @return The name of the provider.
*
*/
public String getProvider();
--- 87,97 ----
* Returns the interface responsible for providing the
* platform metrics.
*
* @implNote
* Metrics are currently only supported Linux.
! * The provider for Linux is cgroups (version 1 or 2).
*
* @return The name of the provider.
*
*/
public String getProvider();
*** 86,96 ****
/**
* Returns the aggregate time, in nanoseconds, consumed by all
* tasks in the Isolation Group.
*
! * @return Time in nanoseconds or 0L if metric is not available.
*
*/
public long getCpuUsage();
/**
--- 103,113 ----
/**
* Returns the aggregate time, in nanoseconds, consumed by all
* tasks in the Isolation Group.
*
! * @return Time in nanoseconds or -2 if metric is not available.
*
*/
public long getCpuUsage();
/**
*** 102,131 ****
* on the system. Time values for processors unavailable to this
* Group are undefined.
*
* @return 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 available, a zero length array will be
* returned.
*
*/
public long[] getPerCpuUsage();
/**
* Returns the aggregate user time, in nanoseconds, consumed by all
* tasks in the Isolation Group.
*
! * @return User time in nanoseconds or 0L if metric is not available.
*
*/
public long getCpuUserUsage();
/**
* Returns the aggregate system time, in nanoseconds, consumed by
* all tasks in the Isolation Group.
*
! * @return System time in nanoseconds or 0L if metric is not available.
*
*/
public long getCpuSystemUsage();
/*****************************************************************
--- 119,148 ----
* on the system. Time values for processors unavailable to this
* Group are undefined.
*
* @return 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 available, null will be
* returned.
*
*/
public long[] getPerCpuUsage();
/**
* Returns the aggregate user time, in nanoseconds, consumed by all
* tasks in the Isolation Group.
*
! * @return User time in nanoseconds or -2 if metric is not available.
*
*/
public long getCpuUserUsage();
/**
* Returns the aggregate system time, in nanoseconds, consumed by
* all tasks in the Isolation Group.
*
! * @return System time in nanoseconds or -2 if metric is not available.
*
*/
public long getCpuSystemUsage();
/*****************************************************************
*** 134,154 ****
/**
* Returns the length of the scheduling period, in
* microseconds, for processes within the Isolation Group.
*
! * @return time in microseconds or 0L if metric is not available.
*
*/
public long getCpuPeriod();
/**
* Returns the total available run-time allowed, in microseconds,
* during each scheduling period for all tasks in the Isolation
* Group.
*
! * @return time in microseconds or -1 if the quota is unlimited.
*
*/
public long getCpuQuota();
--- 151,171 ----
/**
* Returns the length of the scheduling period, in
* microseconds, for processes within the Isolation Group.
*
! * @return time in microseconds or -2 if metric is not available.
*
*/
public long getCpuPeriod();
/**
* Returns the total available run-time allowed, in microseconds,
* during each scheduling period for all tasks in the Isolation
* Group.
*
! * @return time in microseconds or -2 if not supported.
*
*/
public long getCpuQuota();
*** 163,203 ****
* 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.
*
! * @return shares value or -1 if no share set.
*
*/
public long getCpuShares();
/**
* Returns the number of time-slice periods that have elapsed if
* a CPU quota has been setup for the Isolation Group; otherwise
* returns 0.
*
! * @return count of elapsed periods or 0 if the quota is unlimited.
*
*/
public long getCpuNumPeriods();
/**
* 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.
*
! * @return count of throttled periods or 0 if the quota is unlimited.
*
*/
public long getCpuNumThrottled();
/**
* 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.
*
! * @return Throttled time in nanoseconds or 0 if the quota is unlimited.
*
*/
public long getCpuThrottledTime();
--- 180,220 ----
* 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.
*
! * @return shares value or -2 if no share set.
*
*/
public long getCpuShares();
/**
* Returns the number of time-slice periods that have elapsed if
* a CPU quota has been setup for the Isolation Group; otherwise
* returns 0.
*
! * @return count of elapsed periods or -2 if not supported.
*
*/
public long getCpuNumPeriods();
/**
* 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.
*
! * @return count of throttled periods or -2 if not supported.
*
*/
public long getCpuNumThrottled();
/**
* 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.
*
! * @return Throttled time in nanoseconds or -2 if not supported.
*
*/
public long getCpuThrottledTime();
*** 225,235 ****
* 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
* {@link getEffectiveCpuSetCpus()}.
*
! * @return An array of available CPUs or a zero length array
* if the metric is not available.
*
*/
public int[] getCpuSetCpus();
--- 242,252 ----
* 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
* {@link getEffectiveCpuSetCpus()}.
*
! * @return An array of available CPUs or null
* if the metric is not available.
*
*/
public int[] getCpuSetCpus();
*** 237,248 ****
* 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.
*
! * @return An array of available and online CPUs or a zero length
! * array if the metric is not available.
*
*/
public int[] getEffectiveCpuSetCpus();
/**
--- 254,265 ----
* 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.
*
! * @return An array of available and online CPUs or null
! * if the metric is not available.
*
*/
public int[] getEffectiveCpuSetCpus();
/**
*** 251,261 ****
* 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
* {@link getEffectiveCpuSetMems()}.
*
! * @return An array of available memory nodes or a zero length array
* if the metric is not available.
*
*/
public int[] getCpuSetMems();
--- 268,278 ----
* 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
* {@link getEffectiveCpuSetMems()}.
*
! * @return An array of available memory nodes or null
* if the metric is not available.
*
*/
public int[] getCpuSetMems();
*** 263,274 ****
* 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.
*
! * @return An array of available and online nodes or a zero length
! * array if the metric is not available.
*
*/
public int[] getEffectiveCpuSetMems();
/**
--- 280,291 ----
* 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.
*
! * @return An array of available and online nodes or null
! * if the metric is not available.
*
*/
public int[] getEffectiveCpuSetMems();
/**
*** 276,458 ****
* operating system tries to satisfy a memory request for any
* process in the current Isolation Group when no free memory is
* readily available. Use {@link #isCpuSetMemoryPressureEnabled()} to
* determine if this support is enabled.
*
! * @return Memory pressure or 0 if not enabled or metric is not
* available.
*
*/
public double getCpuSetMemoryPressure();
/**
* Returns the state of the memory pressure detection support.
*
! * @return true if the support is available and enabled, otherwise false.
*
*/
! public boolean isCpuSetMemoryPressureEnabled();
/*****************************************************************
* Memory Subsystem
****************************************************************/
/**
* Returns the number of times that user memory requests in the
* Isolation Group have exceeded the memory limit.
*
! * @return The number of exceeded requests or 0 if none or metric
* is not available.
*
*/
public long getMemoryFailCount();
/**
* Returns the maximum amount of physical memory, in bytes, that
* can be allocated in the Isolation Group.
*
! * @return The maximum amount of memory in bytes or -1 if either
! * there is no limit set or this metric is not available.
*
*/
public long getMemoryLimit();
/**
* Returns the largest amount of physical memory, in bytes, that
* have been allocated in the Isolation Group.
*
! * @return The largest amount of memory in bytes or 0 if this
* metric is not available.
*
*/
public long getMemoryMaxUsage();
/**
* Returns the amount of physical memory, in bytes, that is currently
* allocated in the current Isolation Group.
*
! * @return The amount of memory in bytes allocated or 0 if this
* metric is not available.
*
*/
public long getMemoryUsage();
/**
* Returns the number of times that kernel memory requests in the
* Isolation Group have exceeded the kernel memory limit.
*
! * @return The number of exceeded requests or 0 if none or metric
* is not available.
*
*/
public long getKernelMemoryFailCount();
/**
* Returns the maximum amount of kernel physical memory, in bytes, that
* can be allocated in the Isolation Group.
*
! * @return The maximum amount of memory in bytes or -1 if either
! * there is no limit set or this metric is not available.
*
*/
public long getKernelMemoryLimit();
/**
* Returns the largest amount of kernel physical memory, in bytes, that
* have been allocated in the Isolation Group.
*
! * @return The largest amount of memory in bytes or 0 if this
* metric is not available.
*
*/
public long getKernelMemoryMaxUsage();
/**
* Returns the amount of kernel physical memory, in bytes, that
* is currently allocated in the current Isolation Group.
*
! * @return The amount of memory in bytes allocated or 0 if this
* metric is not available.
*
*/
public long getKernelMemoryUsage();
/**
* Returns the number of times that networking memory requests in the
* Isolation Group have exceeded the kernel memory limit.
*
! * @return The number of exceeded requests or 0 if none or metric
* is not available.
*
*/
public long getTcpMemoryFailCount();
/**
* Returns the maximum amount of networking physical memory, in bytes,
* that can be allocated in the Isolation Group.
*
! * @return The maximum amount of memory in bytes or -1 if either
! * there is no limit set or this metric is not available.
*
*/
public long getTcpMemoryLimit();
/**
* Returns the largest amount of networking physical memory, in bytes,
* that have been allocated in the Isolation Group.
*
! * @return The largest amount of memory in bytes or 0 if this
* metric is not available.
*
*/
public long getTcpMemoryMaxUsage();
/**
* Returns the amount of networking physical memory, in bytes, that
* is currently allocated in the current Isolation Group.
*
! * @return The amount of memory in bytes allocated or 0 if this
* metric is not available.
*
*/
public long getTcpMemoryUsage();
/**
* Returns the number of times that user memory requests in the
* Isolation Group have exceeded the memory + swap limit.
*
! * @return The number of exceeded requests or 0 if none or metric
* is not available.
*
*/
public long getMemoryAndSwapFailCount();
/**
* Returns the maximum amount of physical memory and swap space,
* in bytes, that can be allocated in the Isolation Group.
*
! * @return The maximum amount of memory in bytes or -1 if either
! * there is no limit set or this metric is not available.
*
*/
public long getMemoryAndSwapLimit();
/**
* Returns the largest amount of physical memory and swap space,
* in bytes, that have been allocated in the Isolation Group.
*
! * @return The largest amount of memory in bytes or 0 if this
* metric is not available.
*
*/
public long getMemoryAndSwapMaxUsage();
/**
* Returns the amount of physical memory and swap space, in bytes,
* that is currently allocated in the current Isolation Group.
*
! * @return The amount of memory in bytes allocated or 0 if this
* metric is not available.
*
*/
public long getMemoryAndSwapUsage();
--- 293,476 ----
* operating system tries to satisfy a memory request for any
* process in the current Isolation Group when no free memory is
* readily available. Use {@link #isCpuSetMemoryPressureEnabled()} to
* determine if this support is enabled.
*
! * @return Memory pressure or 0 if not enabled or -2 if metric is not
* available.
*
*/
public double getCpuSetMemoryPressure();
/**
* Returns the state of the memory pressure detection support.
*
! * @return true if support is available and enabled. null if metric is
! * not available. false otherwise.
*
*/
! public Boolean isCpuSetMemoryPressureEnabled();
/*****************************************************************
* Memory Subsystem
****************************************************************/
/**
* Returns the number of times that user memory requests in the
* Isolation Group have exceeded the memory limit.
*
! * @return The number of exceeded requests or -2 if metric
* is not available.
*
*/
public long getMemoryFailCount();
/**
* Returns the maximum amount of physical memory, in bytes, that
* can be allocated in the Isolation Group.
*
! * @return The maximum amount of memory in bytes or -1 if
! * there is no limit or -2 if this metric is not available.
*
*/
public long getMemoryLimit();
/**
* Returns the largest amount of physical memory, in bytes, that
* have been allocated in the Isolation Group.
*
! * @return The largest amount of memory in bytes or -2 if this
* metric is not available.
*
*/
public long getMemoryMaxUsage();
/**
* Returns the amount of physical memory, in bytes, that is currently
* allocated in the current Isolation Group.
*
! * @return The amount of memory in bytes allocated or -2 if this
* metric is not available.
*
*/
public long getMemoryUsage();
/**
* Returns the number of times that kernel memory requests in the
* Isolation Group have exceeded the kernel memory limit.
*
! * @return The number of exceeded requests or -2 if metric
* is not available.
*
*/
public long getKernelMemoryFailCount();
/**
* Returns the maximum amount of kernel physical memory, in bytes, that
* can be allocated in the Isolation Group.
*
! * @return The maximum amount of memory in bytes or -1 if
! * there is no limit set or -2 if this metric is not available.
*
*/
public long getKernelMemoryLimit();
/**
* Returns the largest amount of kernel physical memory, in bytes, that
* have been allocated in the Isolation Group.
*
! * @return The largest amount of memory in bytes or -2 if this
* metric is not available.
*
*/
public long getKernelMemoryMaxUsage();
/**
* Returns the amount of kernel physical memory, in bytes, that
* is currently allocated in the current Isolation Group.
*
! * @return The amount of memory in bytes allocated or -2 if this
* metric is not available.
*
*/
public long getKernelMemoryUsage();
/**
* Returns the number of times that networking memory requests in the
* Isolation Group have exceeded the kernel memory limit.
*
! * @return The number of exceeded requests or -2 if the metric
* is not available.
*
*/
public long getTcpMemoryFailCount();
/**
* Returns the maximum amount of networking physical memory, in bytes,
* that can be allocated in the Isolation Group.
*
! * @return The maximum amount of memory in bytes or -1 if
! * there is no limit or -2 if this metric is not available.
*
*/
public long getTcpMemoryLimit();
/**
* Returns the largest amount of networking physical memory, in bytes,
* that have been allocated in the Isolation Group.
*
! * @return The largest amount of memory in bytes or -2 if this
* metric is not available.
*
*/
public long getTcpMemoryMaxUsage();
/**
* Returns the amount of networking physical memory, in bytes, that
* is currently allocated in the current Isolation Group.
*
! * @return The amount of memory in bytes allocated or -2 if this
* metric is not available.
*
*/
public long getTcpMemoryUsage();
/**
* Returns the number of times that user memory requests in the
* Isolation Group have exceeded the memory + swap limit.
*
! * @return The number of exceeded requests or -2 if the metric
* is not available.
*
*/
public long getMemoryAndSwapFailCount();
/**
* Returns the maximum amount of physical memory and swap space,
* in bytes, that can be allocated in the Isolation Group.
*
! * @return The maximum amount of memory in bytes or -1 if
! * there is no limit set or -2 if this metric is not available.
*
*/
public long getMemoryAndSwapLimit();
/**
* Returns the largest amount of physical memory and swap space,
* in bytes, that have been allocated in the Isolation Group.
*
! * @return The largest amount of memory in bytes or -2 if this
* metric is not available.
*
*/
public long getMemoryAndSwapMaxUsage();
/**
* Returns the amount of physical memory and swap space, in bytes,
* that is currently allocated in the current Isolation Group.
*
! * @return The amount of memory in bytes allocated or -2 if this
* metric is not available.
*
*/
public long getMemoryAndSwapUsage();
*** 460,484 ****
* Returns the state of the Operating System Out of Memory termination
* policy.
*
* @return Returns true if operating system will terminate processes
* in the Isolation Group that exceed the amount of available
! * memory, otherwise false. Flase will be returned if this
* capability is not available on the current operating system.
*
*/
! public boolean isMemoryOOMKillEnabled();
/**
* 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.
*
* @return 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, 0 will be
* returned.
*
*/
public long getMemorySoftLimit();
--- 478,502 ----
* Returns the state of the Operating System Out of Memory termination
* policy.
*
* @return Returns true if operating system will terminate processes
* in the Isolation Group that exceed the amount of available
! * memory, otherwise false. null will be returned if this
* capability is not available on the current operating system.
*
*/
! public Boolean isMemoryOOMKillEnabled();
/**
* 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.
*
* @return 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, -2 will be
* returned.
*
*/
public long getMemorySoftLimit();
*** 488,506 ****
/**
* Returns the number of block I/O requests to the disk that have been
* issued by the Isolation Group.
*
! * @return The count of requests or 0 if this metric is not available.
*
*/
public long getBlkIOServiceCount();
/**
* Returns the number of block I/O bytes that have been transferred
* to/from the disk by the Isolation Group.
*
! * @return The number of bytes transferred or 0 if this metric is not available.
*
*/
public long getBlkIOServiced();
}
--- 506,524 ----
/**
* Returns the number of block I/O requests to the disk that have been
* issued by the Isolation Group.
*
! * @return The count of requests or -2 if this metric is not available.
*
*/
public long getBlkIOServiceCount();
/**
* Returns the number of block I/O bytes that have been transferred
* to/from the disk by the Isolation Group.
*
! * @return The number of bytes transferred or -2 if this metric is not available.
*
*/
public long getBlkIOServiced();
}
< prev index next >