Search in sources :

Example 1 with AgentEvent

use of com.navercorp.pinpoint.web.vo.AgentEvent in project pinpoint by naver.

the class AgentStatusTimelineBuilder method createAgentLifeCycle.

private AgentLifeCycle createAgentLifeCycle(long agentStartTimestamp, List<AgentEvent> agentEvents) {
    Collections.sort(agentEvents, AgentEvent.EVENT_TIMESTAMP_ASC_COMPARATOR);
    AgentEvent first = agentEvents.get(0);
    AgentEvent last = agentEvents.get(agentEvents.size() - 1);
    AgentState endState = AgentState.fromAgentEvent(last);
    long startTimestamp = first.getStartTimestamp();
    if (agentStartTimestamp <= timelineStartTimestamp) {
        startTimestamp = timelineStartTimestamp;
    }
    long endTimestamp = last.getEventTimestamp();
    if (endState == AgentState.RUNNING) {
        endTimestamp = timelineEndTimestamp;
    }
    return new AgentLifeCycle(startTimestamp, endTimestamp, endState);
}
Also used : AgentEvent(com.navercorp.pinpoint.web.vo.AgentEvent)

Example 2 with AgentEvent

use of com.navercorp.pinpoint.web.vo.AgentEvent in project pinpoint by naver.

the class AgentStatusTimelineBuilder method partitionByStartTimestamp.

private Map<Long, List<AgentEvent>> partitionByStartTimestamp(List<AgentEvent> agentEvents) {
    Map<Long, List<AgentEvent>> partitions = new HashMap<>();
    for (AgentEvent agentEvent : agentEvents) {
        long startTimestamp = agentEvent.getStartTimestamp();
        List<AgentEvent> partition = partitions.get(startTimestamp);
        if (partition == null) {
            partition = new ArrayList<>();
            partitions.put(startTimestamp, partition);
        }
        partition.add(agentEvent);
    }
    return partitions;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) AgentEvent(com.navercorp.pinpoint.web.vo.AgentEvent)

Example 3 with AgentEvent

use of com.navercorp.pinpoint.web.vo.AgentEvent in project pinpoint by naver.

the class AgentEventServiceImpl method createAgentEvents.

private List<AgentEvent> createAgentEvents(List<AgentEventBo> agentEventBos, boolean includeEventMessage) {
    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, includeEventMessage));
        } else {
            agentEvents.add(createAgentEvent(agentEventBo, includeEventMessage));
        }
    }
    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.AgentEventBo) ArrayList(java.util.ArrayList) PriorityQueue(java.util.PriorityQueue) AgentEvent(com.navercorp.pinpoint.web.vo.AgentEvent) DurationalAgentEvent(com.navercorp.pinpoint.web.vo.DurationalAgentEvent)

Example 4 with AgentEvent

use of com.navercorp.pinpoint.web.vo.AgentEvent in project pinpoint by naver.

the class AgentEventServiceImpl method getAgentEvents.

@Override
public List<AgentEvent> getAgentEvents(String agentId, Range range, int... excludeEventTypeCodes) {
    if (agentId == null) {
        throw new NullPointerException("agentId must not be null");
    }
    final boolean includeEventMessage = false;
    Set<AgentEventType> excludeEventTypes = EnumSet.noneOf(AgentEventType.class);
    for (int excludeEventTypeCode : excludeEventTypeCodes) {
        AgentEventType excludeEventType = AgentEventType.getTypeByCode(excludeEventTypeCode);
        if (excludeEventType != null) {
            excludeEventTypes.add(excludeEventType);
        }
    }
    List<AgentEventBo> agentEventBos = this.agentEventDao.getAgentEvents(agentId, range, excludeEventTypes);
    List<AgentEvent> agentEvents = createAgentEvents(agentEventBos, includeEventMessage);
    Collections.sort(agentEvents, AgentEvent.EVENT_TIMESTAMP_ASC_COMPARATOR);
    return agentEvents;
}
Also used : AgentEventType(com.navercorp.pinpoint.common.server.util.AgentEventType) AgentEventBo(com.navercorp.pinpoint.common.server.bo.AgentEventBo) AgentEvent(com.navercorp.pinpoint.web.vo.AgentEvent) DurationalAgentEvent(com.navercorp.pinpoint.web.vo.DurationalAgentEvent)

