Search in sources :

Example 6 with DeadlockBo

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

the class AgentEventMessageDeserializerV1 method deserializeDeadlockBo.

private DeadlockBo deserializeDeadlockBo(final byte[] eventBody) {
    final Buffer buffer = new FixedBuffer(eventBody);
    final int deadlockedThreadCount = buffer.readInt();
    final int threadDumpBoListSize = buffer.readVInt();
    final List<ThreadDumpBo> threadDumpBoList = new ArrayList<>(threadDumpBoListSize);
    if (threadDumpBoListSize > 0) {
        threadDumpBoList.add(readThreadDumpBo(buffer));
    }
    final DeadlockBo deadlockBo = new DeadlockBo();
    deadlockBo.setDeadlockedThreadCount(deadlockedThreadCount);
    deadlockBo.setThreadDumpBoList(threadDumpBoList);
    return deadlockBo;
}
Also used : FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) Buffer(com.navercorp.pinpoint.common.buffer.Buffer) DeadlockBo(com.navercorp.pinpoint.common.server.bo.event.DeadlockBo) FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) ArrayList(java.util.ArrayList) ThreadDumpBo(com.navercorp.pinpoint.common.server.bo.event.ThreadDumpBo)

Example 7 with DeadlockBo

use of com.navercorp.pinpoint.common.server.bo.event.DeadlockBo 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)

Aggregations

DeadlockBo (com.navercorp.pinpoint.common.server.bo.event.DeadlockBo)7 ThreadDumpBo (com.navercorp.pinpoint.common.server.bo.event.ThreadDumpBo)5 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)3 AgentEventBo (com.navercorp.pinpoint.common.server.bo.event.AgentEventBo)2 DeadlockEventBo (com.navercorp.pinpoint.common.server.bo.event.DeadlockEventBo)2 TAgentStat (com.navercorp.pinpoint.thrift.dto.TAgentStat)2 TDeadlock (com.navercorp.pinpoint.thrift.dto.TDeadlock)2 TThreadDump (com.navercorp.pinpoint.thrift.dto.command.TThreadDump)2 Buffer (com.navercorp.pinpoint.common.buffer.Buffer)1 FixedBuffer (com.navercorp.pinpoint.common.buffer.FixedBuffer)1 MonitorInfoBo (com.navercorp.pinpoint.common.server.bo.event.MonitorInfoBo)1 PThreadDump (com.navercorp.pinpoint.grpc.trace.PThreadDump)1 List (java.util.List)1