< prev index next >

src/java.base/linux/classes/jdk/internal/platform/CgroupSubsystemController.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 +1,7 @@
 /*
- * Copyright (c) 2019, Red Hat Inc.
+ * Copyright (c) 2020, Red Hat Inc.
  * 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

@@ -39,13 +39,10 @@
  * Cgroup version agnostic controller logic
  *
  */
 public interface CgroupSubsystemController {
 
-    public static final long RETVAL_UNLIMITED = -1;
-    public static final long RETVAL_NOT_SUPPORTED = -2;
-    public static final long RETVAL_ERROR = -3;
     public static final String EMPTY_STR = "";
 
     public String path();
 
     /**

@@ -73,11 +70,11 @@
 
     public static long getLongValueMatchingLine(CgroupSubsystemController controller,
                                                      String param,
                                                      String match,
                                                      Function<String, Long> conversion) {
-        long retval = CgroupSubsystemController.RETVAL_UNLIMITED;
+        long retval = Metrics.LONG_RETVAL_UNLIMITED;
         try {
             Path filePath = Paths.get(controller.path(), param);
             List<String> lines = CgroupUtil.readAllLinesPrivileged(filePath);
             for (String line : lines) {
                 if (line.startsWith(match)) {

@@ -147,13 +144,11 @@
      *
      * @param range
      * @return int[] containing a sorted list of processors or memory nodes
      */
     public static int[] stringRangeToIntArray(String range) {
-        int[] ints = new int[0];
-
-        if (range == null || EMPTY_STR.equals(range)) return ints;
+        if (range == null || EMPTY_STR.equals(range)) return null;
 
         ArrayList<Integer> results = new ArrayList<>();
         String strs[] = range.split(",");
         for (String str : strs) {
             if (str.contains("-")) {

@@ -175,11 +170,11 @@
 
         // sort results
         results.sort(null);
 
         // convert ArrayList to primitive int array
-        ints = new int[results.size()];
+        int[] ints = new int[results.size()];
         int i = 0;
         for (Integer n : results) {
             ints[i++] = n;
         }
 
< prev index next >