Search in sources :

Example 6 with AgentEvent

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

the class AgentEventTimelineTest method rightBiasedSpread.

@Test
public void rightBiasedSpread() {
    // Given
    Range range = new Range(0, 199);
    AgentEvent event1 = createAgentEvent(0, AgentEventType.AGENT_CONNECTED);
    AgentEvent event2 = createAgentEvent(5, AgentEventType.AGENT_PING);
    AgentEvent event3 = createAgentEvent(100, AgentEventType.AGENT_PING);
    AgentEvent event4 = createAgentEvent(110, AgentEventType.AGENT_PING);
    AgentEvent event5 = createAgentEvent(199, AgentEventType.AGENT_PING);
    AgentEvent event6 = createAgentEvent(200, AgentEventType.AGENT_SHUTDOWN);
    List<AgentEventTimelineSegment> expectedTimelineSegments = Arrays.asList(createSegment(0, 1, Collections.singletonList(event1)), createSegment(5, 6, Collections.singletonList(event2)), createSegment(99, 199, Arrays.asList(event3, event4, event5, event6)));
    // When
    AgentEventTimeline timeline = new AgentEventTimelineBuilder(range, 100).from(Arrays.asList(event1, event2, event3, event4, event5, event6)).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)

Example 7 with AgentEvent

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

the class AgentEventTimelineTest method fullTimeslots_multipleEvents.

@Test
public void fullTimeslots_multipleEvents() {
    // Given
    long timeRangeMs = TimeUnit.DAYS.toMillis(7);
    long from = System.currentTimeMillis();
    long to = from + timeRangeMs;
    Range range = new Range(from, to);
    int numTimeslots = 100;
    int expectedEventCountPerSegment = 20;
    List<AgentEvent> agentEvents = new ArrayList<>();
    for (int i = 0; i < timeRangeMs; i += (timeRangeMs / (numTimeslots * expectedEventCountPerSegment))) {
        agentEvents.add(createAgentEvent(from + i, AgentEventType.AGENT_PING));
    }
    // When
    AgentEventTimeline timeline = new AgentEventTimelineBuilder(range, numTimeslots).from(agentEvents).build();
    // Then
    List<AgentEventTimelineSegment> timelineSegments = timeline.getTimelineSegments();
    Assert.assertEquals(numTimeslots, timelineSegments.size());
    for (AgentEventTimelineSegment timelineSegment : timelineSegments) {
        AgentEventMarker eventMarker = timelineSegment.getValue();
        Assert.assertEquals(expectedEventCountPerSegment, eventMarker.getTotalCount());
        int pingEventCount = eventMarker.getTypeCounts().get(AgentEventType.AGENT_PING);
        Assert.assertEquals(expectedEventCountPerSegment, pingEventCount);
    }
}
Also used : ArrayList(java.util.ArrayList) Range(com.navercorp.pinpoint.web.vo.Range) AgentEvent(com.navercorp.pinpoint.web.vo.AgentEvent) Test(org.junit.Test)

Example 8 with AgentEvent

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

the class AgentEventTimelineTest method leftBiasedSpread.

@Test
public void leftBiasedSpread() {
    // Given
    Range range = new Range(100, 200);
    AgentEvent event1 = createAgentEvent(0, AgentEventType.AGENT_CONNECTED);
    AgentEvent event2 = createAgentEvent(5, AgentEventType.AGENT_PING);
    AgentEvent event3 = createAgentEvent(50, AgentEventType.AGENT_PING);
    AgentEvent event4 = createAgentEvent(100, AgentEventType.AGENT_PING);
    AgentEvent event5 = createAgentEvent(150, AgentEventType.AGENT_PING);
    AgentEvent event6 = createAgentEvent(220, AgentEventType.AGENT_SHUTDOWN);
    List<AgentEventTimelineSegment> expectedTimelineSegments = Arrays.asList(createSegment(100, 101, Arrays.asList(event1, event2, event3, event4)), createSegment(150, 151, Collections.singletonList(event5)), createSegment(199, 200, Collections.singletonList(event6)));
    // When
    AgentEventTimeline timeline = new AgentEventTimelineBuilder(range, 100).from(Arrays.asList(event1, event2, event3, event4, event5, event6)).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)

Example 9 with AgentEvent

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

the class AgentInfoServiceImpl method getAgentStatusTimeline.

@Override
public InspectorTimeline getAgentStatusTimeline(String agentId, Range range, int... excludeAgentEventTypeCodes) {
    Assert.notNull(agentId, "agentId must not be null");
    Assert.notNull(range, "range must not be null");
    AgentStatus initialStatus = getAgentStatus(agentId, range.getFrom());
    List<AgentEvent> agentEvents = agentEventService.getAgentEvents(agentId, range);
    AgentStatusTimelineBuilder agentStatusTimelinebuilder = new AgentStatusTimelineBuilder(range, initialStatus);
    agentStatusTimelinebuilder.from(agentEvents);
    AgentStatusTimeline agentStatusTimeline = agentStatusTimelinebuilder.build();
    AgentEventTimelineBuilder agentEventTimelineBuilder = new AgentEventTimelineBuilder(range);
    agentEventTimelineBuilder.from(agentEvents);
    agentEventTimelineBuilder.addFilter(new AgentEventFilter.ExcludeFilter(excludeAgentEventTypeCodes));
    AgentEventTimeline agentEventTimeline = agentEventTimelineBuilder.build();
    return new InspectorTimeline(agentStatusTimeline, agentEventTimeline);
}
Also used : AgentEventFilter(com.navercorp.pinpoint.web.filter.agent.AgentEventFilter) AgentEventTimeline(com.navercorp.pinpoint.web.vo.timeline.inspector.AgentEventTimeline) AgentStatus(com.navercorp.pinpoint.web.vo.AgentStatus) AgentStatusTimeline(com.navercorp.pinpoint.web.vo.timeline.inspector.AgentStatusTimeline) AgentEventTimelineBuilder(com.navercorp.pinpoint.web.vo.timeline.inspector.AgentEventTimelineBuilder) InspectorTimeline(com.navercorp.pinpoint.web.vo.timeline.inspector.InspectorTimeline) AgentEvent(com.navercorp.pinpoint.web.vo.AgentEvent) AgentStatusTimelineBuilder(com.navercorp.pinpoint.web.vo.timeline.inspector.AgentStatusTimelineBuilder)

Example 10 with AgentEvent

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

the class AgentEventTimelineBuilder method createTimeslotIndexMap.

private Map<Long, List<AgentEvent>> createTimeslotIndexMap(List<AgentEvent> agentEvents) {
    Map<Long, List<AgentEvent>> timeslotIndexMap = new TreeMap<>();
    for (AgentEvent agentEvent : agentEvents) {
        long timeslotIndex = getTimeslotIndex(agentEvent.getEventTimestamp());
        List<AgentEvent> timeslotAgentEvents = timeslotIndexMap.get(timeslotIndex);
        if (timeslotAgentEvents == null) {
            timeslotAgentEvents = new ArrayList<>();
            timeslotIndexMap.put(timeslotIndex, timeslotAgentEvents);
        }
        timeslotAgentEvents.add(agentEvent);
    }
    return timeslotIndexMap;
}
Also used : List(java.util.List) ArrayList(java.util.ArrayList) TreeMap(java.util.TreeMap) AgentEvent(com.navercorp.pinpoint.web.vo.AgentEvent)

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