< prev index next >
src/java.base/share/classes/sun/launcher/LauncherHelper.java
Print this page
@ rev 57735 : Review feedback 2
|
o 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
~
*** 117,127 ****
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;
--- 117,127 ----
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 class ResourceBundleHolder {
private static final ResourceBundle RB =
ResourceBundle.getBundle(defaultBundleName);
}
private static PrintStream ostream;
*** 322,336 ****
if (c == null) {
ostream.println(INDENT + "No metrics available for this platform");
return;
}
ostream.println(INDENT + "Provider: " + c.getProvider());
ostream.println(INDENT + "Effective CPU Count: " + c.getEffectiveCpuCount());
! ostream.println(formatCpuVal(c.getCpuPeriod(), INDENT + "CPU Period: "));
! ostream.println(formatCpuVal(c.getCpuQuota(), INDENT + "CPU Quota: "));
! ostream.println(formatCpuVal(c.getCpuShares(), INDENT + "CPU Shares: "));
int cpus[] = c.getCpuSetCpus();
if (cpus != null) {
ostream.println(INDENT + "List of Processors, "
+ cpus.length + " total: ");
--- 322,338 ----
if (c == null) {
ostream.println(INDENT + "No metrics available for this platform");
return;
}
+ final long longRetvalNotSupported = -2;
+
ostream.println(INDENT + "Provider: " + c.getProvider());
ostream.println(INDENT + "Effective CPU Count: " + c.getEffectiveCpuCount());
! ostream.println(formatCpuVal(c.getCpuPeriod(), INDENT + "CPU Period: ", longRetvalNotSupported));
! ostream.println(formatCpuVal(c.getCpuQuota(), INDENT + "CPU Quota: ", longRetvalNotSupported));
! ostream.println(formatCpuVal(c.getCpuShares(), INDENT + "CPU Shares: ", longRetvalNotSupported));
int cpus[] = c.getCpuSetCpus();
if (cpus != null) {
ostream.println(INDENT + "List of Processors, "
+ cpus.length + " total: ");
*** 393,441 ****
} else {
ostream.println(INDENT + "List of Available Memory Nodes: N/A");
}
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: "));
ostream.println("");
}
! private static String formatLimitString(long limit, String prefix) {
if (limit >= 0) {
return prefix + SizePrefix.scaleValue(limit);
! } 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 == LONG_RETVAL_NOT_SUPPORTED) {
return prefix + "N/A";
} else {
return prefix + cpuVal;
}
}
- private static String formatBoolean(Boolean value, String prefix) {
- if (value != null) {
- return prefix + value;
- } else {
- return prefix + "N/A";
- }
- }
-
private enum SizePrefix {
KILO(1024, "K"),
MEGA(1024 * 1024, "M"),
GIGA(1024 * 1024 * 1024, "G"),
--- 395,435 ----
} else {
ostream.println(INDENT + "List of Available Memory Nodes: N/A");
}
long limit = c.getMemoryLimit();
! ostream.println(formatLimitString(limit, INDENT + "Memory Limit: ", longRetvalNotSupported));
limit = c.getMemorySoftLimit();
! ostream.println(formatLimitString(limit, INDENT + "Memory Soft Limit: ", longRetvalNotSupported));
limit = c.getMemoryAndSwapLimit();
! ostream.println(formatLimitString(limit, INDENT + "Memory & Swap Limit: ", longRetvalNotSupported));
ostream.println("");
}
! private static String formatLimitString(long limit, String prefix, long unavailable) {
if (limit >= 0) {
return prefix + SizePrefix.scaleValue(limit);
! } else if (limit == unavailable) {
return prefix + "N/A";
} else {
return prefix + "Unlimited";
}
}
! private static String formatCpuVal(long cpuVal, String prefix, long unavailable) {
if (cpuVal >= 0) {
return prefix + cpuVal + "us";
! } else if (cpuVal == unavailable) {
return prefix + "N/A";
} else {
return prefix + cpuVal;
}
}
private enum SizePrefix {
KILO(1024, "K"),
MEGA(1024 * 1024, "M"),
GIGA(1024 * 1024 * 1024, "G"),
< prev index next >