33 * "Isolation Group" or "Container". When the term "Isolation Group"
34 * is used in the API description, this refers to either:
35 *
36 *<ol>
37 *<li> All processes, including the current process within a container.
38 *
39 *<li> All processes, including the current process running together
40 * isolated from other non-isolated processes.
41 *
42 *<li> All processes running on a host when that there is no isolation
43 * in effect.
44 *</ol>
45 *
46 * @author bobv
47 * @since 11
48 */
49
50 public interface Metrics {
51
52 /**
53 * Returned for metrics of type long if the underlying implementation
54 * has determined that no limit is being imposed.
55 */
56 public static final long LONG_RETVAL_UNLIMITED = -1;
57 /**
58 * Returned for metrics of type long if the underlying implementation
59 * doesn't support that metric.
60 */
61 public static final long LONG_RETVAL_NOT_SUPPORTED = -2;
62 public static final double DOUBLE_RETVAL_NOT_SUPPORTED = LONG_RETVAL_NOT_SUPPORTED;
63 /**
64 * Returned for metrics of type Boolean if the underlying implementation
65 * doesn't support that metric.
66 */
67 public static final Boolean BOOL_RETVAL_NOT_SUPPORTED = null;
68
69 /**
70 * Returns an instance of the Metrics class.
71 *
72 * @return Metrics object or null if not supported on this platform.
73 */
74 public static Metrics systemMetrics() {
75 try {
76 Class<?> c = Class.forName("jdk.internal.platform.CgroupMetrics");
77 Method m = c.getMethod("getInstance");
78 return (Metrics) m.invoke(null);
79 } catch (ClassNotFoundException e) {
80 return null;
81 } catch (ReflectiveOperationException e) {
82 throw new InternalError(e);
83 }
84 }
85
86 /**
87 * Returns the interface responsible for providing the
88 * platform metrics.
89 *
271 * {@link getEffectiveCpuSetMems()}.
272 *
273 * @return An array of available memory nodes or null
274 * if the metric is not available.
275 *
276 */
277 public int[] getCpuSetMems();
278
279 /**
280 * Returns the memory nodes that are available and online for use by
281 * processes within the current Isolation Group. The size of the
282 * array is equal to the total number of nodes and the elements in
283 * the array are the physical node numbers.
284 *
285 * @return An array of available and online nodes or null
286 * if the metric is not available.
287 *
288 */
289 public int[] getEffectiveCpuSetMems();
290
291 /**
292 * Returns the (attempts per second * 1000), if enabled, that the
293 * operating system tries to satisfy a memory request for any
294 * process in the current Isolation Group when no free memory is
295 * readily available. Use {@link #isCpuSetMemoryPressureEnabled()} to
296 * determine if this support is enabled.
297 *
298 * @return Memory pressure or 0 if not enabled or -2 if metric is not
299 * available.
300 *
301 */
302 public double getCpuSetMemoryPressure();
303
304 /**
305 * Returns the state of the memory pressure detection support.
306 *
307 * @return true if support is available and enabled. null if metric is
308 * not available. false otherwise.
309 *
310 */
311 public Boolean isCpuSetMemoryPressureEnabled();
312
313 /*****************************************************************
314 * Memory Subsystem
315 ****************************************************************/
316
317 /**
318 * Returns the number of times that user memory requests in the
319 * Isolation Group have exceeded the memory limit.
320 *
321 * @return The number of exceeded requests or -2 if metric
322 * is not available.
323 *
324 */
325 public long getMemoryFailCount();
326
327 /**
328 * Returns the maximum amount of physical memory, in bytes, that
329 * can be allocated in the Isolation Group.
330 *
331 * @return The maximum amount of memory in bytes or -1 if
332 * there is no limit or -2 if this metric is not available.
333 *
334 */
335 public long getMemoryLimit();
336
337 /**
338 * Returns the largest amount of physical memory, in bytes, that
339 * have been allocated in the Isolation Group.
340 *
341 * @return The largest amount of memory in bytes or -2 if this
342 * metric is not available.
343 *
344 */
345 public long getMemoryMaxUsage();
346
347 /**
348 * Returns the amount of physical memory, in bytes, that is currently
349 * allocated in the current Isolation Group.
350 *
351 * @return The amount of memory in bytes allocated or -2 if this
352 * metric is not available.
353 *
354 */
355 public long getMemoryUsage();
356
357 /**
358 * Returns the number of times that kernel memory requests in the
359 * Isolation Group have exceeded the kernel memory limit.
360 *
361 * @return The number of exceeded requests or -2 if metric
362 * is not available.
363 *
364 */
365 public long getKernelMemoryFailCount();
366
367 /**
368 * Returns the maximum amount of kernel physical memory, in bytes, that
369 * can be allocated in the Isolation Group.
370 *
371 * @return The maximum amount of memory in bytes or -1 if
372 * there is no limit set or -2 if this metric is not available.
373 *
374 */
375 public long getKernelMemoryLimit();
376
377 /**
378 * Returns the largest amount of kernel physical memory, in bytes, that
379 * have been allocated in the Isolation Group.
380 *
381 * @return The largest amount of memory in bytes or -2 if this
382 * metric is not available.
383 *
384 */
385 public long getKernelMemoryMaxUsage();
386
387 /**
388 * Returns the amount of kernel physical memory, in bytes, that
389 * is currently allocated in the current Isolation Group.
390 *
391 * @return The amount of memory in bytes allocated or -2 if this
392 * metric is not available.
393 *
394 */
395 public long getKernelMemoryUsage();
396
397 /**
398 * Returns the number of times that networking memory requests in the
399 * Isolation Group have exceeded the kernel memory limit.
400 *
401 * @return The number of exceeded requests or -2 if the metric
402 * is not available.
403 *
404 */
405 public long getTcpMemoryFailCount();
406
407 /**
408 * Returns the maximum amount of networking physical memory, in bytes,
409 * that can be allocated in the Isolation Group.
410 *
411 * @return The maximum amount of memory in bytes or -1 if
412 * there is no limit or -2 if this metric is not available.
413 *
414 */
415 public long getTcpMemoryLimit();
416
417 /**
418 * Returns the largest amount of networking physical memory, in bytes,
419 * that have been allocated in the Isolation Group.
420 *
421 * @return The largest amount of memory in bytes or -2 if this
422 * metric is not available.
423 *
424 */
425 public long getTcpMemoryMaxUsage();
426
427 /**
428 * Returns the amount of networking physical memory, in bytes, that
429 * is currently allocated in the current Isolation Group.
430 *
431 * @return The amount of memory in bytes allocated or -2 if this
432 * metric is not available.
433 *
434 */
435 public long getTcpMemoryUsage();
436
437 /**
438 * Returns the number of times that user memory requests in the
439 * Isolation Group have exceeded the memory + swap limit.
440 *
441 * @return The number of exceeded requests or -2 if the metric
442 * is not available.
443 *
444 */
445 public long getMemoryAndSwapFailCount();
446
447 /**
448 * Returns the maximum amount of physical memory and swap space,
449 * in bytes, that can be allocated in the Isolation Group.
450 *
451 * @return The maximum amount of memory in bytes or -1 if
452 * there is no limit set or -2 if this metric is not available.
453 *
454 */
455 public long getMemoryAndSwapLimit();
456
457 /**
458 * Returns the largest amount of physical memory and swap space,
459 * in bytes, that have been allocated in the Isolation Group.
460 *
461 * @return The largest amount of memory in bytes or -2 if this
462 * metric is not available.
463 *
464 */
465 public long getMemoryAndSwapMaxUsage();
466
467 /**
468 * Returns the amount of physical memory and swap space, in bytes,
469 * that is currently allocated in the current Isolation Group.
470 *
471 * @return The amount of memory in bytes allocated or -2 if this
472 * metric is not available.
473 *
474 */
475 public long getMemoryAndSwapUsage();
476
477 /**
478 * Returns the state of the Operating System Out of Memory termination
479 * policy.
480 *
481 * @return Returns true if operating system will terminate processes
482 * in the Isolation Group that exceed the amount of available
483 * memory, otherwise false. null will be returned if this
484 * capability is not available on the current operating system.
485 *
486 */
487 public Boolean isMemoryOOMKillEnabled();
488
489 /**
490 * Returns the hint to the operating system that allows groups
491 * to specify the minimum amount of physical memory that they need to
492 * achieve reasonable performance in low memory systems. This allows
493 * host systems to provide greater sharing of memory.
494 *
495 * @return The minimum amount of physical memory, in bytes, that the
496 * operating system will try to maintain under low memory
497 * conditions. If this metric is not available, -2 will be
498 * returned.
499 *
500 */
501 public long getMemorySoftLimit();
502
503 /*****************************************************************
504 * BlKIO Subsystem
505 ****************************************************************/
506
507 /**
|
33 * "Isolation Group" or "Container". When the term "Isolation Group"
34 * is used in the API description, this refers to either:
35 *
36 *<ol>
37 *<li> All processes, including the current process within a container.
38 *
39 *<li> All processes, including the current process running together
40 * isolated from other non-isolated processes.
41 *
42 *<li> All processes running on a host when that there is no isolation
43 * in effect.
44 *</ol>
45 *
46 * @author bobv
47 * @since 11
48 */
49
50 public interface Metrics {
51
52 /**
53 * Returns an instance of the Metrics class.
54 *
55 * @return Metrics object or null if not supported on this platform.
56 */
57 public static Metrics systemMetrics() {
58 try {
59 Class<?> c = Class.forName("jdk.internal.platform.CgroupMetrics");
60 Method m = c.getMethod("getInstance");
61 return (Metrics) m.invoke(null);
62 } catch (ClassNotFoundException e) {
63 return null;
64 } catch (ReflectiveOperationException e) {
65 throw new InternalError(e);
66 }
67 }
68
69 /**
70 * Returns the interface responsible for providing the
71 * platform metrics.
72 *
254 * {@link getEffectiveCpuSetMems()}.
255 *
256 * @return An array of available memory nodes or null
257 * if the metric is not available.
258 *
259 */
260 public int[] getCpuSetMems();
261
262 /**
263 * Returns the memory nodes that are available and online for use by
264 * processes within the current Isolation Group. The size of the
265 * array is equal to the total number of nodes and the elements in
266 * the array are the physical node numbers.
267 *
268 * @return An array of available and online nodes or null
269 * if the metric is not available.
270 *
271 */
272 public int[] getEffectiveCpuSetMems();
273
274 /*****************************************************************
275 * Memory Subsystem
276 ****************************************************************/
277
278 /**
279 * Returns the number of times that user memory requests in the
280 * Isolation Group have exceeded the memory limit.
281 *
282 * @return The number of exceeded requests or -2 if metric
283 * is not available.
284 *
285 */
286 public long getMemoryFailCount();
287
288 /**
289 * Returns the maximum amount of physical memory, in bytes, that
290 * can be allocated in the Isolation Group.
291 *
292 * @return The maximum amount of memory in bytes or -1 if
293 * there is no limit or -2 if this metric is not available.
294 *
295 */
296 public long getMemoryLimit();
297
298 /**
299 * Returns the amount of physical memory, in bytes, that is currently
300 * allocated in the current Isolation Group.
301 *
302 * @return The amount of memory in bytes allocated or -2 if this
303 * metric is not available.
304 *
305 */
306 public long getMemoryUsage();
307
308 /**
309 * Returns the amount of networking physical memory, in bytes, that
310 * is currently allocated in the current Isolation Group.
311 *
312 * @return The amount of memory in bytes allocated or -2 if this
313 * metric is not available.
314 *
315 */
316 public long getTcpMemoryUsage();
317
318 /**
319 * Returns the maximum amount of physical memory and swap space,
320 * in bytes, that can be allocated in the Isolation Group.
321 *
322 * @return The maximum amount of memory in bytes or -1 if
323 * there is no limit set or -2 if this metric is not available.
324 *
325 */
326 public long getMemoryAndSwapLimit();
327
328 /**
329 * Returns the amount of physical memory and swap space, in bytes,
330 * that is currently allocated in the current Isolation Group.
331 *
332 * @return The amount of memory in bytes allocated or -2 if this
333 * metric is not available.
334 *
335 */
336 public long getMemoryAndSwapUsage();
337
338 /**
339 * Returns the hint to the operating system that allows groups
340 * to specify the minimum amount of physical memory that they need to
341 * achieve reasonable performance in low memory systems. This allows
342 * host systems to provide greater sharing of memory.
343 *
344 * @return The minimum amount of physical memory, in bytes, that the
345 * operating system will try to maintain under low memory
346 * conditions. If this metric is not available, -2 will be
347 * returned.
348 *
349 */
350 public long getMemorySoftLimit();
351
352 /*****************************************************************
353 * BlKIO Subsystem
354 ****************************************************************/
355
356 /**
|