use of com.navercorp.pinpoint.common.server.bo.event.AgentEventBo in project pinpoint by naver.
the class AgentEventServiceImpl method createAgentEvents.
private List<AgentEvent> createAgentEvents(List<AgentEventBo> agentEventBos) {
if (CollectionUtils.isEmpty(agentEventBos)) {
return Collections.emptyList();
}
List<AgentEvent> agentEvents = new ArrayList<>(agentEventBos.size());
PriorityQueue<DurationalAgentEvent> durationalAgentEvents = new PriorityQueue<>(agentEventBos.size(), AgentEvent.EVENT_TIMESTAMP_ASC_COMPARATOR);
for (AgentEventBo agentEventBo : agentEventBos) {
if (agentEventBo.getEventType().isCategorizedAs(AgentEventTypeCategory.DURATIONAL)) {
durationalAgentEvents.add(createDurationalAgentEvent(agentEventBo, false));
} else {
boolean hasMessage = ArrayUtils.hasLength(agentEventBo.getEventBody());
agentEvents.add(createAgentEvent(agentEventBo, hasMessage));
}
}
long durationStartTimestamp = DurationalAgentEvent.UNKNOWN_TIMESTAMP;
while (!durationalAgentEvents.isEmpty()) {
DurationalAgentEvent currentEvent = durationalAgentEvents.remove();
if (durationStartTimestamp == DurationalAgentEvent.UNKNOWN_TIMESTAMP) {
durationStartTimestamp = currentEvent.getEventTimestamp();
}
currentEvent.setDurationStartTimestamp(durationStartTimestamp);
DurationalAgentEvent nextEvent = durationalAgentEvents.peek();
if (nextEvent != null) {
long nextEventTimestamp = nextEvent.getEventTimestamp();
currentEvent.setDurationEndTimestamp(nextEventTimestamp);
durationStartTimestamp = nextEventTimestamp;
}
agentEvents.add(currentEvent);
}
return agentEvents;
}
use of com.navercorp.pinpoint.common.server.bo.event.AgentEventBo in project pinpoint by naver.
the class GrpcAgentEventBatchMapper method map.
public List<AgentEventBo> map(final PAgentStatBatch agentStatBatch, final Header header) {
final String agentId = header.getAgentId();
final long startTimestamp = header.getAgentStartTime();
final List<PAgentStat> agentStats = agentStatBatch.getAgentStatList();
if (CollectionUtils.isEmpty(agentStats)) {
return Collections.emptyList();
}
final List<AgentEventBo> agentEventBoList = new ArrayList<>(agentStats.size());
for (PAgentStat agentStat : agentStats) {
if (agentStat.hasDeadlock()) {
final long timestamp = agentStat.getTimestamp();
final PDeadlock deadlock = agentStat.getDeadlock();
if (CollectionUtils.hasLength(deadlock.getThreadDumpList())) {
agentEventBoList.add(deadlockEventBoMapper.map(agentId, startTimestamp, timestamp, deadlock));
}
}
}
return agentEventBoList;
}
use of com.navercorp.pinpoint.common.server.bo.event.AgentEventBo in project pinpoint by naver.
the class ThriftAgentEventBatchMapper method map.
public List<AgentEventBo> map(TAgentStatBatch tAgentStatBatch) {
if (tAgentStatBatch == null) {
return Collections.emptyList();
}
final List<TAgentStat> agentStats = tAgentStatBatch.getAgentStats();
if (CollectionUtils.isEmpty(agentStats)) {
return Collections.emptyList();
}
final String agentId = tAgentStatBatch.getAgentId();
final long startTimestamp = tAgentStatBatch.getStartTimestamp();
List<AgentEventBo> agentEventBoList = new ArrayList<>(agentStats.size());
for (TAgentStat tAgentStat : agentStats) {
final long timestamp = tAgentStat.getTimestamp();
if (tAgentStat.isSetDeadlock()) {
TDeadlock deadlock = tAgentStat.getDeadlock();
if (deadlock != null && deadlock.isSetDeadlockedThreadList()) {
agentEventBoList.add(deadlockEventBoMapper.map(agentId, startTimestamp, timestamp, deadlock));
}
}
}
return agentEventBoList;
}
use of com.navercorp.pinpoint.common.server.bo.event.AgentEventBo in project pinpoint by naver.
the class GrpcAgentEventHandler method handleAgentStatBatch.
private void handleAgentStatBatch(PAgentStatBatch agentStatBatch) {
if (logger.isDebugEnabled()) {
logger.debug("Handle PAgentStatBatch={}", MessageFormatUtils.debugLog(agentStatBatch));
}
final Header header = ServerContext.getAgentInfo();
final List<AgentEventBo> agentEventBoList = this.agentEventBatchMapper.map(agentStatBatch, header);
if (CollectionUtils.isEmpty(agentEventBoList)) {
return;
}
try {
for (AgentEventBo agentEventBo : agentEventBoList) {
insert(agentEventBo);
}
} catch (Exception e) {
logger.warn("Failed to handle agentStatBatch={}", MessageFormatUtils.debugLog(agentStatBatch), e);
}
}
use of com.navercorp.pinpoint.common.server.bo.event.AgentEventBo in project pinpoint by naver.
the class GrpcAgentEventHandler method handleAgentStat.
private void handleAgentStat(PAgentStat agentStat) {
if (logger.isDebugEnabled()) {
logger.debug("Handle PAgentStat={}", MessageFormatUtils.debugLog(agentStat));
}
final Header header = ServerContext.getAgentInfo();
final AgentEventBo agentEventBo = this.agentEventMapper.map(agentStat, header);
if (agentEventBo == null) {
return;
}
try {
insert(agentEventBo);
} catch (Exception e) {
logger.warn("Failed to handle agentStat={}", MessageFormatUtils.debugLog(agentStat), e);
}
}
Aggregations