< 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
~


 102     private static final String JAVAFX_FXHELPER_CLASS_NAME_SUFFIX =
 103             "sun.launcher.LauncherHelper$FXHelper";
 104     private static final String LAUNCHER_AGENT_CLASS = "Launcher-Agent-Class";
 105     private static final String MAIN_CLASS = "Main-Class";
 106     private static final String ADD_EXPORTS = "Add-Exports";
 107     private static final String ADD_OPENS = "Add-Opens";
 108 
 109     private static StringBuilder outBuf = new StringBuilder();
 110 
 111     private static final String INDENT = "    ";
 112     private static final String VM_SETTINGS     = "VM settings:";
 113     private static final String PROP_SETTINGS   = "Property settings:";
 114     private static final String LOCALE_SETTINGS = "Locale settings:";
 115 
 116     // sync with java.c and jdk.internal.misc.VM
 117     private static final String diagprop = "sun.java.launcher.diag";
 118     static final boolean trace = VM.getSavedProperty(diagprop) != null;
 119 
 120     private static final String defaultBundleName =
 121             "sun.launcher.resources.launcher";

 122     private static class ResourceBundleHolder {
 123         private static final ResourceBundle RB =
 124                 ResourceBundle.getBundle(defaultBundleName);
 125     }
 126     private static PrintStream ostream;
 127     private static Class<?> appClass; // application class, for GUI/reporting purposes
 128 
 129     /*
 130      * A method called by the launcher to print out the standard settings,
 131      * by default -XshowSettings is equivalent to -XshowSettings:all,
 132      * Specific information may be gotten by using suboptions with possible
 133      * values vm, properties and locale.
 134      *
 135      * printToStderr: choose between stdout and stderr
 136      *
 137      * optionFlag: specifies which options to print default is all other
 138      *    possible values are vm, properties, locale.
 139      *
 140      * initialHeapSize: in bytes, as set by the launcher, a zero-value indicates
 141      *    this code should determine this value, using a suitable method or


 376         } else {
 377             ostream.println(INDENT + "List of Memory Nodes: N/A");
 378         }
 379 
 380         mems = c.getEffectiveCpuSetMems();
 381         if (mems != null) {
 382             ostream.println(INDENT + "List of Available Memory Nodes, "
 383                     + mems.length + " total: ");
 384 
 385             ostream.print(INDENT);
 386             for (int i = 0; i < mems.length; i++) {
 387                 ostream.print(mems[i] + " ");
 388             }
 389             if (mems.length > 0) {
 390                 ostream.println("");
 391             }
 392         } else {
 393             ostream.println(INDENT + "List of Available Memory Nodes: N/A");
 394         }
 395 
 396         ostream.println(formatBoolean(c.isCpuSetMemoryPressureEnabled(),
 397                                       INDENT + "CPUSet Memory Pressure Enabled: "));
 398 
 399         long limit = c.getMemoryLimit();
 400         ostream.println(formatLimitString(limit, INDENT + "Memory Limit: "));
 401 
 402         limit = c.getMemorySoftLimit();
 403         ostream.println(formatLimitString(limit, INDENT + "Memory Soft Limit: "));
 404 
 405         limit = c.getMemoryAndSwapLimit();
 406         ostream.println(formatLimitString(limit, INDENT + "Memory & Swap Limit: "));
 407 
 408         limit = c.getKernelMemoryLimit();
 409         ostream.println(formatLimitString(limit, INDENT + "Kernel Memory Limit: "));
 410 
 411         limit = c.getTcpMemoryLimit();
 412         ostream.println(formatLimitString(limit, INDENT + "TCP Memory Limit: "));
 413 
 414         ostream.println(formatBoolean(c.isMemoryOOMKillEnabled(),
 415                                       INDENT + "Out Of Memory Killer Enabled: "));
 416 
 417         ostream.println("");
 418     }
 419 
 420     private static String formatLimitString(long limit, String prefix) {
 421         if (limit >= 0) {
 422             return prefix + SizePrefix.scaleValue(limit);
 423         } else if (limit == Metrics.LONG_RETVAL_NOT_SUPPORTED) {
 424             return prefix + "N/A";
 425         } else {
 426             return prefix + "Unlimited";
 427         }
 428     }
 429 
 430     private static String formatCpuVal(long cpuVal, String prefix) {
 431         if (cpuVal >= 0) {
 432             return prefix + cpuVal + "us";
 433         } else if (cpuVal == Metrics.LONG_RETVAL_NOT_SUPPORTED) {
 434             return prefix + "N/A";
 435         } else {
 436             return prefix + cpuVal;
 437         }
 438     }
 439 
 440     private static String formatBoolean(Boolean value, String prefix) {
 441         if (value == Metrics.BOOL_RETVAL_NOT_SUPPORTED) {
 442             return prefix + "N/A";
 443         } else {
 444             return prefix + value;


 445         }
 446     }
 447 
 448     private enum SizePrefix {
 449 
 450         KILO(1024, "K"),
 451         MEGA(1024 * 1024, "M"),
 452         GIGA(1024 * 1024 * 1024, "G"),
 453         TERA(1024L * 1024L * 1024L * 1024L, "T");
 454         long size;
 455         String abbrev;
 456 
 457         SizePrefix(long size, String abbrev) {
 458             this.size = size;
 459             this.abbrev = abbrev;
 460         }
 461 
 462         private static String scale(long v, SizePrefix prefix) {
 463             return BigDecimal.valueOf(v).divide(BigDecimal.valueOf(prefix.size),
 464                     2, RoundingMode.HALF_EVEN).toPlainString() + prefix.abbrev;




 102     private static final String JAVAFX_FXHELPER_CLASS_NAME_SUFFIX =
 103             "sun.launcher.LauncherHelper$FXHelper";
 104     private static final String LAUNCHER_AGENT_CLASS = "Launcher-Agent-Class";
 105     private static final String MAIN_CLASS = "Main-Class";
 106     private static final String ADD_EXPORTS = "Add-Exports";
 107     private static final String ADD_OPENS = "Add-Opens";
 108 
 109     private static StringBuilder outBuf = new StringBuilder();
 110 
 111     private static final String INDENT = "    ";
 112     private static final String VM_SETTINGS     = "VM settings:";
 113     private static final String PROP_SETTINGS   = "Property settings:";
 114     private static final String LOCALE_SETTINGS = "Locale settings:";
 115 
 116     // sync with java.c and jdk.internal.misc.VM
 117     private static final String diagprop = "sun.java.launcher.diag";
 118     static final boolean trace = VM.getSavedProperty(diagprop) != null;
 119 
 120     private static final String defaultBundleName =
 121             "sun.launcher.resources.launcher";
 122     private static final long LONG_RETVAL_NOT_SUPPORTED = -2;
 123     private static class ResourceBundleHolder {
 124         private static final ResourceBundle RB =
 125                 ResourceBundle.getBundle(defaultBundleName);
 126     }
 127     private static PrintStream ostream;
 128     private static Class<?> appClass; // application class, for GUI/reporting purposes
 129 
 130     /*
 131      * A method called by the launcher to print out the standard settings,
 132      * by default -XshowSettings is equivalent to -XshowSettings:all,
 133      * Specific information may be gotten by using suboptions with possible
 134      * values vm, properties and locale.
 135      *
 136      * printToStderr: choose between stdout and stderr
 137      *
 138      * optionFlag: specifies which options to print default is all other
 139      *    possible values are vm, properties, locale.
 140      *
 141      * initialHeapSize: in bytes, as set by the launcher, a zero-value indicates
 142      *    this code should determine this value, using a suitable method or


 377         } else {
 378             ostream.println(INDENT + "List of Memory Nodes: N/A");
 379         }
 380 
 381         mems = c.getEffectiveCpuSetMems();
 382         if (mems != null) {
 383             ostream.println(INDENT + "List of Available Memory Nodes, "
 384                     + mems.length + " total: ");
 385 
 386             ostream.print(INDENT);
 387             for (int i = 0; i < mems.length; i++) {
 388                 ostream.print(mems[i] + " ");
 389             }
 390             if (mems.length > 0) {
 391                 ostream.println("");
 392             }
 393         } else {
 394             ostream.println(INDENT + "List of Available Memory Nodes: N/A");
 395         }
 396 



 397         long limit = c.getMemoryLimit();
 398         ostream.println(formatLimitString(limit, INDENT + "Memory Limit: "));
 399 
 400         limit = c.getMemorySoftLimit();
 401         ostream.println(formatLimitString(limit, INDENT + "Memory Soft Limit: "));
 402 
 403         limit = c.getMemoryAndSwapLimit();
 404         ostream.println(formatLimitString(limit, INDENT + "Memory & Swap Limit: "));
 405 









 406         ostream.println("");
 407     }
 408 
 409     private static String formatLimitString(long limit, String prefix) {
 410         if (limit >= 0) {
 411             return prefix + SizePrefix.scaleValue(limit);
 412         } else if (limit == LONG_RETVAL_NOT_SUPPORTED) {
 413             return prefix + "N/A";
 414         } else {
 415             return prefix + "Unlimited";
 416         }
 417     }
 418 
 419     private static String formatCpuVal(long cpuVal, String prefix) {
 420         if (cpuVal >= 0) {
 421             return prefix + cpuVal + "us";
 422         } else if (cpuVal == LONG_RETVAL_NOT_SUPPORTED) {
 423             return prefix + "N/A";
 424         } else {
 425             return prefix + cpuVal;
 426         }
 427     }
 428 
 429     private static String formatBoolean(Boolean value, String prefix) {
 430         if (value != null) {


 431             return prefix + value;
 432         } else {
 433             return prefix + "N/A";
 434         }
 435     }
 436 
 437     private enum SizePrefix {
 438 
 439         KILO(1024, "K"),
 440         MEGA(1024 * 1024, "M"),
 441         GIGA(1024 * 1024 * 1024, "G"),
 442         TERA(1024L * 1024L * 1024L * 1024L, "T");
 443         long size;
 444         String abbrev;
 445 
 446         SizePrefix(long size, String abbrev) {
 447             this.size = size;
 448             this.abbrev = abbrev;
 449         }
 450 
 451         private static String scale(long v, SizePrefix prefix) {
 452             return BigDecimal.valueOf(v).divide(BigDecimal.valueOf(prefix.size),
 453                     2, RoundingMode.HALF_EVEN).toPlainString() + prefix.abbrev;


< prev index next >