Search in sources :

Example 16 with AgentEventBo

use of com.navercorp.pinpoint.common.server.bo.event.AgentEventBo in project pinpoint by naver.

the class AgentEventResultsExtractor method extractData.

@Override
public List<AgentEventBo> extractData(ResultScanner results) throws Exception {
    List<AgentEventBo> agentEvents = new ArrayList<>();
    int rowNum = 0;
    for (Result result : results) {
        List<AgentEventBo> intermediateEvents = agentEventMapper.mapRow(result, rowNum++);
        if (!intermediateEvents.isEmpty()) {
            agentEvents.addAll(intermediateEvents);
        }
    }
    return agentEvents;
}
Also used : AgentEventBo(com.navercorp.pinpoint.common.server.bo.event.AgentEventBo) ArrayList(java.util.ArrayList) Result(org.apache.hadoop.hbase.client.Result)

Example 17 with AgentEventBo

use of com.navercorp.pinpoint.common.server.bo.event.AgentEventBo in project pinpoint by naver.

the class AgentEventMapper method mapRow.

@Override
public List<AgentEventBo> mapRow(Result result, int rowNum) throws Exception {
    if (result.isEmpty()) {
        return Collections.emptyList();
    }
    List<AgentEventBo> agentEvents = new ArrayList<>();
    for (Cell cell : result.rawCells()) {
        final int code = CellUtils.qualifierToInt(cell);
        final AgentEventType eventType = AgentEventType.getTypeByCode(code);
        if (eventType == null) {
            continue;
        }
        byte[] value = CellUtil.cloneValue(cell);
        final Buffer buffer = new FixedBuffer(value);
        final int version = buffer.readInt();
        switch(version) {
            case 0:
            case 1:
                final String agentId = buffer.readPrefixedString();
                final long startTimestamp = buffer.readLong();
                final long eventTimestamp = buffer.readLong();
                final byte[] eventMessage = buffer.readPrefixedBytes();
                final AgentEventBo agentEvent = new AgentEventBo(version, agentId, startTimestamp, eventTimestamp, eventType);
                agentEvent.setEventBody(eventMessage);
                agentEvents.add(agentEvent);
                break;
            default:
                break;
        }
    }
    return agentEvents;
}
Also used : FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) Buffer(com.navercorp.pinpoint.common.buffer.Buffer) AgentEventType(com.navercorp.pinpoint.common.server.util.AgentEventType) FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) AgentEventBo(com.navercorp.pinpoint.common.server.bo.event.AgentEventBo) ArrayList(java.util.ArrayList) Cell(org.apache.hadoop.hbase.Cell)

Example 18 with AgentEventBo

use of com.navercorp.pinpoint.common.server.bo.event.AgentEventBo in project pinpoint by naver.

