use of com.navercorp.pinpoint.common.server.util.AgentEventType in project pinpoint by naver.
the class HbaseAgentEventDao method getAgentEvents.
@Override
public List<AgentEventBo> getAgentEvents(String agentId, Range range, Set<AgentEventType> excludeEventTypes) {
if (agentId == null) {
throw new NullPointerException("agentId must not be null");
}
if (range == null) {
throw new NullPointerException("range must not be null");
}
Scan scan = new Scan();
scan.setMaxVersions(1);
scan.setCaching(SCANNER_CACHE_SIZE);
scan.setStartRow(createRowKey(agentId, range.getTo()));
scan.setStopRow(createRowKey(agentId, range.getFrom()));
scan.addFamily(HBaseTables.AGENT_EVENT_CF_EVENTS);
if (!CollectionUtils.isEmpty(excludeEventTypes)) {
FilterList filterList = new FilterList(FilterList.Operator.MUST_PASS_ALL);
for (AgentEventType excludeEventType : excludeEventTypes) {
byte[] excludeQualifier = Bytes.toBytes(excludeEventType.getCode());
filterList.addFilter(new QualifierFilter(CompareFilter.CompareOp.NOT_EQUAL, new BinaryComparator(excludeQualifier)));
}
scan.setFilter(filterList);
}
List<AgentEventBo> agentEvents = this.hbaseOperations2.find(HBaseTables.AGENT_EVENT, scan, agentEventResultsExtractor);
logger.debug("agentEvents found. {}", agentEvents);
return agentEvents;
}
use of com.navercorp.pinpoint.common.server.util.AgentEventType in project pinpoint by naver.
the class AgentEventMarkerSerializer method writeAgentEventTypeCount.
private void writeAgentEventTypeCount(JsonGenerator jsonGenerator, Map.Entry<AgentEventType, Integer> entry) throws IOException {
AgentEventType agentEventType = entry.getKey();
int count = entry.getValue();
jsonGenerator.writeStartObject();
jsonGenerator.writeNumberField("code", agentEventType.getCode());
jsonGenerator.writeStringField("desc", agentEventType.getDesc());
jsonGenerator.writeNumberField("count", count);
jsonGenerator.writeEndObject();
}
use of com.navercorp.pinpoint.common.server.util.AgentEventType in project pinpoint by naver.
the class AgentEventTimelineTest method multipleFilters.
@Test
public void multipleFilters() {
// Given
Range timelineRange = new Range(100, 200);
List<AgentEvent> agentEvents = Arrays.asList(createAgentEvent(110, AgentEventType.AGENT_PING), createAgentEvent(120, AgentEventType.AGENT_CONNECTED), createAgentEvent(130, AgentEventType.AGENT_SHUTDOWN), createAgentEvent(140, AgentEventType.AGENT_UNEXPECTED_SHUTDOWN), createAgentEvent(150, AgentEventType.AGENT_CLOSED_BY_SERVER), createAgentEvent(160, AgentEventType.AGENT_UNEXPECTED_CLOSE_BY_SERVER), createAgentEvent(170, AgentEventType.USER_THREAD_DUMP), createAgentEvent(180, AgentEventType.OTHER));
Set<AgentEventType> includedAgentEventTypes = new HashSet<AgentEventType>() {
{
add(AgentEventType.AGENT_PING);
add(AgentEventType.AGENT_CONNECTED);
add(AgentEventType.AGENT_SHUTDOWN);
add(AgentEventType.AGENT_CLOSED_BY_SERVER);
}
};
AgentEventFilter excludeUnexpectedEventsFilter = new AgentEventFilter.ExcludeFilter(AgentEventType.AGENT_UNEXPECTED_SHUTDOWN, AgentEventType.AGENT_UNEXPECTED_CLOSE_BY_SERVER);
AgentEventFilter excludeUserThreadDumpFilter = new AgentEventFilter.ExcludeFilter(AgentEventType.USER_THREAD_DUMP);
AgentEventFilter excludeOtherFilter = new AgentEventFilter.ExcludeFilter(AgentEventType.OTHER);
// When
AgentEventTimeline timeline = new AgentEventTimelineBuilder(timelineRange, 1).from(agentEvents).addFilter(excludeUnexpectedEventsFilter).addFilter(excludeUserThreadDumpFilter).addFilter(excludeOtherFilter).build();
// Then
int allEventsTotalCount = 0;
for (AgentEventTimelineSegment segment : timeline.getTimelineSegments()) {
AgentEventMarker marker = segment.getValue();
allEventsTotalCount += marker.getTotalCount();
Map<AgentEventType, Integer> eventTypeCountMap = marker.getTypeCounts();
Assert.assertTrue(includedAgentEventTypes.containsAll(eventTypeCountMap.keySet()));
Assert.assertFalse(eventTypeCountMap.keySet().contains(AgentEventType.AGENT_UNEXPECTED_SHUTDOWN));
Assert.assertFalse(eventTypeCountMap.keySet().contains(AgentEventType.AGENT_UNEXPECTED_CLOSE_BY_SERVER));
Assert.assertFalse(eventTypeCountMap.keySet().contains(AgentEventType.USER_THREAD_DUMP));
Assert.assertFalse(eventTypeCountMap.keySet().contains(AgentEventType.OTHER));
}
Assert.assertEquals(allEventsTotalCount, includedAgentEventTypes.size());
}
use of com.navercorp.pinpoint.common.server.util.AgentEventType in project pinpoint by naver.
the class HbaseAgentEventDao method insert.
@Override
public void insert(AgentEventBo agentEventBo) {
if (agentEventBo == null) {
throw new NullPointerException("agentEventBo must not be null");
}
if (logger.isDebugEnabled()) {
logger.debug("insert event. {}", agentEventBo.toString());
}
final String agentId = agentEventBo.getAgentId();
final long eventTimestamp = agentEventBo.getEventTimestamp();
byte[] rowKey = createRowKey(agentId, eventTimestamp);
final AgentEventType eventType = agentEventBo.getEventType();
byte[] qualifier = Bytes.toBytes(eventType.getCode());
this.hbaseTemplate.put(HBaseTables.AGENT_EVENT, rowKey, HBaseTables.AGENT_EVENT_CF_EVENTS, qualifier, agentEventBo, this.valueMapper);
}
use of com.navercorp.pinpoint.common.server.util.AgentEventType in project pinpoint by naver.
the class AgentEventHandlerTest method handler_should_handle_serialization_of_request_events.
@Test
@SuppressWarnings({ "rawtypes", "unchecked" })
public void handler_should_handle_serialization_of_request_events() throws Exception {
// given
final AgentEventType expectedEventType = AgentEventType.USER_THREAD_DUMP;
final TCommandThreadDumpResponse expectedThreadDumpResponse = new TCommandThreadDumpResponse();
final byte[] expectedThreadDumpResponseBody = new byte[0];
final TCommandTransfer tCommandTransfer = new TCommandTransfer();
tCommandTransfer.setAgentId(TEST_AGENT_ID);
tCommandTransfer.setStartTime(TEST_START_TIMESTAMP);
final TCommandTransferResponse tCommandTransferResponse = new TCommandTransferResponse();
tCommandTransferResponse.setRouteResult(TRouteResult.OK);
tCommandTransferResponse.setPayload(expectedThreadDumpResponseBody);
final ResponseEvent responseEvent = new ResponseEvent(tCommandTransfer, null, 0, tCommandTransferResponse);
ArgumentCaptor<AgentEventBo> argCaptor = ArgumentCaptor.forClass(AgentEventBo.class);
HeaderTBaseDeserializer deserializer = mock(HeaderTBaseDeserializer.class);
when(this.deserializerFactory.createDeserializer()).thenReturn(deserializer);
when(deserializer.deserialize(expectedThreadDumpResponseBody)).thenReturn((TBase) expectedThreadDumpResponse);
// when
this.agentEventHandler.handleResponseEvent(responseEvent, TEST_EVENT_TIMESTAMP);
// then
verify(this.agentEventDao, atLeast(1)).insert(argCaptor.capture());
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());
assertArrayEquals(expectedThreadDumpResponseBody, actualAgentEventBo.getEventBody());
}
Aggregations