Search in sources :

Example 1 with TMonitorInfo

use of com.navercorp.pinpoint.thrift.dto.command.TMonitorInfo in project pinpoint by naver.

the class ThreadDumpUtils method setMonitorInfo.

private static void setMonitorInfo(TThreadDump threadDump, ThreadInfo threadInfo) {
    MonitorInfo[] monitorInfos = threadInfo.getLockedMonitors();
    if (monitorInfos != null) {
        for (MonitorInfo each : monitorInfos) {
            if (each == null) {
                continue;
            }
            TMonitorInfo tMonitorInfo = new TMonitorInfo();
            tMonitorInfo.setStackDepth(each.getLockedStackDepth());
            tMonitorInfo.setStackFrame(each.getLockedStackFrame().toString());
            threadDump.addToLockedMonitors(tMonitorInfo);
        }
    } else {
        threadDump.setLockedMonitors(Collections.<TMonitorInfo>emptyList());
    }
}
Also used : TMonitorInfo(com.navercorp.pinpoint.thrift.dto.command.TMonitorInfo) MonitorInfo(java.lang.management.MonitorInfo) TMonitorInfo(com.navercorp.pinpoint.thrift.dto.command.TMonitorInfo)

Example 2 with TMonitorInfo

use of com.navercorp.pinpoint.thrift.dto.command.TMonitorInfo in project pinpoint by naver.

the class AgentActiveThreadDumpFactory method createDumpMessage.

public String createDumpMessage(TThreadDump threadDump) {
    TThreadState threadState = getThreadState(threadDump.getThreadState());
    // set threadName
    StringBuilder message = new StringBuilder("\"" + threadDump.getThreadName() + "\"");
    // set threadId
    String hexStringThreadId = Long.toHexString(threadDump.getThreadId());
    message.append(" Id=0x" + hexStringThreadId);
    // set threadState
    message.append(" " + threadState.name());
    if (!StringUtils.isBlank(threadDump.getLockName())) {
        message.append(" on ").append(threadDump.getLockName());
    }
    if (!StringUtils.isBlank(threadDump.getLockOwnerName())) {
        message.append(" owned by \"").append(threadDump.getLockOwnerName()).append("\" Id=").append(threadDump.getLockOwnerId());
    }
    if (threadDump.isSuspended()) {
        message.append(" (suspended)");
    }
    if (threadDump.isInNative()) {
        message.append(" (in native)");
    }
    message.append(LINE_SEPARATOR);
    // set StackTrace
    for (int i = 0; i < threadDump.getStackTraceSize(); i++) {
        String stackTrace = threadDump.getStackTrace().get(i);
        message.append(TAB_SEPARATOR + "at ").append(stackTrace);
        message.append(LINE_SEPARATOR);
        if (i == 0 && !StringUtils.isBlank(threadDump.getLockName())) {
            switch(threadState) {
                case BLOCKED:
                    message.append(TAB_SEPARATOR + "-  blocked on ").append(threadDump.getLockName());
                    message.append(LINE_SEPARATOR);
                    break;
                case WAITING:
                    message.append(TAB_SEPARATOR + "-  waiting on ").append(threadDump.getLockName());
                    message.append(LINE_SEPARATOR);
                    break;
                case TIMED_WAITING:
                    message.append(TAB_SEPARATOR + "-  waiting on ").append(threadDump.getLockName());
                    message.append(LINE_SEPARATOR);
                    break;
                default:
            }
        }
        if (threadDump.getLockedMonitors() != null) {
            for (TMonitorInfo lockedMonitor : threadDump.getLockedMonitors()) {
                if (lockedMonitor.getStackDepth() == i) {
                    message.append(TAB_SEPARATOR + "-  locked ").append(lockedMonitor.getStackFrame());
                    message.append(LINE_SEPARATOR);
                }
            }
        }
    }
    // set Locks
    List<String> lockedSynchronizers = threadDump.getLockedSynchronizers();
    if (!CollectionUtils.isEmpty(lockedSynchronizers)) {
        message.append(LINE_SEPARATOR + TAB_SEPARATOR + "Number of locked synchronizers = ").append(lockedSynchronizers.size());
        message.append(LINE_SEPARATOR);
        for (String lockedSynchronizer : lockedSynchronizers) {
            message.append(TAB_SEPARATOR + "- ").append(lockedSynchronizer);
            message.append(LINE_SEPARATOR);
        }
    }
    message.append(LINE_SEPARATOR);
    return message.toString();
}
Also used : TThreadState(com.navercorp.pinpoint.thrift.dto.command.TThreadState) TMonitorInfo(com.navercorp.pinpoint.thrift.dto.command.TMonitorInfo)

Example 3 with TMonitorInfo

use of com.navercorp.pinpoint.thrift.dto.command.TMonitorInfo in project pinpoint by naver.

the class AgentEventMessageSerDesTest method createTThreadDump.

private TThreadDump createTThreadDump(ThreadInfo info) {
    TThreadDump dump = new TThreadDump();
    dump.setThreadName(info.getThreadName());
    dump.setThreadId(info.getThreadId());
    dump.setBlockedTime(info.getBlockedTime());
    dump.setBlockedCount(info.getBlockedCount());
    dump.setWaitedTime(info.getWaitedTime());
    dump.setWaitedCount(info.getWaitedCount());
    dump.setLockName(info.getLockName());
    dump.setLockOwnerId(info.getLockOwnerId());
    dump.setLockOwnerName(info.getLockOwnerName());
    dump.setInNative(info.isInNative());
    dump.setSuspended(info.isSuspended());
    dump.setThreadState(getThreadState(info));
    StackTraceElement[] stackTraceElements = info.getStackTrace();
    for (StackTraceElement each : stackTraceElements) {
        dump.addToStackTrace(each.toString());
    }
    MonitorInfo[] monitorInfos = info.getLockedMonitors();
    for (MonitorInfo each : monitorInfos) {
        TMonitorInfo tMonitorInfo = new TMonitorInfo();
        tMonitorInfo.setStackDepth(each.getLockedStackDepth());
        tMonitorInfo.setStackFrame(each.getLockedStackFrame().toString());
        dump.addToLockedMonitors(tMonitorInfo);
    }
    LockInfo[] lockInfos = info.getLockedSynchronizers();
    for (LockInfo lockInfo : lockInfos) {
        dump.addToLockedSynchronizers(lockInfo.toString());
    }
    return dump;
}
Also used : TMonitorInfo(com.navercorp.pinpoint.thrift.dto.command.TMonitorInfo) MonitorInfo(java.lang.management.MonitorInfo) TMonitorInfo(com.navercorp.pinpoint.thrift.dto.command.TMonitorInfo) TThreadDump(com.navercorp.pinpoint.thrift.dto.command.TThreadDump) LockInfo(java.lang.management.LockInfo)

Aggregations

TMonitorInfo (com.navercorp.pinpoint.thrift.dto.command.TMonitorInfo)3 MonitorInfo (java.lang.management.MonitorInfo)2 TThreadDump (com.navercorp.pinpoint.thrift.dto.command.TThreadDump)1 TThreadState (com.navercorp.pinpoint.thrift.dto.command.TThreadState)1 LockInfo (java.lang.management.LockInfo)1