Search in sources :

Example 1 with PinpointRouteResponse

use of com.navercorp.pinpoint.web.cluster.PinpointRouteResponse in project pinpoint by naver.

the class AgentCommandController method getActiveThreadDump.

@RequestMapping(value = "/activeThreadDump", method = RequestMethod.GET)
public ModelAndView getActiveThreadDump(@RequestParam(value = "applicationName") String applicationName, @RequestParam(value = "agentId") String agentId, @RequestParam(value = "limit", required = false, defaultValue = "-1") int limit, @RequestParam(value = "threadName", required = false) String[] threadNameList, @RequestParam(value = "localTraceId", required = false) Long[] localTraceIdList) throws TException {
    if (!webProperties.isEnableActiveThreadDump()) {
        return createResponse(false, "Disable activeThreadDump option. 'config.enable.activeThreadDump=false'");
    }
    AgentInfo agentInfo = agentService.getAgentInfo(applicationName, agentId);
    if (agentInfo == null) {
        return createResponse(false, String.format("Can't find suitable Agent(%s/%s)", applicationName, agentId));
    }
    TCmdActiveThreadDump threadDump = new TCmdActiveThreadDump();
    if (limit > 0) {
        threadDump.setLimit(limit);
    }
    if (threadNameList != null) {
        threadDump.setThreadNameList(Arrays.asList(threadNameList));
    }
    if (localTraceIdList != null) {
        threadDump.setLocalTraceIdList(Arrays.asList(localTraceIdList));
    }
    try {
        PinpointRouteResponse pinpointRouteResponse = agentService.invoke(agentInfo, threadDump);
        if (isSuccessResponse(pinpointRouteResponse)) {
            TBase<?, ?> result = pinpointRouteResponse.getResponse();
            if (result instanceof TCmdActiveThreadDumpRes) {
                TCmdActiveThreadDumpRes activeThreadDumpResponse = (TCmdActiveThreadDumpRes) result;
                List<TActiveThreadDump> activeThreadDumps = activeThreadDumpResponse.getThreadDumps();
                AgentActiveThreadDumpFactory factory = new AgentActiveThreadDumpFactory();
                AgentActiveThreadDumpList activeThreadDumpList = factory.create1(activeThreadDumps);
                Map<String, Object> responseData = createResponseData(activeThreadDumpList, activeThreadDumpResponse.getType(), activeThreadDumpResponse.getSubType(), activeThreadDumpResponse.getVersion());
                return createResponse(true, responseData);
            }
        }
        return handleFailedResponse(pinpointRouteResponse);
    } catch (TException e) {
        return createResponse(false, e.getMessage());
    }
}
Also used : AgentActiveThreadDumpList(com.navercorp.pinpoint.web.vo.AgentActiveThreadDumpList) TException(org.apache.thrift.TException) TCmdActiveThreadDumpRes(com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadDumpRes) AgentActiveThreadDumpFactory(com.navercorp.pinpoint.web.vo.AgentActiveThreadDumpFactory) AgentInfo(com.navercorp.pinpoint.web.vo.AgentInfo) TCmdActiveThreadDump(com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadDump) PinpointRouteResponse(com.navercorp.pinpoint.web.cluster.PinpointRouteResponse) TActiveThreadDump(com.navercorp.pinpoint.thrift.dto.command.TActiveThreadDump) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with PinpointRouteResponse

use of com.navercorp.pinpoint.web.cluster.PinpointRouteResponse in project pinpoint by naver.

the class AgentCommandController method getActiveThreadLightDump.

