1 /*
   2  * Copyright (c) 2020, Red Hat Inc.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package jdk.internal.platform;
  27 
  28 /**
  29  *
  30  * Cgroup v1 extensions to the Metrics interface.
  31  *
  32  */
  33 public interface MetricsCgroupV1 extends Metrics {
  34 
  35     /**
  36      * Returns the largest amount of physical memory, in bytes, that
  37      * have been allocated in the Isolation Group.
  38      *
  39      * @return The largest amount of memory in bytes or -2 if this
  40      *         metric is not available.
  41      *
  42      */
  43     public long getMemoryMaxUsage();
  44 
  45     /**
  46      * Returns the number of times that kernel memory requests in the
  47      * Isolation Group have exceeded the kernel memory limit.
  48      *
  49      * @return The number of exceeded requests or -2 if metric
  50      *         is not available.
  51      *
  52      */
  53     public long getKernelMemoryFailCount();
  54 
  55     /**
  56      * Returns the maximum amount of kernel physical memory, in bytes, that
  57      * can be allocated in the Isolation Group.
  58      *
  59      * @return The maximum amount of memory in bytes or -1 if
  60      *         there is no limit set or -2 if this metric is not available.
  61      *
  62      */
  63     public long getKernelMemoryLimit();
  64 
  65     /**
  66      * Returns the largest amount of kernel physical memory, in bytes, that
  67      * have been allocated in the Isolation Group.
  68      *
  69      * @return The largest amount of memory in bytes or -2 if this
  70      *         metric is not available.
  71      *
  72      */
  73     public long getKernelMemoryMaxUsage();
  74 
  75     /**
  76      * Returns the amount of kernel physical memory, in bytes, that
  77      * is currently allocated in the current Isolation Group.
  78      *
  79      * @return The amount of memory in bytes allocated or -2 if this
  80      *         metric is not available.
  81      *
  82      */
  83     public long getKernelMemoryUsage();
  84 
  85     /**
  86      * Returns the number of times that networking memory requests in the
  87      * Isolation Group have exceeded the kernel memory limit.
  88      *
  89      * @return The number of exceeded requests or -2 if the metric
  90      *         is not available.
  91      *
  92      */
  93     public long getTcpMemoryFailCount();
  94 
  95     /**
  96      * Returns the maximum amount of networking physical memory, in bytes,
  97      * that can be allocated in the Isolation Group.
  98      *
  99      * @return The maximum amount of memory in bytes or -1 if
 100      *         there is no limit or -2 if this metric is not available.
 101      *
 102      */
 103     public long getTcpMemoryLimit();
 104 
 105     /**
 106      * Returns the largest amount of networking physical memory, in bytes,
 107      * that have been allocated in the Isolation Group.
 108      *
 109      * @return The largest amount of memory in bytes or -2 if this
 110      *         metric is not available.
 111      *
 112      */
 113     public long getTcpMemoryMaxUsage();
 114 
 115     /**
 116      * Returns the number of times that user memory requests in the
 117      * Isolation Group have exceeded the memory + swap limit.
 118      *
 119      * @return The number of exceeded requests or -2 if the metric
 120      *         is not available.
 121      *
 122      */
 123     public long getMemoryAndSwapFailCount();
 124 
 125     /**
 126      * Returns the largest amount of physical memory and swap space,
 127      * in bytes, that have been allocated in the Isolation Group.
 128      *
 129      * @return The largest amount of memory in bytes or -2 if this
 130      *         metric is not available.
 131      *
 132      */
 133     public long getMemoryAndSwapMaxUsage();
 134 
 135     /**
 136      * Returns the state of the Operating System Out of Memory termination
 137      * policy.
 138      *
 139      * @return Returns true if operating system will terminate processes
 140      *         in the Isolation Group that exceed the amount of available
 141      *         memory, otherwise false. null will be returned if this
 142      *         capability is not available on the current operating system.
 143      *
 144      */
 145     public Boolean isMemoryOOMKillEnabled();
 146 
 147     /**
 148      * Returns the (attempts per second * 1000), if enabled, that the
 149      * operating system tries to satisfy a memory request for any
 150      * process in the current Isolation Group when no free memory is
 151      * readily available.  Use {@link #isCpuSetMemoryPressureEnabled()} to
 152      * determine if this support is enabled.
 153      *
 154      * @return Memory pressure or 0 if not enabled or -2 if metric is not
 155      *         available.
 156      *
 157      */
 158     public double getCpuSetMemoryPressure();
 159 
 160     /**
 161      * Returns the state of the memory pressure detection support.
 162      *
 163      * @return true if support is available and enabled. null if metric is
 164      *         not available. false otherwise.
 165      *
 166      */
 167     public Boolean isCpuSetMemoryPressureEnabled();
 168 }