Search in sources :

Example 6 with PinpointRouteResponse

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());
    }
}
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

PinpointRouteResponse (com.navercorp.pinpoint.web.cluster.PinpointRouteResponse)6 AgentInfo (com.navercorp.pinpoint.web.vo.AgentInfo)5 DefaultPinpointRouteResponse (com.navercorp.pinpoint.web.cluster.DefaultPinpointRouteResponse)3 FailedPinpointRouteResponse (com.navercorp.pinpoint.web.cluster.FailedPinpointRouteResponse)3 TException (org.apache.thrift.TException)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 PinpointSocket (com.navercorp.pinpoint.rpc.PinpointSocket)2 ResponseMessage (com.navercorp.pinpoint.rpc.ResponseMessage)2 TCommandTransfer (com.navercorp.pinpoint.thrift.dto.command.TCommandTransfer)2 AgentActiveThreadDumpFactory (com.navercorp.pinpoint.web.vo.AgentActiveThreadDumpFactory)2 AgentActiveThreadDumpList (com.navercorp.pinpoint.web.vo.AgentActiveThreadDumpList)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Future (com.navercorp.pinpoint.rpc.Future)1 TResult (com.navercorp.pinpoint.thrift.dto.TResult)1 TActiveThreadDump (com.navercorp.pinpoint.thrift.dto.command.TActiveThreadDump)1 TActiveThreadLightDump (com.navercorp.pinpoint.thrift.dto.command.TActiveThreadLightDump)1 TCmdActiveThreadDump (com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadDump)1 TCmdActiveThreadDumpRes (com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadDumpRes)1 TCmdActiveThreadLightDump (com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadLightDump)1