< prev index next >
src/java.base/share/classes/sun/launcher/LauncherHelper.java
Print this page
@ rev 57734 : Review feedback
|
o rev 57733 : 8231111: Cgroups v2: Rework Metrics in java.base so as to recognize unified hierarchy
| Reviewed-by: bobv, mchung
~
@@ -85,10 +85,11 @@
import jdk.internal.misc.VM;
import jdk.internal.module.ModuleBootstrap;
import jdk.internal.module.Modules;
import jdk.internal.platform.Container;
import jdk.internal.platform.Metrics;
+import jdk.internal.platform.MetricsCgroupV1;
public final class LauncherHelper {
// No instantiation
@@ -117,10 +118,11 @@
private static final String diagprop = "sun.java.launcher.diag";
static final boolean trace = VM.getSavedProperty(diagprop) != null;
private static final String defaultBundleName =
"sun.launcher.resources.launcher";
+ private static final long LONG_RETVAL_NOT_SUPPORTED = -2;
private static class ResourceBundleHolder {
private static final ResourceBundle RB =
ResourceBundle.getBundle(defaultBundleName);
}
private static PrintStream ostream;
@@ -391,59 +393,60 @@
}
} else {
ostream.println(INDENT + "List of Available Memory Nodes: N/A");
}
- ostream.println(formatBoolean(c.isCpuSetMemoryPressureEnabled(),
- INDENT + "CPUSet Memory Pressure Enabled: "));
-
long limit = c.getMemoryLimit();
ostream.println(formatLimitString(limit, INDENT + "Memory Limit: "));
limit = c.getMemorySoftLimit();
ostream.println(formatLimitString(limit, INDENT + "Memory Soft Limit: "));
limit = c.getMemoryAndSwapLimit();
ostream.println(formatLimitString(limit, INDENT + "Memory & Swap Limit: "));
- limit = c.getKernelMemoryLimit();
+ // Extended cgroupv1 specific metrics
+ if (c instanceof MetricsCgroupV1) {
+ MetricsCgroupV1 cgroupV1 = (MetricsCgroupV1)c;
+ limit = cgroupV1.getKernelMemoryLimit();
ostream.println(formatLimitString(limit, INDENT + "Kernel Memory Limit: "));
-
- limit = c.getTcpMemoryLimit();
+ limit = cgroupV1.getTcpMemoryLimit();
ostream.println(formatLimitString(limit, INDENT + "TCP Memory Limit: "));
-
- ostream.println(formatBoolean(c.isMemoryOOMKillEnabled(),
- INDENT + "Out Of Memory Killer Enabled: "));
+ Boolean value = cgroupV1.isMemoryOOMKillEnabled();
+ ostream.println(formatBoolean(value, INDENT + "Out Of Memory Killer Enabled: "));
+ value = cgroupV1.isCpuSetMemoryPressureEnabled();
+ ostream.println(formatBoolean(value, INDENT + "CPUSet Memory Pressure Enabled: "));
+ }
ostream.println("");
}
private static String formatLimitString(long limit, String prefix) {
if (limit >= 0) {
return prefix + SizePrefix.scaleValue(limit);
- } else if (limit == Metrics.LONG_RETVAL_NOT_SUPPORTED) {
+ } else if (limit == LONG_RETVAL_NOT_SUPPORTED) {
return prefix + "N/A";
} else {
return prefix + "Unlimited";
}
}
private static String formatCpuVal(long cpuVal, String prefix) {
if (cpuVal >= 0) {
return prefix + cpuVal + "us";
- } else if (cpuVal == Metrics.LONG_RETVAL_NOT_SUPPORTED) {
+ } else if (cpuVal == LONG_RETVAL_NOT_SUPPORTED) {
return prefix + "N/A";
} else {
return prefix + cpuVal;
}
}
private static String formatBoolean(Boolean value, String prefix) {
- if (value == Metrics.BOOL_RETVAL_NOT_SUPPORTED) {
- return prefix + "N/A";
- } else {
+ if (value != null) {
return prefix + value;
+ } else {
+ return prefix + "N/A";
}
}
private enum SizePrefix {
< prev index next >