Search in sources :

Example 1 with AgentEventType

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

Example 2 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_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());
}
Also used : AgentEventType(com.navercorp.pinpoint.common.server.util.AgentEventType) AgentEventBo(com.navercorp.pinpoint.common.server.bo.AgentEventBo) Test(org.junit.Test)

Example 3 with AgentEventType

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

Example 4 with AgentEventType

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

Example 5 with AgentEventType

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;
}
Also used : AgentEventType(com.navercorp.pinpoint.common.server.util.AgentEventType) AgentEventBo(com.navercorp.pinpoint.common.server.bo.AgentEventBo) AgentEvent(com.navercorp.pinpoint.web.vo.AgentEvent) DurationalAgentEvent(com.navercorp.pinpoint.web.vo.DurationalAgentEvent)

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