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