Top Fields Constructors Methods
org.apache.tomcat.util

public Class Diagnostics

extends Object
Class Inheritance
Imports
java.lang.management.ClassLoadingMXBean, .CompilationMXBean, .GarbageCollectorMXBean, .LockInfo, .ManagementFactory, .MemoryMXBean, .MemoryManagerMXBean, .MemoryPoolMXBean, .MemoryUsage, .MonitorInfo, .OperatingSystemMXBean, .PlatformLoggingMXBean, .RuntimeMXBean, .ThreadInfo, .ThreadMXBean, java.text.SimpleDateFormat, java.util.ArrayList, .Arrays, .Collections, .Date, .Enumeration, .List, .Locale, .Map, org.apache.juli.logging.Log, .LogFactory, org.apache.tomcat.util.res.StringManager

Field Summary

Modifier and TypeField and Description
private static final ClassLoadingMXBean
private static final CompilationMXBean
private static final String
private static final List<GarbageCollectorMXBean>
private static final String
private static final String
private static final String
private static final Log
private static final PlatformLoggingMXBean
private static final List<MemoryManagerMXBean>
private static final MemoryMXBean
private static final List<MemoryPoolMXBean>
private static final OperatingSystemMXBean
private static final String
private static final RuntimeMXBean
private static final StringManager
private static final ThreadMXBean
private static final SimpleDateFormat
private static final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static String

Returns:

a deadlock message and the formatted thread dump of the deadlocked threads
findDeadlock
()

Check if any threads are deadlocked.

private static String

Returns:

the formatted contents
formatMemoryUsage
(String
a text prefix used in formatting
name
,
MemoryUsage
the MemoryUsage object to format
usage
)

Format contents of a MemoryUsage object.

public static void
gc()

Initiate garbage collection via MX Bean

private static String

Returns:

the formatted thread dump
getThreadDump
(ThreadInfo
the ThreadInfo describing the thread
ti
)

Formats the thread dump for one thread.

private static String

Returns:

the formatted thread dump
getThreadDump
(ThreadInfo[]
the ThreadInfo array describing the thread list
tinfos
)

Formats the thread dump for a list of threads.

public static String

Returns:

the formatted JVM thread dump
getThreadDump
()

Retrieves a formatted JVM thread dump.

public static String

Returns:

the formatted JVM thread dump
getThreadDump
(Enumeration<Locale>
list of locales to use
requestedLocales
)

Retrieves a formatted JVM thread dump.

public static String

Returns:

the formatted JVM thread dump
getThreadDump
(StringManager
the StringManager to use
requestedSm
)

Retrieve a JVM thread dump formatted using the given StringManager.

private static String

Returns:

the formatted thread dump header
getThreadDumpHeader
(ThreadInfo
the ThreadInfo describing the thread
ti
)

Formats the thread dump header for one thread.

public static String

Returns:

the formatted JVM information text
getVMInfo
()

Retrieves a formatted JVM information text.

public static String

Returns:

the formatted JVM information text
getVMInfo
(Enumeration<Locale>
list of locales to use
requestedLocales
)

Retrieves a formatted JVM information text.

public static String

Returns:

the formatted JVM information text
getVMInfo
(StringManager
the StringManager to use
requestedSm
)

Retrieve a JVM information text formatted using the given StringManager.

public static boolean

Returns:

true if thread contention monitoring is enabled
isThreadContentionMonitoringEnabled
()

Check whether thread contention monitoring is enabled.

public static boolean

Returns:

true if thread cpu time measurement is enabled
isThreadCpuTimeEnabled
()

Check whether thread cpu time measurement is enabled.

public static void
resetPeakThreadCount()

Reset peak thread count in ThreadMXBean

public static void
resetPeakUsage(String
name of the MemoryPoolMXBean or "all"
name
)

Reset peak memory usage data in MemoryPoolMXBean

public static boolean

Returns:

true if setting the threshold succeeded
setCollectionUsageThreshold
(String
name of the MemoryPoolMXBean
name
,
long
the collection threshold to set
threshold
)

Set collection usage threshold in MemoryPoolMXBean

public static void
setLoggerLevel(String
the name of the logger
loggerName
,
String
the level to set
levelName
)

Set logger level

public static void
setThreadContentionMonitoringEnabled(boolean
whether to enable thread contention monitoring
enable
)

Enable or disable thread contention monitoring via the ThreadMxMXBean.

public static void
setThreadCpuTimeEnabled(boolean
whether to enable thread cpu time measurement
enable
)

Enable or disable thread cpu time measurement via the ThreadMxMXBean.

public static boolean

Returns:

true if setting the threshold succeeded
setUsageThreshold
(String
name of the MemoryPoolMXBean
name
,
long
the threshold to set
threshold
)

Set usage threshold in MemoryPoolMXBean

public static void
setVerboseClassLoading(boolean
whether to enable verbose class loading
verbose
)

Set verbose class loading

public static void
setVerboseGarbageCollection(boolean
whether to enable verbose gc logging
verbose
)

Set verbose garbage collection logging

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

