use of com.navercorp.pinpoint.thrift.dto.command.TCommandThreadDumpResponse 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());
}
use of com.navercorp.pinpoint.thrift.dto.command.TCommandThreadDumpResponse in project pinpoint by naver.
the class ThreadDumpService method requestCommandService.
@Override
public TBase<?, ?> requestCommandService(TBase<?, ?> tbase) {
logger.info("{} execute {}.", this, tbase);
TCommandThreadDump param = (TCommandThreadDump) tbase;
TThreadDumpType type = param.getType();
final List<ThreadInfo> threadInfoList = getThreadInfos(type, param);
final List<TThreadDump> threadDumpList = getTThreadDumpList(threadInfoList);
TCommandThreadDumpResponse response = new TCommandThreadDumpResponse();
response.setThreadDumps(threadDumpList);
return response;
}
use of com.navercorp.pinpoint.thrift.dto.command.TCommandThreadDumpResponse in project pinpoint by naver.
the class AgentEventMessageSerDesTest method createTCommandThreadDumpResponse.
private TCommandThreadDumpResponse createTCommandThreadDumpResponse() {
final TCommandThreadDumpResponse threadDumpResponse = new TCommandThreadDumpResponse();
ThreadInfo[] threadInfos = ThreadMXBeanUtils.dumpAllThread();
for (ThreadInfo threadInfo : threadInfos) {
final TThreadDump threadDump = createTThreadDump(threadInfo);
threadDumpResponse.addToThreadDumps(threadDump);
}
return threadDumpResponse;
}
use of com.navercorp.pinpoint.thrift.dto.command.TCommandThreadDumpResponse in project pinpoint by naver.
the class AgentEventMessageSerDesTest method TCommandThreadDumpResponse_event_messages_should_serialize_and_deserialize_correctly.
@Test
public void TCommandThreadDumpResponse_event_messages_should_serialize_and_deserialize_correctly() throws UnsupportedEncodingException {
final Class<TCommandThreadDumpResponse> messageTypeToTest = TCommandThreadDumpResponse.class;
final TCommandThreadDumpResponse expectedEventMessage = createTCommandThreadDumpResponse();
verifyEventMessageSerDer(messageTypeToTest, expectedEventMessage);
}
use of com.navercorp.pinpoint.thrift.dto.command.TCommandThreadDumpResponse 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());
}
Aggregations