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;
}
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);
}
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;
}
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();
}
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);
}
Aggregations