Package jetbrains.buildServer.util
Class DiagnosticUtil
- java.lang.Object
-
- jetbrains.buildServer.util.DiagnosticUtil
-
public class DiagnosticUtil extends 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 String
DIR_PREFIX
static String
FILE_DATE_FORMAT
static String
TC_TOTAL_MEMORY_USAGE_KEY
static String
THREAD_DUMP_DATE_PATTERN
static String
THREAD_DUMP_EXTENSION
static String
THREAD_DUMP_PREFIX
-
Constructor Summary
Constructors Constructor Description DiagnosticUtil()
-
Method Summary
-
-
-
Field Detail
-
FILE_DATE_FORMAT
public static final String FILE_DATE_FORMAT
- See Also:
- Constant Field Values
-
THREAD_DUMP_PREFIX
public static final String THREAD_DUMP_PREFIX
- See Also:
- Constant Field Values
-
THREAD_DUMP_EXTENSION
public static final String THREAD_DUMP_EXTENSION
- See Also:
- Constant Field Values
-
TC_TOTAL_MEMORY_USAGE_KEY
public static final String TC_TOTAL_MEMORY_USAGE_KEY
- See Also:
- Constant Field Values
-
THREAD_DUMP_DATE_PATTERN
public static final String THREAD_DUMP_DATE_PATTERN
- See Also:
- Constant Field Values
-
DIR_PREFIX
public static final String DIR_PREFIX
- See Also:
- Constant Field Values
-
-
Method Detail
-
threadDumpToStream
public static void threadDumpToStream(@NotNull 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 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 PrintWriter out, @NotNull DiagnosticUtil.ThreadDumpData threadDumpData)
-
threadDumpToDirectory
public static File threadDumpToDirectory(@Nullable File dir, @Nullable String suffix, @NotNull DiagnosticUtil.ThreadDumpData data)
-
threadDumpToDirectory
public static File threadDumpToDirectory(@Nullable File dir, @NotNull DiagnosticUtil.ThreadDumpData data)
-
threadDumpToFile
public static File threadDumpToFile(@NotNull File file, @NotNull DiagnosticUtil.ThreadDumpData data)
-
writeThreadDump
public static File writeThreadDump(@NotNull File baseDir, @NotNull String threadDump)
-
getAutomaticThreadDumpsSubdirectory
public static File getAutomaticThreadDumpsSubdirectory(@NotNull File baseDir) throws IOException
- Throws:
IOException
-
getDiagnosticFile
public static File getDiagnosticFile(@Nullable File baseDir, @NotNull String suffix, @NotNull String ext)
-
threadDumpToString
@NotNull public static 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 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, Date currentTime)
-
getHeapMemoryUsage
@NotNull public static MemoryUsage getHeapMemoryUsage()
-
getPermGenPoolMemoryUsage
@Nullable public static MemoryUsage getPermGenPoolMemoryUsage()
-
isPermGenPool
public static boolean isPermGenPool(String name)
-
getMemoryUsageBeans
public static List<MemoryPoolMXBean> getMemoryUsageBeans()
-
getMaxPoolSize
public static long getMaxPoolSize(String key)
-
appendCurrentThreadStacktrace
@NotNull public static StringBuilder appendCurrentThreadStacktrace(@NotNull StringBuilder sb)
-
getThreadDumpDateFormat
public static SimpleDateFormat getThreadDumpDateFormat()
-
memoryDumpAvailable
public static boolean memoryDumpAvailable()
- Returns:
- true iff JVM supports memory dump capture
- Since:
- 8.0
-
memoryDump
@NotNull public static File memoryDump(@Nullable File hprofDir) throws 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:
Exception
- on error or if memory dump is not supported- Since:
- 8.0
-
memoryDump
@NotNull public static File memoryDump(@Nullable File dir, boolean zip, @NotNull String requestorData, @NotNull Logger logger) throws 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:
Exception
- on error or if memory dump is not supported- Since:
- 2019.2.1
-
memoryDumpZipped
@NotNull public static File memoryDumpZipped(@Nullable File dir) throws 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:
Exception
- on error or if memory dump is not supported- Since:
- 8.0
-
getJVMArgsString
@NotNull public static String getJVMArgsString()
-
getUser
public static String getUser()
- Returns:
- Current username
-
getJavaDetails
public static String getJavaDetails()
-
getJVMDiagnosticString
@NotNull public static String getJVMDiagnosticString()
- Returns:
- String containing JVM info: version, bitness, vendor
-
getJVMName
@NotNull public static String getJVMName()
-
getOsEnvironmentDetails
@NotNull public static String getOsEnvironmentDetails()
-
getFriendlyTimeZone
public static String getFriendlyTimeZone()
-
-