the class AgentEventHandlingFilterTest 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);
    Message<TBase<?, ?>> message = new DefaultMessage<>(new HeaderV1((short) 1000), HeaderEntity.EMPTY_HEADER_ENTITY, expectedThreadDumpResponse);
    when(deserializer.deserialize(expectedThreadDumpResponseBody)).thenReturn(message);
    // when
    this.agentEventHandlingFilter.handleResponseEvent(responseEvent, TEST_EVENT_TIMESTAMP);
    // then
    verify(this.agentEventService, 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 : DefaultMessage(com.navercorp.pinpoint.io.request.DefaultMessage) TCommandThreadDumpResponse(com.navercorp.pinpoint.thrift.dto.command.TCommandThreadDumpResponse) TCommandTransfer(com.navercorp.pinpoint.thrift.dto.command.TCommandTransfer) HeaderV1(com.navercorp.pinpoint.io.header.v1.HeaderV1) HeaderTBaseDeserializer(com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializer) AgentEventType(com.navercorp.pinpoint.common.server.util.AgentEventType) TCommandTransferResponse(com.navercorp.pinpoint.thrift.dto.command.TCommandTransferResponse) AgentEventBo(com.navercorp.pinpoint.common.server.bo.event.AgentEventBo) ResponseEvent(com.navercorp.pinpoint.collector.cluster.route.ResponseEvent) TBase(org.apache.thrift.TBase) Test(org.junit.Test)

Example 19 with AgentEventBo

use of com.navercorp.pinpoint.common.server.bo.event.AgentEventBo in project pinpoint by naver.

the class AgentEventHandlingFilterTest method handler_should_ignore_request_events_with_unsupported_message_types.

@Test
@SuppressWarnings({ "rawtypes", "unchecked" })
public void handler_should_ignore_request_events_with_unsupported_message_types() throws Exception {
    // given
    final TCommandEcho mismatchingResponse = new TCommandEcho();
    final byte[] mismatchingResponseBody = 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(mismatchingResponseBody);
    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);
    Message<TBase<?, ?>> message = new DefaultMessage<>(new HeaderV1((short) 1000), HeaderEntity.EMPTY_HEADER_ENTITY, mismatchingResponse);
    when(deserializer.deserialize(mismatchingResponseBody)).thenReturn(message);
    // when
    this.agentEventHandlingFilter.handleResponseEvent(responseEvent, TEST_EVENT_TIMESTAMP);
    // then
    verify(this.agentEventDao, never()).insert(argCaptor.capture());
}
Also used : DefaultMessage(com.navercorp.pinpoint.io.request.DefaultMessage) TCommandTransfer(com.navercorp.pinpoint.thrift.dto.command.TCommandTransfer) TCommandTransferResponse(com.navercorp.pinpoint.thrift.dto.command.TCommandTransferResponse) AgentEventBo(com.navercorp.pinpoint.common.server.bo.event.AgentEventBo) TCommandEcho(com.navercorp.pinpoint.thrift.dto.command.TCommandEcho) HeaderV1(com.navercorp.pinpoint.io.header.v1.HeaderV1) ResponseEvent(com.navercorp.pinpoint.collector.cluster.route.ResponseEvent) TBase(org.apache.thrift.TBase) HeaderTBaseDeserializer(com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializer) Test(org.junit.Test)

Example 20 with AgentEventBo

use of com.navercorp.pinpoint.common.server.bo.event.AgentEventBo in project pinpoint by naver.

the class AgentEventAsyncTaskService method handleEvent.

@Async("agentEventWorker")
public void handleEvent(final AgentProperty agentProperty, long eventTimestamp, AgentEventType eventType) {
    Objects.requireNonNull(agentProperty, "agentProperty");
    Objects.requireNonNull(eventType, "eventType");
    final String agentId = agentProperty.getAgentId();
    final long startTimestamp = agentProperty.getStartTime();
    final AgentEventBo agentEventBo = newAgentEventBo(agentId, startTimestamp, eventTimestamp, eventType);
    this.agentEventService.insert(agentEventBo);
}
Also used : AgentEventBo(com.navercorp.pinpoint.common.server.bo.event.AgentEventBo) Async(org.springframework.scheduling.annotation.Async)

Aggregations

AgentEventBo (com.navercorp.pinpoint.common.server.bo.event.AgentEventBo)20 AgentEventType (com.navercorp.pinpoint.common.server.util.AgentEventType)5 ArrayList (java.util.ArrayList)5 Test (org.junit.Test)5 TAgentStat (com.navercorp.pinpoint.thrift.dto.TAgentStat)3 TCommandTransfer (com.navercorp.pinpoint.thrift.dto.command.TCommandTransfer)3 TCommandTransferResponse (com.navercorp.pinpoint.thrift.dto.command.TCommandTransferResponse)3 ResponseEvent (com.navercorp.pinpoint.collector.cluster.route.ResponseEvent)2 DeadlockBo (com.navercorp.pinpoint.common.server.bo.event.DeadlockBo)2 DeadlockEventBo (com.navercorp.pinpoint.common.server.bo.event.DeadlockEventBo)2 Header (com.navercorp.pinpoint.grpc.Header)2 HeaderV1 (com.navercorp.pinpoint.io.header.v1.HeaderV1)2 DefaultMessage (com.navercorp.pinpoint.io.request.DefaultMessage)2 TDeadlock (com.navercorp.pinpoint.thrift.dto.TDeadlock)2 HeaderTBaseDeserializer (com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializer)2 AgentEvent (com.navercorp.pinpoint.web.vo.AgentEvent)2 TableName (org.apache.hadoop.hbase.TableName)2 TBase (org.apache.thrift.TBase)2 AgentProperty (com.navercorp.pinpoint.collector.service.async.AgentProperty)1 AgentPropertyChannelAdaptor (com.navercorp.pinpoint.collector.service.async.AgentPropertyChannelAdaptor)1