< prev index next >

src/java.base/share/classes/jdk/internal/platform/Metrics.java

Print this page
@  rev 56863 : 8231111: Cgroups v2: Rework Metrics in java.base so as to recognize unified hierarchy
|  Reviewed-by: bobv
~


  39  *<li> All processes, including the current process running together
  40  *    isolated from other non-isolated processes.
  41  *
  42  *<li> All processes running on a host when that there is no isolation
  43  *     in effect.
  44  *</ol>
  45  *
  46  * @author bobv
  47  * @since 11
  48  */
  49 
  50 public interface Metrics {
  51 
  52     /**
  53      * Returns an instance of the Metrics class.
  54      *
  55      * @return Metrics object or null if not supported on this platform.
  56      */
  57     public static Metrics systemMetrics() {
  58         try {
  59             // We currently only support cgroupv1
  60             Class<?> c = Class.forName("jdk.internal.platform.cgroupv1.Metrics");
  61             @SuppressWarnings("unchecked")
  62             Method m = c.getMethod("getInstance");
  63             return (Metrics) m.invoke(null);
  64         } catch (ClassNotFoundException e) {
  65             return null;
  66         } catch (ReflectiveOperationException e) {
  67             throw new InternalError(e);
  68         }
  69     }
  70 
  71     /**
  72      * Returns the interface responsible for providing the
  73      * platform metrics.
  74      *
  75      * @implNote
  76      * Metrics are currently only supported Linux.
  77      * The provider for Linux is cgroupsv1.
  78      *
  79      * @return The name of the provider.
  80      *
  81      */




  39  *<li> All processes, including the current process running together
  40  *    isolated from other non-isolated processes.
  41  *
  42  *<li> All processes running on a host when that there is no isolation
  43  *     in effect.
  44  *</ol>
  45  *
  46  * @author bobv
  47  * @since 11
  48  */
  49 
  50 public interface Metrics {
  51 
  52     /**
  53      * Returns an instance of the Metrics class.
  54      *
  55      * @return Metrics object or null if not supported on this platform.
  56      */
  57     public static Metrics systemMetrics() {
  58         try {
  59             Class<?> c = Class.forName("jdk.internal.platform.CgroupMetrics");


  60             Method m = c.getMethod("getInstance");
  61             return (Metrics) m.invoke(null);
  62         } catch (ClassNotFoundException e) {
  63             return null;
  64         } catch (ReflectiveOperationException e) {
  65             throw new InternalError(e);
  66         }
  67     }
  68 
  69     /**
  70      * Returns the interface responsible for providing the
  71      * platform metrics.
  72      *
  73      * @implNote
  74      * Metrics are currently only supported Linux.
  75      * The provider for Linux is cgroupsv1.
  76      *
  77      * @return The name of the provider.
  78      *
  79      */


< prev index next >