Search in sources :

Example 6 with MonitorInfoBo

use of com.navercorp.pinpoint.common.server.bo.event.MonitorInfoBo in project pinpoint by naver.

the class ThriftMonitorInfoBoMapper method map.

public MonitorInfoBo map(final TMonitorInfo monitorInfo) {
    final MonitorInfoBo monitorInfoBo = new MonitorInfoBo();
    monitorInfoBo.setStackDepth(monitorInfo.getStackDepth());
    monitorInfoBo.setStackFrame(monitorInfo.getStackFrame());
    return monitorInfoBo;
}
Also used : MonitorInfoBo(com.navercorp.pinpoint.common.server.bo.event.MonitorInfoBo)

Example 7 with MonitorInfoBo

use of com.navercorp.pinpoint.common.server.bo.event.MonitorInfoBo in project pinpoint by naver.

the class AgentEventMessageDeserializerV1 method readMonitorInfoBo.

private MonitorInfoBo readMonitorInfoBo(final Buffer buffer) {
    final int stackDepth = buffer.readInt();
    final String stackFrame = buffer.readPrefixedString();
    final MonitorInfoBo monitorInfoBo = new MonitorInfoBo();
    monitorInfoBo.setStackDepth(stackDepth);
    monitorInfoBo.setStackFrame(stackFrame);
    return monitorInfoBo;
}
Also used : MonitorInfoBo(com.navercorp.pinpoint.common.server.bo.event.MonitorInfoBo)

Example 8 with MonitorInfoBo

use of com.navercorp.pinpoint.common.server.bo.event.MonitorInfoBo in project pinpoint by naver.

the class AgentEventMessageSerializerV1 method putThreadDumpBo.

private void putThreadDumpBo(final Buffer buffer, final ThreadDumpBo threadDumpBo) {
    buffer.putPrefixedString(threadDumpBo.getThreadName());
    buffer.putLong(threadDumpBo.getThreadId());
    buffer.putLong(threadDumpBo.getBlockedTime());
    buffer.putLong(threadDumpBo.getBlockedCount());
    buffer.putLong(threadDumpBo.getWaitedTime());
    buffer.putLong(threadDumpBo.getWaitedCount());
    buffer.putPrefixedString(threadDumpBo.getLockName());
    buffer.putLong(threadDumpBo.getLockOwnerId());
    buffer.putPrefixedString(threadDumpBo.getLockOwnerName());
    buffer.putBoolean(threadDumpBo.isInNative());
    buffer.putBoolean(threadDumpBo.isSuspended());
    buffer.putInt(threadDumpBo.getThreadState().getValue());
    final int stackTraceSize = threadDumpBo.getStackTraceList() == null ? 0 : threadDumpBo.getStackTraceList().size();
    buffer.putVInt(stackTraceSize);
    if (stackTraceSize > 0) {
        for (String string : threadDumpBo.getStackTraceList()) {
            buffer.putPrefixedString(string);
        }
    }
    final int lockedMonitorListSize = threadDumpBo.getLockedMonitorInfoList() == null ? 0 : threadDumpBo.getLockedMonitorInfoList().size();
    buffer.putVInt(lockedMonitorListSize);
    if (lockedMonitorListSize > 0) {
        for (MonitorInfoBo monitorInfoBo : threadDumpBo.getLockedMonitorInfoList()) {
            putMonitorInfoBo(buffer, monitorInfoBo);
        }
    }
    final int lockedSynchronizerListSize = threadDumpBo.getLockedSynchronizerList() == null ? 0 : threadDumpBo.getLockedSynchronizerList().size();
    buffer.putVInt(lockedSynchronizerListSize);
    if (lockedSynchronizerListSize > 0) {
        for (String string : threadDumpBo.getLockedSynchronizerList()) {
            buffer.putPrefixedString(string);
        }
    }
}
Also used : MonitorInfoBo(com.navercorp.pinpoint.common.server.bo.event.MonitorInfoBo)

Example 9 with MonitorInfoBo

use of com.navercorp.pinpoint.common.server.bo.event.MonitorInfoBo in project pinpoint by naver.

the class AgentEventMessageSerializerV1Test method serialize.

@Test
public void serialize() throws Exception {
    AgentEventMessageSerializerV1 serializer = new AgentEventMessageSerializerV1();
    // Mock
    final DeadlockBo deadlockBo = new DeadlockBo();
    deadlockBo.setDeadlockedThreadCount(1);
    List<ThreadDumpBo> threadDumpBoList = new ArrayList<>();
    ThreadDumpBo threadDumpBo = new ThreadDumpBo();
    threadDumpBo.setThreadName("threadName");
    threadDumpBo.setThreadId(0);
    threadDumpBo.setBlockedTime(1);
    threadDumpBo.setBlockedCount(2);
    threadDumpBo.setWaitedTime(3);
    threadDumpBo.setWaitedCount(4);
    threadDumpBo.setLockName("lockName");
    threadDumpBo.setLockOwnerId(5);
    threadDumpBo.setLockOwnerName("lockOwnerName");
    threadDumpBo.setInNative(Boolean.TRUE);
    threadDumpBo.setSuspended(Boolean.FALSE);
    threadDumpBo.setThreadState(ThreadState.RUNNABLE);
    threadDumpBo.setStackTraceList(Arrays.asList("foo", "bar"));
    List<MonitorInfoBo> monitorInfoBoList = new ArrayList<>();
    MonitorInfoBo monitorInfoBo = new MonitorInfoBo();
    monitorInfoBo.setStackDepth(9);
    monitorInfoBo.setStackFrame("Frame");
    monitorInfoBoList.add(monitorInfoBo);
    threadDumpBo.setLockedMonitorInfoList(monitorInfoBoList);
    threadDumpBo.setLockedSynchronizerList(Arrays.asList("foo", "bar"));
    threadDumpBoList.add(threadDumpBo);
    deadlockBo.setThreadDumpBoList(threadDumpBoList);
    byte[] bytes = serializer.serialize(AgentEventType.AGENT_DEADLOCK_DETECTED, deadlockBo);
    // deserialize
    AgentEventMessageDeserializerV1 deserializer = new AgentEventMessageDeserializerV1();
    Object object = deserializer.deserialize(AgentEventType.AGENT_DEADLOCK_DETECTED, bytes);
    if (false == (object instanceof DeadlockBo)) {
        fail("Failed to deserialize, expected object is DeadlockBo");
    }
    DeadlockBo result = (DeadlockBo) object;
    assertEquals(1, result.getDeadlockedThreadCount());
    assertEquals(1, result.getThreadDumpBoList().size());
    assertThreadDumpBo(threadDumpBo, result.getThreadDumpBoList().get(0));
}
Also used : DeadlockBo(com.navercorp.pinpoint.common.server.bo.event.DeadlockBo) ArrayList(java.util.ArrayList) MonitorInfoBo(com.navercorp.pinpoint.common.server.bo.event.MonitorInfoBo) ThreadDumpBo(com.navercorp.pinpoint.common.server.bo.event.ThreadDumpBo) Test(org.junit.Test)

