Search in sources :

Example 1 with DeadlockBo

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

the class GrpcDeadlockBoMapper method map.

public DeadlockBo map(final PDeadlock deadlock) {
    final DeadlockBo deadlockBo = new DeadlockBo();
    deadlockBo.setDeadlockedThreadCount(deadlock.getCount());
    final List<PThreadDump> threadDumpList = deadlock.getThreadDumpList();
    if (CollectionUtils.hasLength(threadDumpList)) {
        final List<ThreadDumpBo> threadDumpBoList = new ArrayList<>();
        for (PThreadDump threadDump : threadDumpList) {
            final ThreadDumpBo threadDumpBo = this.threadDumpBoMapper.map(threadDump);
            threadDumpBoList.add(threadDumpBo);
        }
        deadlockBo.setThreadDumpBoList(threadDumpBoList);
    }
    return deadlockBo;
}
Also used : DeadlockBo(com.navercorp.pinpoint.common.server.bo.event.DeadlockBo) ArrayList(java.util.ArrayList) ThreadDumpBo(com.navercorp.pinpoint.common.server.bo.event.ThreadDumpBo) PThreadDump(com.navercorp.pinpoint.grpc.trace.PThreadDump)

Example 2 with DeadlockBo

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

the class ThriftAgentEventMapperTest method simpleTest2.

@Test
public void simpleTest2() {
    final String agentId = "agentId";
    final long startTimestamp = Long.MAX_VALUE;
    final long eventTimestamp = startTimestamp;
    final TAgentStat agentStat = createAgentStat(agentId, startTimestamp, eventTimestamp, 0);
    DeadlockBo deadlockBo = new DeadlockBo();
    DeadlockEventBo expectedEventBo = new DeadlockEventBo(agentId, startTimestamp, eventTimestamp, AgentEventType.AGENT_DEADLOCK_DETECTED, deadlockBo);
    when(this.deadlockEventBoMapper.map(any(String.class), any(Long.class), any(Long.class), any(TDeadlock.class))).thenReturn(expectedEventBo);
    AgentEventBo actualEventBo = agentEventMapper.map(agentStat);
    Assert.assertNull(actualEventBo);
}
Also used : TDeadlock(com.navercorp.pinpoint.thrift.dto.TDeadlock) TAgentStat(com.navercorp.pinpoint.thrift.dto.TAgentStat) DeadlockBo(com.navercorp.pinpoint.common.server.bo.event.DeadlockBo) AgentEventBo(com.navercorp.pinpoint.common.server.bo.event.AgentEventBo) DeadlockEventBo(com.navercorp.pinpoint.common.server.bo.event.DeadlockEventBo) Test(org.junit.Test)

Example 3 with DeadlockBo

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

the class ThriftDeadlockBoMapper method map.

public DeadlockBo map(final TDeadlock tDeadlock) {
    final DeadlockBo deadlockBo = new DeadlockBo();
    deadlockBo.setDeadlockedThreadCount(tDeadlock.getDeadlockedThreadCount());
    if (tDeadlock.isSetDeadlockedThreadList()) {
        final List<ThreadDumpBo> threadDumpBoList = new ArrayList<>();
        for (TThreadDump threadDump : tDeadlock.getDeadlockedThreadList()) {
            final ThreadDumpBo threadDumpBo = this.threadDumpBoMapper.map(threadDump);
            threadDumpBoList.add(threadDumpBo);
        }
        deadlockBo.setThreadDumpBoList(threadDumpBoList);
    }
    return deadlockBo;
}
Also used : DeadlockBo(com.navercorp.pinpoint.common.server.bo.event.DeadlockBo) TThreadDump(com.navercorp.pinpoint.thrift.dto.command.TThreadDump) ArrayList(java.util.ArrayList) ThreadDumpBo(com.navercorp.pinpoint.common.server.bo.event.ThreadDumpBo)

Example 4 with DeadlockBo

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

