use of com.navercorp.pinpoint.common.server.util.AgentEventType in project pinpoint by naver.
the class AgentEventHandlerTest method handler_should_handle_events_with_empty_message_body.
@Test
public void handler_should_handle_events_with_empty_message_body() throws Exception {
// given
final AgentEventType expectedEventType = AgentEventType.AGENT_CONNECTED;
ArgumentCaptor<AgentEventBo> argCaptor = ArgumentCaptor.forClass(AgentEventBo.class);
// when
this.agentEventHandler.handleEvent(this.pinpointServer, TEST_EVENT_TIMESTAMP, expectedEventType);
verify(this.agentEventDao, times(1)).insert(argCaptor.capture());
// then
AgentEventBo actualAgentEventBo = argCaptor.getValue();
assertEquals(TEST_AGENT_ID, actualAgentEventBo.getAgentId());
assertEquals(TEST_START_TIMESTAMP, actualAgentEventBo.getStartTimestamp());
assertEquals(TEST_EVENT_TIMESTAMP, actualAgentEventBo.getEventTimestamp());
assertEquals(expectedEventType, actualAgentEventBo.getEventType());
assertNull(actualAgentEventBo.getEventBody());
}
use of com.navercorp.pinpoint.common.server.util.AgentEventType in project pinpoint by naver.
the class AgentEventHandlerTest method handler_should_handle_serialization_of_messages_appropriately.
@Test
public void handler_should_handle_serialization_of_messages_appropriately() throws Exception {
// given
final AgentEventType expectedEventType = AgentEventType.OTHER;
final String expectedMessageBody = "test event message";
final byte[] expectedMessageBodyBytes = BytesUtils.toBytes(expectedMessageBody);
ArgumentCaptor<AgentEventBo> argCaptor = ArgumentCaptor.forClass(AgentEventBo.class);
when(this.agentEventMessageSerializer.serialize(expectedEventType, expectedMessageBody)).thenReturn(expectedMessageBodyBytes);
// when
this.agentEventHandler.handleEvent(this.pinpointServer, TEST_EVENT_TIMESTAMP, expectedEventType, expectedMessageBody);
verify(this.agentEventDao, times(1)).insert(argCaptor.capture());
// then
AgentEventBo actualAgentEventBo = argCaptor.getValue();
assertEquals(TEST_AGENT_ID, actualAgentEventBo.getAgentId());
assertEquals(TEST_START_TIMESTAMP, actualAgentEventBo.getStartTimestamp());
assertEquals(TEST_EVENT_TIMESTAMP, actualAgentEventBo.getEventTimestamp());
assertEquals(expectedEventType, actualAgentEventBo.getEventType());
assertEquals(expectedMessageBodyBytes, actualAgentEventBo.getEventBody());
}
use of com.navercorp.pinpoint.common.server.util.AgentEventType in project pinpoint by naver.
the class AgentEventMarker method addAgentEvent.
public void addAgentEvent(AgentEvent agentEvent) {
AgentEventType agentEventType = AgentEventType.getTypeByCode(agentEvent.getEventTypeCode());
if (agentEventType != null) {
MutableInt typeCount = typeCounts.get(agentEventType);
if (typeCount == null) {
typeCount = new MutableInt();
typeCounts.put(agentEventType, typeCount);
}
typeCount.increment();
totalCount++;
}
}
use of com.navercorp.pinpoint.common.server.util.AgentEventType in project pinpoint by naver.
the class AgentEventServiceImpl method getAgentEvent.
@Override
public AgentEvent getAgentEvent(String agentId, long eventTimestamp, int eventTypeCode) {
if (agentId == null) {
throw new NullPointerException("agentId must not be null");
}
if (eventTimestamp < 0) {
throw new IllegalArgumentException("eventTimeTimestamp must not be less than 0");
}
final AgentEventType eventType = AgentEventType.getTypeByCode(eventTypeCode);
if (eventType == null) {
throw new IllegalArgumentException("invalid eventTypeCode [" + eventTypeCode + "]");
}
final boolean includeEventMessage = true;
AgentEventBo agentEventBo = this.agentEventDao.getAgentEvent(agentId, eventTimestamp, eventType);
if (agentEventBo != null) {
return createAgentEvent(agentEventBo, includeEventMessage);
}
return null;
}
use of com.navercorp.pinpoint.common.server.util.AgentEventType 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;
}
Aggregations