Example 10 with MonitorInfoBo

use of com.navercorp.pinpoint.common.server.bo.event.MonitorInfoBo in project pinpoint by naver.

the class AgentEventMessageSerializerV1Test method assertThreadDumpBo.

private void assertThreadDumpBo(ThreadDumpBo expectedThreadDumpBo, ThreadDumpBo threadDumpBo) {
    assertEquals(expectedThreadDumpBo.getThreadName(), threadDumpBo.getThreadName());
    assertEquals(expectedThreadDumpBo.getThreadId(), threadDumpBo.getThreadId());
    assertEquals(expectedThreadDumpBo.getBlockedTime(), threadDumpBo.getBlockedTime());
    assertEquals(expectedThreadDumpBo.getBlockedCount(), threadDumpBo.getBlockedCount());
    assertEquals(expectedThreadDumpBo.getWaitedTime(), threadDumpBo.getWaitedTime());
    assertEquals(expectedThreadDumpBo.getWaitedCount(), threadDumpBo.getWaitedCount());
    assertEquals(expectedThreadDumpBo.getLockName(), threadDumpBo.getLockName());
    assertEquals(expectedThreadDumpBo.getLockOwnerId(), threadDumpBo.getLockOwnerId());
    assertEquals(expectedThreadDumpBo.getLockOwnerName(), threadDumpBo.getLockOwnerName());
    assertEquals(expectedThreadDumpBo.isInNative(), threadDumpBo.isInNative());
    assertEquals(expectedThreadDumpBo.isSuspended(), threadDumpBo.isSuspended());
    assertEquals(expectedThreadDumpBo.getThreadState().getValue(), threadDumpBo.getThreadState().getValue());
    assertEquals(expectedThreadDumpBo.getStackTraceList().size(), threadDumpBo.getStackTraceList().size());
    for (int i = 0; i < expectedThreadDumpBo.getStackTraceList().size(); i++) {
        final String expectedStackTrace = expectedThreadDumpBo.getStackTraceList().get(i);
        final String stackTrace = threadDumpBo.getStackTraceList().get(i);
        assertEquals(expectedStackTrace, stackTrace);
    }
    assertEquals(expectedThreadDumpBo.getLockedMonitorInfoList().size(), threadDumpBo.getLockedMonitorInfoList().size());
    for (int i = 0; i < expectedThreadDumpBo.getLockedMonitorInfoList().size(); i++) {
        final MonitorInfoBo expectedMonitorInfoBo = expectedThreadDumpBo.getLockedMonitorInfoList().get(i);
        final MonitorInfoBo monitorInfoBo = threadDumpBo.getLockedMonitorInfoList().get(i);
        assertEquals(expectedMonitorInfoBo.getStackDepth(), monitorInfoBo.getStackDepth());
        assertEquals(expectedMonitorInfoBo.getStackFrame(), monitorInfoBo.getStackFrame());
    }
    assertEquals(expectedThreadDumpBo.getLockedSynchronizerList().size(), threadDumpBo.getLockedSynchronizerList().size());
    for (int i = 0; i < expectedThreadDumpBo.getLockedSynchronizerList().size(); i++) {
        final String expectedLockedSynchronizer = expectedThreadDumpBo.getLockedSynchronizerList().get(i);
        final String lockedSynchronizer = threadDumpBo.getLockedSynchronizerList().get(i);
        assertEquals(expectedLockedSynchronizer, lockedSynchronizer);
    }
}
Also used : MonitorInfoBo(com.navercorp.pinpoint.common.server.bo.event.MonitorInfoBo)

Aggregations

MonitorInfoBo (com.navercorp.pinpoint.common.server.bo.event.MonitorInfoBo)10 ThreadDumpBo (com.navercorp.pinpoint.common.server.bo.event.ThreadDumpBo)4 ArrayList (java.util.ArrayList)4 TThreadState (com.navercorp.pinpoint.thrift.dto.command.TThreadState)2 DeadlockBo (com.navercorp.pinpoint.common.server.bo.event.DeadlockBo)1 ThreadState (com.navercorp.pinpoint.common.server.bo.event.ThreadState)1 PMonitorInfo (com.navercorp.pinpoint.grpc.trace.PMonitorInfo)1 PThreadState (com.navercorp.pinpoint.grpc.trace.PThreadState)1 TMonitorInfo (com.navercorp.pinpoint.thrift.dto.command.TMonitorInfo)1 Test (org.junit.Test)1