@RequestMapping(value = "/activeThreadLightDump", method = RequestMethod.GET)
public ModelAndView getActiveThreadLightDump(@RequestParam(value = "applicationName") String applicationName, @RequestParam(value = "agentId") String agentId, @RequestParam(value = "limit", required = false, defaultValue = "-1") int limit, @RequestParam(value = "threadName", required = false) String[] threadNameList, @RequestParam(value = "localTraceId", required = false) Long[] localTraceIdList) throws TException {
    if (!webProperties.isEnableActiveThreadDump()) {
        return createResponse(false, "Disable activeThreadDump option. 'config.enable.activeThreadDump=false'");
    }
    AgentInfo agentInfo = agentService.getAgentInfo(applicationName, agentId);
    if (agentInfo == null) {
        return createResponse(false, String.format("Can't find suitable Agent(%s/%s)", applicationName, agentId));
    }
    TCmdActiveThreadLightDump threadDump = new TCmdActiveThreadLightDump();
    if (limit > 0) {
        threadDump.setLimit(limit);
    }
    if (threadNameList != null) {
        threadDump.setThreadNameList(Arrays.asList(threadNameList));
    }
    if (localTraceIdList != null) {
        threadDump.setLocalTraceIdList(Arrays.asList(localTraceIdList));
    }
    try {
        PinpointRouteResponse pinpointRouteResponse = agentService.invoke(agentInfo, threadDump);
        if (isSuccessResponse(pinpointRouteResponse)) {
            TBase<?, ?> result = pinpointRouteResponse.getResponse();
            if (result instanceof TCmdActiveThreadLightDumpRes) {
                TCmdActiveThreadLightDumpRes activeThreadDumpResponse = (TCmdActiveThreadLightDumpRes) result;
                List<TActiveThreadLightDump> activeThreadDumps = activeThreadDumpResponse.getThreadDumps();
                AgentActiveThreadDumpFactory factory = new AgentActiveThreadDumpFactory();
                AgentActiveThreadDumpList activeThreadDumpList = factory.create2(activeThreadDumps);
                Map<String, Object> responseData = createResponseData(activeThreadDumpList, activeThreadDumpResponse.getType(), activeThreadDumpResponse.getSubType(), activeThreadDumpResponse.getVersion());
                return createResponse(true, responseData);
            }
        }
        return handleFailedResponse(pinpointRouteResponse);
    } catch (TException e) {
        return createResponse(false, e.getMessage());
    }
}
Also used : AgentActiveThreadDumpList(com.navercorp.pinpoint.web.vo.AgentActiveThreadDumpList) TException(org.apache.thrift.TException) TCmdActiveThreadLightDump(com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadLightDump) AgentActiveThreadDumpFactory(com.navercorp.pinpoint.web.vo.AgentActiveThreadDumpFactory) TCmdActiveThreadLightDumpRes(com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadLightDumpRes) AgentInfo(com.navercorp.pinpoint.web.vo.AgentInfo) PinpointRouteResponse(com.navercorp.pinpoint.web.cluster.PinpointRouteResponse) TActiveThreadLightDump(com.navercorp.pinpoint.thrift.dto.command.TActiveThreadLightDump) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with PinpointRouteResponse

use of com.navercorp.pinpoint.web.cluster.PinpointRouteResponse in project pinpoint by naver.

the class AgentServiceImpl method getActiveThreadCount.

@Override
public AgentActiveThreadCountList getActiveThreadCount(List<AgentInfo> agentInfoList, byte[] payload) throws TException {
    AgentActiveThreadCountList activeThreadCountList = new AgentActiveThreadCountList(agentInfoList.size());
    Map<AgentInfo, PinpointRouteResponse> responseList = invoke(agentInfoList, payload);
    for (Map.Entry<AgentInfo, PinpointRouteResponse> entry : responseList.entrySet()) {
        AgentInfo agentInfo = entry.getKey();
        PinpointRouteResponse response = entry.getValue();
        AgentActiveThreadCount activeThreadCount = createActiveThreadCount(agentInfo.getAgentId(), response);
        activeThreadCountList.add(activeThreadCount);
    }
    return activeThreadCountList;
}
Also used : AgentActiveThreadCount(com.navercorp.pinpoint.web.vo.AgentActiveThreadCount) AgentActiveThreadCountList(com.navercorp.pinpoint.web.vo.AgentActiveThreadCountList) AgentInfo(com.navercorp.pinpoint.web.vo.AgentInfo) PinpointRouteResponse(com.navercorp.pinpoint.web.cluster.PinpointRouteResponse) FailedPinpointRouteResponse(com.navercorp.pinpoint.web.cluster.FailedPinpointRouteResponse) DefaultPinpointRouteResponse(com.navercorp.pinpoint.web.cluster.DefaultPinpointRouteResponse) HashMap(java.util.HashMap) Map(java.util.Map)

