1 /*
   2  * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
   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. Linux, only.
  31  *
  32  */
  33 public interface CgroupV1Metrics 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 -1 if this
  40      *         metric is not available. Returns -2 if this metric is not
  41      *         supported.
  42      *
  43      */
  44     public long getMemoryMaxUsage();
  45 
  46     /**
  47      * Returns the number of times that kernel memory requests in the
  48      * Isolation Group have exceeded the kernel memory limit.
  49      *
  50      * @return The number of exceeded requests or -1 if metric
  51      *         is not available.
  52      *
  53      */
  54     public long getKernelMemoryFailCount();
  55 
  56     /**
  57      * Returns the maximum amount of kernel physical memory, in bytes, that
  58      * can be allocated in the Isolation Group.
  59      *
  60      * @return The maximum amount of memory in bytes or -1 if
  61      *         there is no limit set.
  62      *
  63      */
  64     public long getKernelMemoryLimit();
  65 
  66     /**
  67      * Returns the largest amount of kernel physical memory, in bytes, that
  68      * have been allocated in the Isolation Group.
  69      *
  70      * @return The largest amount of memory in bytes or -1 if this
  71      *         metric is not available.
  72      *
  73      */
  74     public long getKernelMemoryMaxUsage();
  75 
  76     /**
  77      * Returns the amount of kernel physical memory, in bytes, that
  78      * is currently allocated in the current Isolation Group.
  79      *
  80      * @return The amount of memory in bytes allocated or -1 if this
  81      *         metric is not available.
  82      *
  83      */
  84     public long getKernelMemoryUsage();
  85 
  86     /**
  87      * Returns the number of times that networking memory requests in the
  88      * Isolation Group have exceeded the kernel memory limit.
  89      *
  90      * @return The number of exceeded requests or -1 if the metric
  91      *         is not available.
  92      *
  93      */
  94     public long getTcpMemoryFailCount();
  95 
  96     /**
  97      * Returns the maximum amount of networking physical memory, in bytes,
  98      * that can be allocated in the Isolation Group.
  99      *
 100      * @return The maximum amount of memory in bytes or -1 if
 101      *         there is no limit.
 102      *
 103      */
 104     public long getTcpMemoryLimit();
 105 
 106     /**
 107      * Returns the largest amount of networking physical memory, in bytes,
 108      * that have been allocated in the Isolation Group.
 109      *
 110      * @return The largest amount of memory in bytes or -1 if this
 111      *         metric is not available.
 112      *
 113      */
 114     public long getTcpMemoryMaxUsage();
 115 
 116     /**
 117      * Returns the number of times that user memory requests in the
 118      * Isolation Group have exceeded the memory + swap limit.
 119      *
 120      * @return The number of exceeded requests or -1 if the metric
 121      *         is not available.
 122      *
 123      */
 124     public long getMemoryAndSwapFailCount();
 125 
 126     /**
 127      * Returns the largest amount of physical memory and swap space,
 128      * in bytes, that have been allocated in the Isolation Group.
 129      *
 130      * @return The largest amount of memory in bytes or -1 if this
 131      *         metric is not available.
 132      *
 133      */
 134     public long getMemoryAndSwapMaxUsage();
 135 
 136     /**
 137      * Returns the state of the Operating System Out of Memory termination
 138      * policy.
 139      *
 140      * @return Returns true if operating system will terminate processes
 141      *         in the Isolation Group that exceed the amount of available
 142      *         memory, otherwise false. null will be returned if this
 143      *         capability is not available on the current operating system.
 144      *
 145      */
 146     public Boolean isMemoryOOMKillEnabled();
 147 
 148     /**
 149      * Returns the (attempts per second * 1000), if enabled, that the
 150      * operating system tries to satisfy a memory request for any
 151      * process in the current Isolation Group when no free memory is
 152      * readily available.  Use {@link #isCpuSetMemoryPressureEnabled()} to
 153      * determine if this support is enabled.
 154      *
 155      * @return Memory pressure or 0 if not enabled or -1 if metric is not
 156      *         available.
 157      *
 158      */
 159     public double getCpuSetMemoryPressure();
 160 
 161     /**
 162      * Returns the state of the memory pressure detection support.
 163      *
 164      * @return true if support is available and enabled. false otherwise.
 165      *
 166      */
 167     public Boolean isCpuSetMemoryPressureEnabled();
 168 }