Search in sources :

Example 1 with HeaderV1

use of com.navercorp.pinpoint.io.header.v1.HeaderV1 in project pinpoint by naver.

the class HeaderUtilsTest method validateSignature.

@Test
public void validateSignature() throws TException {
    Header header = new HeaderV1((short) 1);
    Assert.assertEquals(HeaderUtils.validateSignature(header.getSignature()), HeaderUtils.OK);
    logger.debug(header.toString());
}
Also used : Header(com.navercorp.pinpoint.io.header.Header) HeaderV1(com.navercorp.pinpoint.io.header.v1.HeaderV1) Test(org.junit.Test)

Example 2 with HeaderV1

use of com.navercorp.pinpoint.io.header.v1.HeaderV1 in project pinpoint by naver.

the class HeaderTest method testGetSignature.

@Test
public void testGetSignature() {
    Header header = new HeaderV1((short) 1);
    byte signature = header.getSignature();
    short type = header.getType();
    byte version = header.getVersion();
}
Also used : Header(com.navercorp.pinpoint.io.header.Header) HeaderV1(com.navercorp.pinpoint.io.header.v1.HeaderV1) Test(org.junit.Test)

Example 3 with HeaderV1

use of com.navercorp.pinpoint.io.header.v1.HeaderV1 in project pinpoint by naver.

the class HeaderUtilsTest method validateSignature_error.

@Test(expected = InvalidHeaderException.class)
public void validateSignature_error() throws TException {
    Header error = new HeaderV1((byte) 0x11, (byte) 0x20, (short) 1);
    Assert.assertNotEquals(HeaderUtils.validateSignature(error.getSignature()), HeaderUtils.OK);
    logger.debug(error.toString());
}
Also used : Header(com.navercorp.pinpoint.io.header.Header) HeaderV1(com.navercorp.pinpoint.io.header.v1.HeaderV1) Test(org.junit.Test)

Example 4 with HeaderV1

use of com.navercorp.pinpoint.io.header.v1.HeaderV1 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 5 with HeaderV1

use of com.navercorp.pinpoint.io.header.v1.HeaderV1 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)

Aggregations

HeaderV1 (com.navercorp.pinpoint.io.header.v1.HeaderV1)5 Test (org.junit.Test)5 Header (com.navercorp.pinpoint.io.header.Header)3 ResponseEvent (com.navercorp.pinpoint.collector.cluster.route.ResponseEvent)2 AgentEventBo (com.navercorp.pinpoint.common.server.bo.event.AgentEventBo)2 DefaultMessage (com.navercorp.pinpoint.io.request.DefaultMessage)2 TCommandTransfer (com.navercorp.pinpoint.thrift.dto.command.TCommandTransfer)2 TCommandTransferResponse (com.navercorp.pinpoint.thrift.dto.command.TCommandTransferResponse)2 HeaderTBaseDeserializer (com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializer)2 TBase (org.apache.thrift.TBase)2 AgentEventType (com.navercorp.pinpoint.common.server.util.AgentEventType)1 TCommandEcho (com.navercorp.pinpoint.thrift.dto.command.TCommandEcho)1 TCommandThreadDumpResponse (com.navercorp.pinpoint.thrift.dto.command.TCommandThreadDumpResponse)1