Search in sources :

Example 1 with ThreadDumpGenerator

use of com.exactprosystems.clearth.utils.ThreadDumpGenerator in project clearth by exactpro.

the class LogsBean method getThreadDumps.

// *** Thread dumps routines ***
public StreamedContent getThreadDumps() {
    if (!logsDir.exists())
        return null;
    try {
        if (!outputDir.exists())
            outputDir.mkdir();
        ThreadDumpGenerator threadDumpGenerator = new ThreadDumpGenerator();
        File result = threadDumpGenerator.writeThreadDump(outputDir, UserInfoUtils.getUserName() + "_thread_dump.txt");
        result.deleteOnExit();
        return new DefaultStreamedContent(new FileInputStream(result), new MimetypesFileTypeMap().getContentType(result), "thread_dump.txt");
    } catch (Exception e) {
        String msg = "Could not generate thread dumps";
        getLogger().error(msg, e);
        MessageUtils.addErrorMessage(msg, ExceptionUtils.getDetailedMessage(e));
        return null;
    }
}
Also used : DefaultStreamedContent(org.primefaces.model.DefaultStreamedContent) MimetypesFileTypeMap(javax.activation.MimetypesFileTypeMap) ThreadDumpGenerator(com.exactprosystems.clearth.utils.ThreadDumpGenerator) File(java.io.File) FileInputStream(java.io.FileInputStream) IOException(java.io.IOException)

Aggregations

ThreadDumpGenerator (com.exactprosystems.clearth.utils.ThreadDumpGenerator)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 MimetypesFileTypeMap (javax.activation.MimetypesFileTypeMap)1 DefaultStreamedContent (org.primefaces.model.DefaultStreamedContent)1