use of com.navercorp.pinpoint.web.cluster.PinpointRouteResponse 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