use of com.navercorp.pinpoint.thrift.dto.command.TCommandEcho 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());
}
use of com.navercorp.pinpoint.thrift.dto.command.TCommandEcho in project pinpoint by naver.
the class EchoService method requestCommandService.
@Override
public TBase<?, ?> requestCommandService(TBase tbase) {
logger.info("{} execute {}.", this, tbase);
TCommandEcho param = (TCommandEcho) tbase;
return param;
}
use of com.navercorp.pinpoint.thrift.dto.command.TCommandEcho in project pinpoint by naver.
the class ProfilerCommandServiceLocatorTest method basicFunctionTest1.
@Test
public void basicFunctionTest1() throws Exception {
ProfilerCommandLocatorBuilder builder = new ProfilerCommandLocatorBuilder();
builder.addService(new EchoService());
builder.addService(new EchoService());
ProfilerCommandServiceLocator commandServiceLocator = builder.build();
TCommandEcho commandEcho = new TCommandEcho();
Assert.assertEquals(1, commandServiceLocator.getCommandServiceClasses().size());
Assert.assertEquals(1, commandServiceLocator.getCommandServiceCodes().size());
Assert.assertTrue(commandServiceLocator.getCommandServiceCodes().contains(TCommandType.getType(commandEcho.getClass()).getCode()));
Assert.assertNotNull(commandServiceLocator.getService(commandEcho));
Assert.assertNotNull(commandServiceLocator.getRequestService(commandEcho));
Assert.assertNull(commandServiceLocator.getSimpleService(commandEcho));
Assert.assertNull(commandServiceLocator.getStreamService(commandEcho));
}
use of com.navercorp.pinpoint.thrift.dto.command.TCommandEcho in project pinpoint by naver.
the class CommandController method echo.
@RequestMapping(value = "/echo", method = RequestMethod.GET)
public ModelAndView echo(@RequestParam("applicationName") String applicationName, @RequestParam("agentId") String agentId, @RequestParam("startTimeStamp") long startTimeStamp, @RequestParam("message") String message) throws TException {
AgentInfo agentInfo = agentService.getAgentInfo(applicationName, agentId, startTimeStamp);
if (agentInfo == null) {
return createResponse(false, String.format("Can't find suitable PinpointServer(%s/%s/%d).", applicationName, agentId, startTimeStamp));
}
TCommandEcho echo = new TCommandEcho();
echo.setMessage(message);
try {
PinpointRouteResponse pinpointRouteResponse = agentService.invoke(agentInfo, echo);
if (pinpointRouteResponse != null && pinpointRouteResponse.getRouteResult() == TRouteResult.OK) {
TBase<?, ?> result = pinpointRouteResponse.getResponse();
if (result == null) {
return createResponse(false, "result null.");
} else if (result instanceof TCommandEcho) {
return createResponse(true, ((TCommandEcho) result).getMessage());
} else if (result instanceof TResult) {
return createResponse(false, ((TResult) result).getMessage());
} else {
return createResponse(false, result.toString());
}
} else {
return createResponse(false, "unknown");
}
} catch (TException e) {
return createResponse(false, e.getMessage());
}
}
Aggregations