Example 4 with PinpointRouteResponse

use of com.navercorp.pinpoint.web.cluster.PinpointRouteResponse in project pinpoint by naver.

the class AgentServiceImpl method invoke.

@Override
public PinpointRouteResponse invoke(AgentInfo agentInfo, byte[] payload, long timeout) throws TException {
    TCommandTransfer transferObject = createCommandTransferObject(agentInfo, payload);
    PinpointSocket socket = clusterManager.getSocket(agentInfo);
    Future<ResponseMessage> future = null;
    if (socket != null) {
        future = socket.request(serializeRequest(transferObject));
    }
    PinpointRouteResponse response = getResponse(future, timeout);
    return response;
}
Also used : TCommandTransfer(com.navercorp.pinpoint.thrift.dto.command.TCommandTransfer) PinpointSocket(com.navercorp.pinpoint.rpc.PinpointSocket) PinpointRouteResponse(com.navercorp.pinpoint.web.cluster.PinpointRouteResponse) FailedPinpointRouteResponse(com.navercorp.pinpoint.web.cluster.FailedPinpointRouteResponse) DefaultPinpointRouteResponse(com.navercorp.pinpoint.web.cluster.DefaultPinpointRouteResponse) ResponseMessage(com.navercorp.pinpoint.rpc.ResponseMessage)

Example 5 with PinpointRouteResponse

use of com.navercorp.pinpoint.web.cluster.PinpointRouteResponse in project pinpoint by naver.

the class AgentServiceImpl method invoke.

@Override
public Map<AgentInfo, PinpointRouteResponse> invoke(List<AgentInfo> agentInfoList, byte[] payload, long timeout) throws TException {
    Map<AgentInfo, Future<ResponseMessage>> futureMap = new HashMap<>();
    for (AgentInfo agentInfo : agentInfoList) {
        TCommandTransfer transferObject = createCommandTransferObject(agentInfo, payload);
        PinpointSocket socket = clusterManager.getSocket(agentInfo);
        if (socket != null) {
            Future<ResponseMessage> future = socket.request(serializeRequest(transferObject));
            futureMap.put(agentInfo, future);
        } else {
            futureMap.put(agentInfo, null);
        }
    }
    long startTime = System.currentTimeMillis();
    Map<AgentInfo, PinpointRouteResponse> result = new HashMap<>();
    for (Map.Entry<AgentInfo, Future<ResponseMessage>> futureEntry : futureMap.entrySet()) {
        AgentInfo agentInfo = futureEntry.getKey();
        Future<ResponseMessage> future = futureEntry.getValue();
        PinpointRouteResponse response = getResponse(future, getTimeoutMillis(startTime, timeout));
        result.put(agentInfo, response);
    }
    return result;
}
Also used : TCommandTransfer(com.navercorp.pinpoint.thrift.dto.command.TCommandTransfer) HashMap(java.util.HashMap) ResponseMessage(com.navercorp.pinpoint.rpc.ResponseMessage) PinpointSocket(com.navercorp.pinpoint.rpc.PinpointSocket) Future(com.navercorp.pinpoint.rpc.Future) AgentInfo(com.navercorp.pinpoint.web.vo.AgentInfo) PinpointRouteResponse(com.navercorp.pinpoint.web.cluster.PinpointRouteResponse) FailedPinpointRouteResponse(com.navercorp.pinpoint.web.cluster.FailedPinpointRouteResponse) DefaultPinpointRouteResponse(com.navercorp.pinpoint.web.cluster.DefaultPinpointRouteResponse) HashMap(java.util.HashMap) Map(java.util.Map)

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