Search in sources :

Example 6 with AgentEventType

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;
}
Also used : AgentEventType(com.navercorp.pinpoint.common.server.util.AgentEventType) AgentEventBo(com.navercorp.pinpoint.common.server.bo.AgentEventBo) Scan(org.apache.hadoop.hbase.client.Scan) FilterList(org.apache.hadoop.hbase.filter.FilterList) BinaryComparator(org.apache.hadoop.hbase.filter.BinaryComparator) QualifierFilter(org.apache.hadoop.hbase.filter.QualifierFilter)

Example 7 with AgentEventType

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();
}
Also used : AgentEventType(com.navercorp.pinpoint.common.server.util.AgentEventType)

Example 8 with AgentEventType

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());
}
Also used : Range(com.navercorp.pinpoint.web.vo.Range) AgentEventFilter(com.navercorp.pinpoint.web.filter.agent.AgentEventFilter) AgentEventType(com.navercorp.pinpoint.common.server.util.AgentEventType) AgentEvent(com.navercorp.pinpoint.web.vo.AgentEvent) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 9 with AgentEventType

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);
}
Also used : AgentEventType(com.navercorp.pinpoint.common.server.util.AgentEventType)

Example 10 with AgentEventType

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());
}
Also used : TCommandThreadDumpResponse(com.navercorp.pinpoint.thrift.dto.command.TCommandThreadDumpResponse) AgentEventType(com.navercorp.pinpoint.common.server.util.AgentEventType) TCommandTransfer(com.navercorp.pinpoint.thrift.dto.command.TCommandTransfer) TCommandTransferResponse(com.navercorp.pinpoint.thrift.dto.command.TCommandTransferResponse) AgentEventBo(com.navercorp.pinpoint.common.server.bo.AgentEventBo) ResponseEvent(com.navercorp.pinpoint.collector.cluster.route.ResponseEvent) HeaderTBaseDeserializer(com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializer) Test(org.junit.Test)

Aggregations

AgentEventType (com.navercorp.pinpoint.common.server.util.AgentEventType)12 AgentEventBo (com.navercorp.pinpoint.common.server.bo.AgentEventBo)7 Test (org.junit.Test)4 AgentEvent (com.navercorp.pinpoint.web.vo.AgentEvent)2 ResponseEvent (com.navercorp.pinpoint.collector.cluster.route.ResponseEvent)1 ManagedAgentLifeCycle (com.navercorp.pinpoint.collector.util.ManagedAgentLifeCycle)1 Buffer (com.navercorp.pinpoint.common.buffer.Buffer)1 FixedBuffer (com.navercorp.pinpoint.common.buffer.FixedBuffer)1 AgentLifeCycleState (com.navercorp.pinpoint.common.server.util.AgentLifeCycleState)1 TCommandThreadDumpResponse (com.navercorp.pinpoint.thrift.dto.command.TCommandThreadDumpResponse)1 TCommandTransfer (com.navercorp.pinpoint.thrift.dto.command.TCommandTransfer)1 TCommandTransferResponse (com.navercorp.pinpoint.thrift.dto.command.TCommandTransferResponse)1 HeaderTBaseDeserializer (com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializer)1 AgentEventFilter (com.navercorp.pinpoint.web.filter.agent.AgentEventFilter)1 DurationalAgentEvent (com.navercorp.pinpoint.web.vo.DurationalAgentEvent)1 Range (com.navercorp.pinpoint.web.vo.Range)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Cell (org.apache.hadoop.hbase.Cell)1 Scan (org.apache.hadoop.hbase.client.Scan)1