Search in sources :

Example 11 with AgentEventBo

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;
}
Also used : DurationalAgentEvent(com.navercorp.pinpoint.web.vo.DurationalAgentEvent) AgentEventBo(com.navercorp.pinpoint.common.server.bo.event.AgentEventBo) ArrayList(java.util.ArrayList) PriorityQueue(java.util.PriorityQueue) AgentEvent(com.navercorp.pinpoint.web.vo.AgentEvent) DurationalAgentEvent(com.navercorp.pinpoint.web.vo.DurationalAgentEvent)

Example 12 with AgentEventBo

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;
}
Also used : AgentEventBo(com.navercorp.pinpoint.common.server.bo.event.AgentEventBo) PAgentStat(com.navercorp.pinpoint.grpc.trace.PAgentStat) ArrayList(java.util.ArrayList) PDeadlock(com.navercorp.pinpoint.grpc.trace.PDeadlock)

Example 13 with AgentEventBo

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;
}
Also used : TDeadlock(com.navercorp.pinpoint.thrift.dto.TDeadlock) TAgentStat(com.navercorp.pinpoint.thrift.dto.TAgentStat) AgentEventBo(com.navercorp.pinpoint.common.server.bo.event.AgentEventBo) ArrayList(java.util.ArrayList)

Example 14 with AgentEventBo

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);
    }
}
Also used : Header(com.navercorp.pinpoint.grpc.Header) AgentEventBo(com.navercorp.pinpoint.common.server.bo.event.AgentEventBo)

Example 15 with AgentEventBo

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);
    }
}
Also used : Header(com.navercorp.pinpoint.grpc.Header) AgentEventBo(com.navercorp.pinpoint.common.server.bo.event.AgentEventBo)

Aggregations

AgentEventBo (com.navercorp.pinpoint.common.server.bo.event.AgentEventBo)20 AgentEventType (com.navercorp.pinpoint.common.server.util.AgentEventType)5 ArrayList (java.util.ArrayList)5 Test (org.junit.Test)5 TAgentStat (com.navercorp.pinpoint.thrift.dto.TAgentStat)3 TCommandTransfer (com.navercorp.pinpoint.thrift.dto.command.TCommandTransfer)3 TCommandTransferResponse (com.navercorp.pinpoint.thrift.dto.command.TCommandTransferResponse)3 ResponseEvent (com.navercorp.pinpoint.collector.cluster.route.ResponseEvent)2 DeadlockBo (com.navercorp.pinpoint.common.server.bo.event.DeadlockBo)2 DeadlockEventBo (com.navercorp.pinpoint.common.server.bo.event.DeadlockEventBo)2 Header (com.navercorp.pinpoint.grpc.Header)2 HeaderV1 (com.navercorp.pinpoint.io.header.v1.HeaderV1)2 DefaultMessage (com.navercorp.pinpoint.io.request.DefaultMessage)2 TDeadlock (com.navercorp.pinpoint.thrift.dto.TDeadlock)2 HeaderTBaseDeserializer (com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializer)2 AgentEvent (com.navercorp.pinpoint.web.vo.AgentEvent)2 TableName (org.apache.hadoop.hbase.TableName)2 TBase (org.apache.thrift.TBase)2 AgentProperty (com.navercorp.pinpoint.collector.service.async.AgentProperty)1 AgentPropertyChannelAdaptor (com.navercorp.pinpoint.collector.service.async.AgentPropertyChannelAdaptor)1