org.apache.tomcat.util

## Class Diagnostics

- java.lang.Object
- - org.apache.tomcat.util.Diagnostics

-     public class Diagnostics
      extends Object

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Diagnostics()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static String` | `findDeadlock()` Check if any threads are deadlocked.
    `static void` | `gc()` Initiate garbage collection via MX Bean
    `static String` | `getThreadDump()` Retrieves a formatted JVM thread dump.
    `static String` | `getThreadDump(Enumeration<Locale> requestedLocales)` Retrieves a formatted JVM thread dump.
    `static String` | `getThreadDump(StringManager requestedSm)` Retrieve a JVM thread dump formatted using the given StringManager.
    `static String` | `getVMInfo()` Retrieves a formatted JVM information text.
    `static String` | `getVMInfo(Enumeration<Locale> requestedLocales)` Retrieves a formatted JVM information text.
    `static String` | `getVMInfo(StringManager requestedSm)` Retrieve a JVM information text formatted using the given StringManager.
    `static boolean` | `isThreadContentionMonitoringEnabled()` Check whether thread contention monitoring is enabled.
    `static boolean` | `isThreadCpuTimeEnabled()` Check whether thread cpu time measurement is enabled.
    `static void` | `resetPeakThreadCount()` Reset peak thread count in ThreadMXBean
    `static void` | `resetPeakUsage(String name)` Reset peak memory usage data in MemoryPoolMXBean
    `static boolean` | `setCollectionUsageThreshold(String name, long threshold)` Set collection usage threshold in MemoryPoolMXBean
    `static void` | `setLoggerLevel(String loggerName, String levelName)` Set logger level
    `static void` | `setThreadContentionMonitoringEnabled(boolean enable)` Enable or disable thread contention monitoring via the ThreadMxMXBean.
    `static void` | `setThreadCpuTimeEnabled(boolean enable)` Enable or disable thread cpu time measurement via the ThreadMxMXBean.
    `static boolean` | `setUsageThreshold(String name, long threshold)` Set usage threshold in MemoryPoolMXBean
    `static void` | `setVerboseClassLoading(boolean verbose)` Set verbose class loading
    `static void` | `setVerboseGarbageCollection(boolean verbose)` Set verbose garbage collection logging

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Diagnostics

          public Diagnostics()

  - ### Method Detail

    - #### isThreadContentionMonitoringEnabled

          public static boolean isThreadContentionMonitoringEnabled()

      Check whether thread contention monitoring is enabled.
      Returns:
        true if thread contention monitoring is enabled

    - #### setThreadContentionMonitoringEnabled

          public static void setThreadContentionMonitoringEnabled(boolean enable)

      Enable or disable thread contention monitoring via the ThreadMxMXBean.
      Parameters:
        `enable` - whether to enable thread contention monitoring

    - #### isThreadCpuTimeEnabled

          public static boolean isThreadCpuTimeEnabled()

      Check whether thread cpu time measurement is enabled.
      Returns:
        true if thread cpu time measurement is enabled

    - #### setThreadCpuTimeEnabled

          public static void setThreadCpuTimeEnabled(boolean enable)

      Enable or disable thread cpu time measurement via the ThreadMxMXBean.
      Parameters:
        `enable` - whether to enable thread cpu time measurement

    - #### resetPeakThreadCount

          public static void resetPeakThreadCount()

      Reset peak thread count in ThreadMXBean

    - #### setVerboseClassLoading

          public static void setVerboseClassLoading(boolean verbose)

      Set verbose class loading
      Parameters:
        `verbose` - whether to enable verbose class loading

    - #### setLoggerLevel

          public static void setLoggerLevel(String loggerName,
                            String levelName)

      Set logger level
      Parameters:
        `loggerName` - the name of the logger
        `levelName` - the level to set

    - #### setVerboseGarbageCollection

          public static void setVerboseGarbageCollection(boolean verbose)

      Set verbose garbage collection logging
      Parameters:
        `verbose` - whether to enable verbose gc logging

    - #### gc

          public static void gc()

      Initiate garbage collection via MX Bean

    - #### resetPeakUsage

          public static void resetPeakUsage(String name)

      Reset peak memory usage data in MemoryPoolMXBean
      Parameters:
        `name` - name of the MemoryPoolMXBean or "all"

    - #### setUsageThreshold

          public static boolean setUsageThreshold(String name,
                                  long threshold)

      Set usage threshold in MemoryPoolMXBean
      Parameters:
        `name` - name of the MemoryPoolMXBean
        `threshold` - the threshold to set
      Returns:
        true if setting the threshold succeeded

    - #### setCollectionUsageThreshold

          public static boolean setCollectionUsageThreshold(String name,
                                            long threshold)

      Set collection usage threshold in MemoryPoolMXBean
      Parameters:
        `name` - name of the MemoryPoolMXBean
        `threshold` - the collection threshold to set
      Returns:
        true if setting the threshold succeeded

    - #### findDeadlock

          public static String findDeadlock()

      Check if any threads are deadlocked. If any, print the thread dump for those threads.
      Returns:
        a deadlock message and the formatted thread dump of the deadlocked threads

    - #### getThreadDump

          public static String getThreadDump()

      Retrieves a formatted JVM thread dump. The default StringManager will be used.
      Returns:
        the formatted JVM thread dump

    - #### getThreadDump

          public static String getThreadDump(Enumeration<Locale> requestedLocales)

      Retrieves a formatted JVM thread dump. The given list of locales will be used to retrieve a StringManager.
      Parameters:
        `requestedLocales` - list of locales to use
      Returns:
        the formatted JVM thread dump

    - #### getThreadDump

          public static String getThreadDump(StringManager requestedSm)

      Retrieve a JVM thread dump formatted using the given StringManager.
      Parameters:
        `requestedSm` - the StringManager to use
      Returns:
        the formatted JVM thread dump

    - #### getVMInfo

          public static String getVMInfo()

      Retrieves a formatted JVM information text. The default StringManager will be used.
      Returns:
        the formatted JVM information text

    - #### getVMInfo

          public static String getVMInfo(Enumeration<Locale> requestedLocales)

      Retrieves a formatted JVM information text. The given list of locales will be used to retrieve a StringManager.
      Parameters:
        `requestedLocales` - list of locales to use
      Returns:
        the formatted JVM information text

    - #### getVMInfo

          public static String getVMInfo(StringManager requestedSm)

      Retrieve a JVM information text formatted using the given StringManager.
      Parameters:
        `requestedSm` - the StringManager to use
      Returns:
        the formatted JVM information text

Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.