< 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 ****
/*
! * Copyright (c) 2019, 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
--- 1,7 ----
/*
! * 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,51 ****
* 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();
/**
--- 39,48 ----
*** 73,83 ****
public static long getLongValueMatchingLine(CgroupSubsystemController controller,
String param,
String match,
Function<String, Long> conversion) {
! long retval = CgroupSubsystemController.RETVAL_UNLIMITED;
try {
Path filePath = Paths.get(controller.path(), param);
List<String> lines = CgroupUtil.readAllLinesPrivileged(filePath);
for (String line : lines) {
if (line.startsWith(match)) {
--- 70,80 ----
public static long getLongValueMatchingLine(CgroupSubsystemController controller,
String param,
String match,
Function<String, Long> conversion) {
! 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,159 ****
*
* @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;
ArrayList<Integer> results = new ArrayList<>();
String strs[] = range.split(",");
for (String str : strs) {
if (str.contains("-")) {
--- 144,154 ----
*
* @param range
* @return int[] containing a sorted list of processors or memory nodes
*/
public static int[] stringRangeToIntArray(String range) {
! 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,185 ****
// sort results
results.sort(null);
// convert ArrayList to primitive int array
! ints = new int[results.size()];
int i = 0;
for (Integer n : results) {
ints[i++] = n;
}
--- 170,180 ----
// sort results
results.sort(null);
// convert ArrayList to primitive int array
! int[] ints = new int[results.size()];
int i = 0;
for (Integer n : results) {
ints[i++] = n;
}
< prev index next >