Example 5 with AgentEvent

use of com.navercorp.pinpoint.web.vo.AgentEvent in project pinpoint by naver.

the class AgentEventTimelineTest method rangeLessThanNumTimeslots.

@Test
public void rangeLessThanNumTimeslots() {
    // Given
    Range range = new Range(10, 20);
    AgentEvent event1 = createAgentEvent(10, AgentEventType.AGENT_PING);
    AgentEvent event2 = createAgentEvent(11, AgentEventType.AGENT_PING);
    AgentEvent event3 = createAgentEvent(12, AgentEventType.AGENT_PING);
    AgentEvent event4 = createAgentEvent(13, AgentEventType.AGENT_PING);
    AgentEvent event5 = createAgentEvent(14, AgentEventType.AGENT_PING);
    AgentEvent event6 = createAgentEvent(15, AgentEventType.AGENT_PING);
    AgentEvent event7 = createAgentEvent(16, AgentEventType.AGENT_PING);
    AgentEvent event8 = createAgentEvent(17, AgentEventType.AGENT_PING);
    AgentEvent event9 = createAgentEvent(18, AgentEventType.AGENT_PING);
    AgentEvent event10 = createAgentEvent(19, AgentEventType.AGENT_PING);
    List<AgentEventTimelineSegment> expectedTimelineSegments = Arrays.asList(createSegment(10, 11, Collections.singletonList(event1)), createSegment(11, 12, Collections.singletonList(event2)), createSegment(12, 13, Collections.singletonList(event3)), createSegment(13, 14, Collections.singletonList(event4)), createSegment(14, 15, Collections.singletonList(event5)), createSegment(15, 16, Collections.singletonList(event6)), createSegment(16, 17, Collections.singletonList(event7)), createSegment(17, 18, Collections.singletonList(event8)), createSegment(18, 19, Collections.singletonList(event9)), createSegment(19, 20, Collections.singletonList(event10)));
    // When
    AgentEventTimeline timeline = new AgentEventTimelineBuilder(range, 100).from(Arrays.asList(event1, event2, event3, event4, event5, event6, event7, event8, event9, event10)).build();
    // Then
    Assert.assertEquals(expectedTimelineSegments, timeline.getTimelineSegments());
}
Also used : Range(com.navercorp.pinpoint.web.vo.Range) AgentEvent(com.navercorp.pinpoint.web.vo.AgentEvent) Test(org.junit.Test)

Aggregations

AgentEvent (com.navercorp.pinpoint.web.vo.AgentEvent)14 Range (com.navercorp.pinpoint.web.vo.Range)7 Test (org.junit.Test)7 ArrayList (java.util.ArrayList)4 AgentEventBo (com.navercorp.pinpoint.common.server.bo.AgentEventBo)2 AgentEventType (com.navercorp.pinpoint.common.server.util.AgentEventType)2 AgentEventFilter (com.navercorp.pinpoint.web.filter.agent.AgentEventFilter)2 DurationalAgentEvent (com.navercorp.pinpoint.web.vo.DurationalAgentEvent)2 List (java.util.List)2 AgentStatus (com.navercorp.pinpoint.web.vo.AgentStatus)1 AgentEventTimeline (com.navercorp.pinpoint.web.vo.timeline.inspector.AgentEventTimeline)1 AgentEventTimelineBuilder (com.navercorp.pinpoint.web.vo.timeline.inspector.AgentEventTimelineBuilder)1 AgentStatusTimeline (com.navercorp.pinpoint.web.vo.timeline.inspector.AgentStatusTimeline)1 AgentStatusTimelineBuilder (com.navercorp.pinpoint.web.vo.timeline.inspector.AgentStatusTimelineBuilder)1 InspectorTimeline (com.navercorp.pinpoint.web.vo.timeline.inspector.InspectorTimeline)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 PriorityQueue (java.util.PriorityQueue)1 TreeMap (java.util.TreeMap)1