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
142 * the line could be omitted.
143 *
144 * maxHeapSize: in bytes, as set by the launcher, a zero-value indicates
145 * this code should determine this value, using a suitable method.
146 *
147 * stackSize: in bytes, as set by the launcher, a zero-value indicates
148 * this code determine this value, using a suitable method or omit the
149 * line entirely.
150 */
151 @SuppressWarnings("fallthrough")
152 static void showSettings(boolean printToStderr, String optionFlag,
153 long initialHeapSize, long maxHeapSize, long stackSize) {
154
155 initOutput(printToStderr);
156 String opts[] = optionFlag.split(":");
157 String optStr = (opts.length > 1 && opts[1] != null)
158 ? opts[1].trim()
159 : "all";
160 switch (optStr) {
161 case "vm":
162 printVmSettings(initialHeapSize, maxHeapSize, stackSize);
163 break;
164 case "properties":
165 printProperties();
166 break;
167 case "locale":
168 printLocale();
169 break;
170 case "system":
171 if (System.getProperty("os.name").contains("Linux")) {
172 printSystemMetrics();
173 break;
174 }
175 default:
176 printVmSettings(initialHeapSize, maxHeapSize, stackSize);
314 }
315
316 public static void printSystemMetrics() {
317 Metrics c = Container.metrics();
318
319 ostream.println("Operating System Metrics:");
320
321 if (c == null) {
322 ostream.println(INDENT + "No metrics available for this platform");
323 return;
324 }
325
326 ostream.println(INDENT + "Provider: " + c.getProvider());
327 ostream.println(INDENT + "Effective CPU Count: " + c.getEffectiveCpuCount());
328 ostream.println(INDENT + "CPU Period: " + c.getCpuPeriod() +
329 (c.getCpuPeriod() == -1 ? "" : "us"));
330 ostream.println(INDENT + "CPU Quota: " + c.getCpuQuota() +
331 (c.getCpuQuota() == -1 ? "" : "us"));
332 ostream.println(INDENT + "CPU Shares: " + c.getCpuShares());
333
334 int cpus[] = c.getCpuSetCpus();
335 ostream.println(INDENT + "List of Processors, "
336 + cpus.length + " total: ");
337
338 ostream.print(INDENT);
339 for (int i = 0; i < cpus.length; i++) {
340 ostream.print(cpus[i] + " ");
341 }
342 if (cpus.length > 0) {
343 ostream.println("");
344 }
345
346 cpus = c.getEffectiveCpuSetCpus();
347 ostream.println(INDENT + "List of Effective Processors, "
348 + cpus.length + " total: ");
349
350 ostream.print(INDENT);
351 for (int i = 0; i < cpus.length; i++) {
352 ostream.print(cpus[i] + " ");
353 }
354 if (cpus.length > 0) {
355 ostream.println("");
356 }
357
358 int mems[] = c.getCpuSetMems();
359 ostream.println(INDENT + "List of Memory Nodes, "
360 + mems.length + " total: ");
361
362 ostream.print(INDENT);
363 for (int i = 0; i < mems.length; i++) {
364 ostream.print(mems[i] + " ");
365 }
366 if (mems.length > 0) {
367 ostream.println("");
368 }
369
370 mems = c.getEffectiveCpuSetMems();
371 ostream.println(INDENT + "List of Available Memory Nodes, "
372 + mems.length + " total: ");
373
374 ostream.print(INDENT);
375 for (int i = 0; i < mems.length; i++) {
376 ostream.print(mems[i] + " ");
377 }
378 if (mems.length > 0) {
|
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
142 * the line could be omitted.
143 *
144 * maxHeapSize: in bytes, as set by the launcher, a zero-value indicates
145 * this code should determine this value, using a suitable method.
146 *
147 * stackSize: in bytes, as set by the launcher, a zero-value indicates
148 * this code determine this value, using a suitable method or omit the
149 * line entirely.
150 */
151 @SuppressWarnings("fallthrough")
152 static void showSettings(boolean printToStderr, String optionFlag,
153 long initialHeapSize, long maxHeapSize, long stackSize) {
154
155 initOutput(printToStderr);
156 String[] opts = optionFlag.split(":");
157 String optStr = (opts.length > 1 && opts[1] != null)
158 ? opts[1].trim()
159 : "all";
160 switch (optStr) {
161 case "vm":
162 printVmSettings(initialHeapSize, maxHeapSize, stackSize);
163 break;
164 case "properties":
165 printProperties();
166 break;
167 case "locale":
168 printLocale();
169 break;
170 case "system":
171 if (System.getProperty("os.name").contains("Linux")) {
172 printSystemMetrics();
173 break;
174 }
175 default:
176 printVmSettings(initialHeapSize, maxHeapSize, stackSize);
314 }
315
316 public static void printSystemMetrics() {
317 Metrics c = Container.metrics();
318
319 ostream.println("Operating System Metrics:");
320
321 if (c == null) {
322 ostream.println(INDENT + "No metrics available for this platform");
323 return;
324 }
325
326 ostream.println(INDENT + "Provider: " + c.getProvider());
327 ostream.println(INDENT + "Effective CPU Count: " + c.getEffectiveCpuCount());
328 ostream.println(INDENT + "CPU Period: " + c.getCpuPeriod() +
329 (c.getCpuPeriod() == -1 ? "" : "us"));
330 ostream.println(INDENT + "CPU Quota: " + c.getCpuQuota() +
331 (c.getCpuQuota() == -1 ? "" : "us"));
332 ostream.println(INDENT + "CPU Shares: " + c.getCpuShares());
333
334 int[] cpus = c.getCpuSetCpus();
335 ostream.println(INDENT + "List of Processors, "
336 + cpus.length + " total: ");
337
338 ostream.print(INDENT);
339 for (int i = 0; i < cpus.length; i++) {
340 ostream.print(cpus[i] + " ");
341 }
342 if (cpus.length > 0) {
343 ostream.println("");
344 }
345
346 cpus = c.getEffectiveCpuSetCpus();
347 ostream.println(INDENT + "List of Effective Processors, "
348 + cpus.length + " total: ");
349
350 ostream.print(INDENT);
351 for (int i = 0; i < cpus.length; i++) {
352 ostream.print(cpus[i] + " ");
353 }
354 if (cpus.length > 0) {
355 ostream.println("");
356 }
357
358 int[] mems = c.getCpuSetMems();
359 ostream.println(INDENT + "List of Memory Nodes, "
360 + mems.length + " total: ");
361
362 ostream.print(INDENT);
363 for (int i = 0; i < mems.length; i++) {
364 ostream.print(mems[i] + " ");
365 }
366 if (mems.length > 0) {
367 ostream.println("");
368 }
369
370 mems = c.getEffectiveCpuSetMems();
371 ostream.println(INDENT + "List of Available Memory Nodes, "
372 + mems.length + " total: ");
373
374 ostream.print(INDENT);
375 for (int i = 0; i < mems.length; i++) {
376 ostream.print(mems[i] + " ");
377 }
378 if (mems.length > 0) {
|