Package jetbrains.buildServer.util
Class DiagnosticUtil
- java.lang.Object
-
- jetbrains.buildServer.util.DiagnosticUtil
-
public class DiagnosticUtil extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DiagnosticUtil.NodeInfo
static interface
DiagnosticUtil.Printer
static class
DiagnosticUtil.ThreadDumpData
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DIR_PREFIX
static java.lang.String
FILE_DATE_FORMAT
static java.lang.String
TC_TOTAL_MEMORY_USAGE_KEY
static java.lang.String
THREAD_DUMP_DATE_PATTERN
static java.lang.String
THREAD_DUMP_EXTENSION
static java.lang.String
THREAD_DUMP_PREFIX
-
Constructor Summary
Constructors Constructor Description DiagnosticUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static java.lang.StringBuilder
appendCurrentThreadStacktrace(java.lang.StringBuilder sb)
static java.io.File
getAutomaticThreadDumpsSubdirectory(java.io.File baseDir)
static java.io.File
getDiagnosticFile(java.io.File baseDir, java.lang.String suffix, java.lang.String ext)
static java.lang.String
getFriendlyTimeZone()
static java.lang.management.MemoryUsage
getHeapMemoryUsage()
static java.lang.String
getJavaDetails()
static java.util.List<java.lang.String>
getJVMArgs()
static java.lang.String
getJVMArgsString()
static java.lang.String
getJVMDiagnosticString()
static java.lang.String
getJVMName()
static long
getMaxPoolSize(java.lang.String key)
static java.util.List<java.lang.management.MemoryPoolMXBean>
getMemoryUsageBeans()
static java.lang.String
getOsEnvironmentDetails()
static java.lang.management.MemoryUsage
getPermGenPoolMemoryUsage()
static java.text.SimpleDateFormat
getThreadDumpDateFormat()
static java.lang.String
getUser()
static boolean
isPermGenPool(java.lang.String name)
static java.io.File
memoryDump(java.io.File hprofDir)
Deprecated.Useinstead
static java.io.File
memoryDump(java.io.File dir, boolean zip, java.lang.String requestorData, com.intellij.openapi.diagnostic.Logger logger)
Takes hprof and logs the result into the passed loggerstatic boolean
memoryDumpAvailable()
static java.io.File
memoryDumpZipped(java.io.File dir)
Deprecated.Useinstead
static void
printCpuUsage(DiagnosticUtil.Printer out, DiagnosticUtil.ThreadDumpData data)
static void
printCpuUsage(DiagnosticUtil.Printer out, DiagnosticUtil.ThreadDumpData data, java.util.Date currentTime)
static void
printMemoryUsage(DiagnosticUtil.Printer out)
static void
printServerStatistics(DiagnosticUtil.Printer out, DiagnosticUtil.ThreadDumpData data)
static java.io.File
threadDumpToDirectory(java.io.File dir, java.lang.String suffix, DiagnosticUtil.ThreadDumpData data)
static java.io.File
threadDumpToDirectory(java.io.File dir, DiagnosticUtil.ThreadDumpData data)
static java.io.File
threadDumpToFile(java.io.File file, DiagnosticUtil.ThreadDumpData data)
static void
threadDumpToStream(java.io.PrintStream out)
Shouldn't be used for streaming thread dump to log.static void
threadDumpToStream(java.io.PrintWriter out)
Shouldn't be used for streaming thread dump to log.static void
threadDumpToStream(java.io.PrintWriter out, DiagnosticUtil.ThreadDumpData threadDumpData)
static java.lang.String
threadDumpToString()
Shouldn't be used for streaming thread dump to log.static java.lang.String
threadDumpToString(DiagnosticUtil.ThreadDumpData data)
Shouldn't be used for streaming thread dump to log.static java.io.File
writeThreadDump(java.io.File baseDir, java.lang.String threadDump)
-
-
-
Field Detail
-
FILE_DATE_FORMAT
public static final java.lang.String FILE_DATE_FORMAT
- See Also:
- Constant Field Values
-
THREAD_DUMP_PREFIX
public static final java.lang.String THREAD_DUMP_PREFIX
- See Also:
- Constant Field Values
-
THREAD_DUMP_EXTENSION
public static final java.lang.String THREAD_DUMP_EXTENSION
- See Also:
- Constant Field Values
-
TC_TOTAL_MEMORY_USAGE_KEY
public static final java.lang.String TC_TOTAL_MEMORY_USAGE_KEY
- See Also:
- Constant Field Values
-
THREAD_DUMP_DATE_PATTERN
public static final java.lang.String THREAD_DUMP_DATE_PATTERN
- See Also:
- Constant Field Values
-
DIR_PREFIX
public static final java.lang.String DIR_PREFIX
- See Also:
- Constant Field Values
-
-
Method Detail
-
threadDumpToStream
public static void threadDumpToStream(@NotNull java.io.PrintStream out)
Shouldn't be used for streaming thread dump to log. All thread dumps should be saved to a separate file in the log directory. To be used in web request and tests only- Parameters:
out
- stream to write dump to- See Also:
threadDumpToDirectory(File, ThreadDumpData)
-
threadDumpToStream
public static void threadDumpToStream(@NotNull java.io.PrintWriter out)
Shouldn't be used for streaming thread dump to log. All thread dumps should be saved to a separate file in the log directory. To be used in web request and tests only- Parameters:
out
- writer to write dump to- See Also:
threadDumpToDirectory(File, ThreadDumpData)
-
threadDumpToStream
public static void threadDumpToStream(@NotNull java.io.PrintWriter out, @NotNull DiagnosticUtil.ThreadDumpData threadDumpData)
-
threadDumpToDirectory
public static java.io.File threadDumpToDirectory(@Nullable java.io.File dir, @Nullable java.lang.String suffix, @NotNull DiagnosticUtil.ThreadDumpData data)
-
threadDumpToDirectory
public static java.io.File threadDumpToDirectory(@Nullable java.io.File dir, @NotNull DiagnosticUtil.ThreadDumpData data)
-
threadDumpToFile
public static java.io.File threadDumpToFile(@NotNull java.io.File file, @NotNull DiagnosticUtil.ThreadDumpData data)
-
writeThreadDump
public static java.io.File writeThreadDump(@NotNull java.io.File baseDir, @NotNull java.lang.String threadDump)
-
getAutomaticThreadDumpsSubdirectory
public static java.io.File getAutomaticThreadDumpsSubdirectory(@NotNull java.io.File baseDir) throws java.io.IOException
- Throws:
java.io.IOException
-
getDiagnosticFile
public static java.io.File getDiagnosticFile(@Nullable java.io.File baseDir, @NotNull java.lang.String suffix, @NotNull java.lang.String ext)
-
threadDumpToString
@NotNull public static java.lang.String threadDumpToString()
Shouldn't be used for streaming thread dump to log. All thread dumps should be saved to a separate file in the log directory. To be used in tests only- Returns:
- thread dump
-
threadDumpToString
@NotNull public static java.lang.String threadDumpToString(@NotNull DiagnosticUtil.ThreadDumpData data)
Shouldn't be used for streaming thread dump to log. All thread dumps should be saved to a separate file in the log directory. To be used in request and tests only. Is also used in SQL exception handling.- Parameters:
data
- thread dump data- Returns:
- thread dump
-
printServerStatistics
public static void printServerStatistics(DiagnosticUtil.Printer out, DiagnosticUtil.ThreadDumpData data)
-
printMemoryUsage
public static void printMemoryUsage(DiagnosticUtil.Printer out)
-
printCpuUsage
public static void printCpuUsage(DiagnosticUtil.Printer out, DiagnosticUtil.ThreadDumpData data)
-
printCpuUsage
public static void printCpuUsage(DiagnosticUtil.Printer out, DiagnosticUtil.ThreadDumpData data, java.util.Date currentTime)
-
getHeapMemoryUsage
@NotNull public static java.lang.management.MemoryUsage getHeapMemoryUsage()
-
getPermGenPoolMemoryUsage
@Nullable public static java.lang.management.MemoryUsage getPermGenPoolMemoryUsage()
-
isPermGenPool
public static boolean isPermGenPool(java.lang.String name)
-
getMemoryUsageBeans
public static java.util.List<java.lang.management.MemoryPoolMXBean> getMemoryUsageBeans()
-
getMaxPoolSize
public static long getMaxPoolSize(java.lang.String key)
-
appendCurrentThreadStacktrace
@NotNull public static java.lang.StringBuilder appendCurrentThreadStacktrace(@NotNull java.lang.StringBuilder sb)
-
getThreadDumpDateFormat
public static java.text.SimpleDateFormat getThreadDumpDateFormat()
-
memoryDumpAvailable
public static boolean memoryDumpAvailable()
- Returns:
- true iff JVM supports memory dump capture
- Since:
- 8.0
-
memoryDump
@NotNull public static java.io.File memoryDump(@Nullable java.io.File hprofDir) throws java.lang.Exception
Deprecated.Useinstead
Takes JVM memory dump- Parameters:
hprofDir
- directory to write dump. It's required ~ 2*heap-size of free space- Returns:
- path to saved .hprof
- Throws:
java.lang.Exception
- on error or if memory dump is not supported- Since:
- 8.0
-
memoryDump
@NotNull public static java.io.File memoryDump(@Nullable java.io.File dir, boolean zip, @NotNull java.lang.String requestorData, @NotNull com.intellij.openapi.diagnostic.Logger logger) throws java.lang.Exception
Takes hprof and logs the result into the passed logger- Parameters:
dir
- path to write file. If zip is used, it's required ~ 2*heap-size of free spacezip
- to archived dump or leave as it isrequestorData
- text describing why the dump is created to be used in the logginglogger
- logger to log success/failure messages to- Returns:
- path to created dump file
- Throws:
java.lang.Exception
- on error or if memory dump is not supported- Since:
- 2019.2.1
-
memoryDumpZipped
@NotNull public static java.io.File memoryDumpZipped(@Nullable java.io.File dir) throws java.lang.Exception
Deprecated.Useinstead
Takes hprof and than zips it- Parameters:
dir
- path to write file. It's required ~ 2*heap-size of free space- Returns:
- path to created dump file
- Throws:
java.lang.Exception
- on error or if memory dump is not supported- Since:
- 8.0
-
getJVMArgs
@NotNull public static java.util.List<java.lang.String> getJVMArgs()
-
getJVMArgsString
@NotNull public static java.lang.String getJVMArgsString()
-
getUser
public static java.lang.String getUser()
- Returns:
- Current username
-
getJavaDetails
public static java.lang.String getJavaDetails()
-
getJVMDiagnosticString
@NotNull public static java.lang.String getJVMDiagnosticString()
- Returns:
- String containing JVM info: version, bitness, vendor
-
getJVMName
@NotNull public static java.lang.String getJVMName()
-
getOsEnvironmentDetails
@NotNull public static java.lang.String getOsEnvironmentDetails()
-
getFriendlyTimeZone
public static java.lang.String getFriendlyTimeZone()
-
-