Class DiagnosticUtil


  • public class DiagnosticUtil
    extends Object
    • Constructor Detail

      • DiagnosticUtil

        public DiagnosticUtil()
    • 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)
      • 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
      • getHeapMemoryUsage

        @NotNull
        public static MemoryUsage getHeapMemoryUsage()
      • getPermGenPoolMemoryUsage

        @Nullable
        public static MemoryUsage getPermGenPoolMemoryUsage()
      • isPermGenPool

        public static boolean isPermGenPool​(String name)
      • 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.
        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 space
        zip - to archived dump or leave as it is
        requestorData - text describing why the dump is created to be used in the logging
        logger - 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.
        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
      • getJVMArgs

        @NotNull
        public static List<String> getJVMArgs()
      • 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()