classLoadingMXBeanback to summary
private static final ClassLoadingMXBean classLoadingMXBean
compilationMXBeanback to summary
private static final CompilationMXBean compilationMXBean
CRLFback to summary
private static final String CRLF
garbageCollectorMXBeansback to summary
private static final List<GarbageCollectorMXBean> garbageCollectorMXBeans
INDENT1back to summary
private static final String INDENT1
INDENT2back to summary
private static final String INDENT2
INDENT3back to summary
private static final String INDENT3
logback to summary
private static final Log log
loggingMXBeanback to summary
private static final PlatformLoggingMXBean loggingMXBean
memoryManagerMXBeansback to summary
private static final List<MemoryManagerMXBean> memoryManagerMXBeans
memoryMXBeanback to summary
private static final MemoryMXBean memoryMXBean
memoryPoolMXBeansback to summary
private static final List<MemoryPoolMXBean> memoryPoolMXBeans
operatingSystemMXBeanback to summary
private static final OperatingSystemMXBean operatingSystemMXBean
PACKAGEback to summary
private static final String PACKAGE
runtimeMXBeanback to summary
private static final RuntimeMXBean runtimeMXBean
smback to summary
private static final StringManager sm
threadMXBeanback to summary
private static final ThreadMXBean threadMXBean
timeformatback to summary
private static final SimpleDateFormat timeformat
vminfoSystemPropertyback to summary
private static final String vminfoSystemProperty

Constructor Detail

Diagnosticsback to summary
public Diagnostics()

Method Detail

findDeadlockback to summary
public static String findDeadlock()

Check if any threads are deadlocked. If any, print the thread dump for those threads.

Returns:String

a deadlock message and the formatted thread dump of the deadlocked threads

formatMemoryUsageback to summary
private static String formatMemoryUsage(String name, MemoryUsage usage)

Format contents of a MemoryUsage object.

Parameters
name:String

a text prefix used in formatting

usage:MemoryUsage

the MemoryUsage object to format

Returns:String

the formatted contents

gcback to summary
public static void gc()

Initiate garbage collection via MX Bean

getThreadDumpback to summary
private static String getThreadDump(ThreadInfo ti)

Formats the thread dump for one thread.

Parameters
ti:ThreadInfo

the ThreadInfo describing the thread

Returns:String

the formatted thread dump

getThreadDumpback to summary
private static String getThreadDump(ThreadInfo[] tinfos)

Formats the thread dump for a list of threads.

Parameters
tinfos:ThreadInfo[]

the ThreadInfo array describing the thread list

Returns:String

the formatted thread dump

getThreadDumpback to summary
public static String getThreadDump()

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

Returns:String

the formatted JVM thread dump

getThreadDumpback to summary
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:Enumeration<Locale>

list of locales to use

Returns:String

the formatted JVM thread dump

getThreadDumpback to summary
public static String getThreadDump(StringManager requestedSm)

Retrieve a JVM thread dump formatted using the given StringManager.

Parameters
requestedSm:StringManager

the StringManager to use

Returns:String

the formatted JVM thread dump

getThreadDumpHeaderback to summary
private static String getThreadDumpHeader(ThreadInfo ti)

Formats the thread dump header for one thread.

Parameters
ti:ThreadInfo

the ThreadInfo describing the thread

Returns:String

the formatted thread dump header

getVMInfoback to summary
public static String getVMInfo()

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

Returns:String

the formatted JVM information text

getVMInfoback to summary
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:Enumeration<Locale>

list of locales to use

Returns:String

the formatted JVM information text

getVMInfoback to summary
public static String getVMInfo(StringManager requestedSm)

Retrieve a JVM information text formatted using the given StringManager.

Parameters
requestedSm:StringManager

the StringManager to use

Returns:String

the formatted JVM information text

isThreadContentionMonitoringEnabledback to summary
public static boolean isThreadContentionMonitoringEnabled()

Check whether thread contention monitoring is enabled.

Returns:boolean

true if thread contention monitoring is enabled

isThreadCpuTimeEnabledback to summary
public static boolean isThreadCpuTimeEnabled()

Check whether thread cpu time measurement is enabled.

Returns:boolean

true if thread cpu time measurement is enabled

resetPeakThreadCountback to summary
public static void resetPeakThreadCount()

Reset peak thread count in ThreadMXBean

resetPeakUsageback to summary
public static void resetPeakUsage(String name)

Reset peak memory usage data in MemoryPoolMXBean

Parameters
name:String

name of the MemoryPoolMXBean or "all"

setCollectionUsageThresholdback to summary
public static boolean setCollectionUsageThreshold(String name, long threshold)

Set collection usage threshold in MemoryPoolMXBean

Parameters
name:String

name of the MemoryPoolMXBean

threshold:long

the collection threshold to set

Returns:boolean

true if setting the threshold succeeded

setLoggerLevelback to summary
public static void setLoggerLevel(String loggerName, String levelName)

Set logger level

Parameters
loggerName:String

the name of the logger

levelName:String

the level to set

setThreadContentionMonitoringEnabledback to summary
public static void setThreadContentionMonitoringEnabled(boolean enable)

Enable or disable thread contention monitoring via the ThreadMxMXBean.

Parameters
enable:boolean

whether to enable thread contention monitoring

setThreadCpuTimeEnabledback to summary
public static void setThreadCpuTimeEnabled(boolean enable)

Enable or disable thread cpu time measurement via the ThreadMxMXBean.

Parameters
enable:boolean

whether to enable thread cpu time measurement

setUsageThresholdback to summary
public static boolean setUsageThreshold(String name, long threshold)

Set usage threshold in MemoryPoolMXBean

Parameters
name:String

name of the MemoryPoolMXBean

threshold:long

the threshold to set

Returns:boolean

true if setting the threshold succeeded

setVerboseClassLoadingback to summary
public static void setVerboseClassLoading(boolean verbose)

Set verbose class loading

Parameters
verbose:boolean

whether to enable verbose class loading

setVerboseGarbageCollectionback to summary
public static void setVerboseGarbageCollection(boolean verbose)

Set verbose garbage collection logging

Parameters
verbose:boolean

whether to enable verbose gc logging