the class AgentEventSerializer method serialize.

@Override
public void serialize(AgentEvent agentEvent, JsonGenerator jgen, SerializerProvider serializers) throws IOException {
    jgen.writeStartObject();
    if (agentEvent.getAgentId() != null) {
        jgen.writeStringField("agentId", agentEvent.getAgentId());
    }
    jgen.writeNumberField("startTimestamp", agentEvent.getStartTimestamp());
    jgen.writeNumberField("eventTimestamp", agentEvent.getEventTimestamp());
    jgen.writeNumberField("eventTypeCode", agentEvent.getEventTypeCode());
    if (agentEvent.getEventTypeDesc() != null) {
        jgen.writeStringField("eventTypeDesc", agentEvent.getEventTypeDesc());
    }
    jgen.writeBooleanField("hasEventMessage", agentEvent.hasEventMessage());
    if (agentEvent.getEventMessage() != null) {
        Object eventMessage = agentEvent.getEventMessage();
        if (eventMessage instanceof TDeadlock) {
            StringBuilder message = new StringBuilder();
            List<TThreadDump> deadlockedThreadList = ((TDeadlock) eventMessage).getDeadlockedThreadList();
            for (TThreadDump threadDump : deadlockedThreadList) {
                message.append(ThreadDumpUtils.createDumpMessage(threadDump));
            }
            jgen.writeObjectField("eventMessage", message.toString());
        } else if (eventMessage instanceof DeadlockBo) {
            final StringBuilder message = new StringBuilder();
            final List<ThreadDumpBo> threadDumpBoList = ((DeadlockBo) eventMessage).getThreadDumpBoList();
            for (ThreadDumpBo threadDump : threadDumpBoList) {
                message.append(ThreadDumpUtils.createDumpMessage(threadDump));
            }
            jgen.writeObjectField("eventMessage", message.toString());
        } else {
            jgen.writeObjectField("eventMessage", eventMessage);
        }
    }
    jgen.writeEndObject();
}
Also used : TDeadlock(com.navercorp.pinpoint.thrift.dto.TDeadlock) DeadlockBo(com.navercorp.pinpoint.common.server.bo.event.DeadlockBo) TThreadDump(com.navercorp.pinpoint.thrift.dto.command.TThreadDump) List(java.util.List) ThreadDumpBo(com.navercorp.pinpoint.common.server.bo.event.ThreadDumpBo)

Example 5 with DeadlockBo

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

the class ThriftAgentEventMapperTest method simpleTest1.

@Test
public void simpleTest1() {
    final String agentId = "agentId";
    final long startTimestamp = Long.MAX_VALUE;
    final long eventTimestamp = startTimestamp;
    final TAgentStat agentStat = createAgentStat(agentId, startTimestamp, eventTimestamp, 2);
    DeadlockBo deadlockBo = new DeadlockBo();
    deadlockBo.setDeadlockedThreadCount(agentStat.getDeadlock().getDeadlockedThreadCount());
    DeadlockEventBo expectedEventBo = new DeadlockEventBo(agentId, startTimestamp, eventTimestamp, AgentEventType.AGENT_DEADLOCK_DETECTED, deadlockBo);
    when(this.deadlockEventBoMapper.map(agentId, startTimestamp, startTimestamp, agentStat.getDeadlock())).thenReturn(expectedEventBo);
    AgentEventBo actualEventBo = agentEventMapper.map(agentStat);
    Assert.assertEquals(expectedEventBo, actualEventBo);
}
Also used : TAgentStat(com.navercorp.pinpoint.thrift.dto.TAgentStat) DeadlockBo(com.navercorp.pinpoint.common.server.bo.event.DeadlockBo) AgentEventBo(com.navercorp.pinpoint.common.server.bo.event.AgentEventBo) DeadlockEventBo(com.navercorp.pinpoint.common.server.bo.event.DeadlockEventBo) 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