Search in sources :

Example 11 with TResult

use of com.navercorp.pinpoint.thrift.dto.TResult 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());
    }
}
Also used : TException(org.apache.thrift.TException) TCommandEcho(com.navercorp.pinpoint.thrift.dto.command.TCommandEcho) AgentInfo(com.navercorp.pinpoint.web.vo.AgentInfo) PinpointRouteResponse(com.navercorp.pinpoint.web.cluster.PinpointRouteResponse) TResult(com.navercorp.pinpoint.thrift.dto.TResult) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

TResult (com.navercorp.pinpoint.thrift.dto.TResult)11 TBase (org.apache.thrift.TBase)3 Test (org.junit.Test)3 FutureListener (com.navercorp.pinpoint.rpc.FutureListener)2 ResponseMessage (com.navercorp.pinpoint.rpc.ResponseMessage)2 HeaderTBaseDeserializer (com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializer)2 TAgentInfo (com.navercorp.pinpoint.thrift.dto.TAgentInfo)1 TCommandEcho (com.navercorp.pinpoint.thrift.dto.command.TCommandEcho)1 TCommandTransfer (com.navercorp.pinpoint.thrift.dto.command.TCommandTransfer)1 PinpointRouteResponse (com.navercorp.pinpoint.web.cluster.PinpointRouteResponse)1 AgentInfo (com.navercorp.pinpoint.web.vo.AgentInfo)1 TException (org.apache.thrift.TException)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1