use of com.navercorp.pinpoint.thrift.dto.command.TCommandTransferResponse in project pinpoint by naver.
the class StreamRouteHandler method createResponse.
private TCommandTransferResponse createResponse(TRouteResult result, byte[] payload) {
TCommandTransferResponse response = new TCommandTransferResponse();
response.setRouteResult(result);
response.setPayload(payload);
return response;
}
use of com.navercorp.pinpoint.thrift.dto.command.TCommandTransferResponse in project pinpoint by naver.
the class ClusterPointRouter method handleRouteRequest.
private boolean handleRouteRequest(TCommandTransfer request, RequestPacket requestPacket, PinpointSocket pinpointSocket) {
byte[] payload = ((TCommandTransfer) request).getPayload();
TBase<?, ?> command = deserialize(payload);
TCommandTransferResponse response = routeHandler.onRoute(new RequestEvent((TCommandTransfer) request, pinpointSocket.getRemoteAddress(), requestPacket.getRequestId(), command));
pinpointSocket.response(requestPacket, serialize(response));
return response.getRouteResult() == TRouteResult.OK;
}
use of com.navercorp.pinpoint.thrift.dto.command.TCommandTransferResponse in project pinpoint by naver.
the class ClusterPointRouter method handleStreamRouteCreate.
private StreamCode handleStreamRouteCreate(TCommandTransfer request, StreamCreatePacket packet, ServerStreamChannelContext streamChannelContext) {
byte[] payload = ((TCommandTransfer) request).getPayload();
TBase<?, ?> command = deserialize(payload);
if (command == null) {
return StreamCode.TYPE_UNKNOWN;
}
TCommandTransferResponse response = streamRouteHandler.onRoute(new StreamEvent((TCommandTransfer) request, streamChannelContext, command));
TRouteResult routeResult = response.getRouteResult();
if (routeResult != TRouteResult.OK) {
logger.warn("handleStreamRouteCreate failed. command:{}, routeResult:{}", command, routeResult);
return convertToStreamCode(routeResult);
}
return StreamCode.OK;
}
use of com.navercorp.pinpoint.thrift.dto.command.TCommandTransferResponse 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.TCommandTransferResponse in project pinpoint by naver.
the class AgentEventHandlerTest 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);
when(deserializer.deserialize(mismatchingResponseBody)).thenReturn((TBase) mismatchingResponse);
// when
this.agentEventHandler.handleResponseEvent(responseEvent, TEST_EVENT_TIMESTAMP);
// then
verify(this.agentEventDao, never()).insert(argCaptor.capture());
}
Aggregations