Search in sources :

Example 1 with TActiveThreadDump

use of com.navercorp.pinpoint.thrift.dto.command.TActiveThreadDump 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 TActiveThreadDump

use of com.navercorp.pinpoint.thrift.dto.command.TActiveThreadDump in project pinpoint by naver.

the class ActiveThreadDumpService method requestCommandService.

@Override
public TBase<?, ?> requestCommandService(TBase tBase) {
    TCmdActiveThreadDump request = (TCmdActiveThreadDump) tBase;
    List<TActiveThreadDump> activeThreadDumpList = getActiveThreadDumpList(request);
    TCmdActiveThreadDumpRes response = new TCmdActiveThreadDumpRes();
    response.setType("JAVA");
    response.setSubType(JvmUtils.getType().name());
    response.setVersion(JvmUtils.getVersion().name());
    response.setThreadDumps(activeThreadDumpList);
    return response;
}
Also used : TCmdActiveThreadDump(com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadDump) TCmdActiveThreadDumpRes(com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadDumpRes) TActiveThreadDump(com.navercorp.pinpoint.thrift.dto.command.TActiveThreadDump)

Example 3 with TActiveThreadDump

use of com.navercorp.pinpoint.thrift.dto.command.TActiveThreadDump in project pinpoint by naver.

the class ActiveThreadDumpService method getActiveThreadDumpList.

private List<TActiveThreadDump> getActiveThreadDumpList(TCmdActiveThreadDump request, int limit, List<ActiveTraceInfo> activeTraceInfoList) {
    int targetThreadNameListSize = request.getThreadNameListSize();
    int localTraceIdListSize = request.getLocalTraceIdListSize();
    boolean filterEnable = (targetThreadNameListSize + localTraceIdListSize) > 0;
    List<TActiveThreadDump> activeThreadDumpList = new ArrayList<TActiveThreadDump>(Math.min(limit, activeTraceInfoList.size()));
    if (filterEnable) {
        for (ActiveTraceInfo activeTraceInfo : activeTraceInfoList) {
            if (!ActiveThreadDumpUtils.isTraceThread(activeTraceInfo, request.getThreadNameList(), request.getLocalTraceIdList())) {
                continue;
            }
            TActiveThreadDump activeThreadDump = createActiveThreadDump(activeTraceInfo);
            if (activeThreadDump != null) {
                if (limit > activeThreadDumpList.size()) {
                    activeThreadDumpList.add(activeThreadDump);
                }
            }
        }
    } else {
        for (ActiveTraceInfo activeTraceInfo : activeTraceInfoList) {
            TActiveThreadDump activeThreadDump = createActiveThreadDump(activeTraceInfo);
            if (activeThreadDump != null) {
                if (limit > activeThreadDumpList.size()) {
                    activeThreadDumpList.add(activeThreadDump);
                }
            }
        }
    }
    return activeThreadDumpList;
}
Also used : ArrayList(java.util.ArrayList) TActiveThreadDump(com.navercorp.pinpoint.thrift.dto.command.TActiveThreadDump) ActiveTraceInfo(com.navercorp.pinpoint.profiler.context.active.ActiveTraceInfo)

Example 4 with TActiveThreadDump

use of com.navercorp.pinpoint.thrift.dto.command.TActiveThreadDump in project pinpoint by naver.

the class ActiveThreadDumpService method toTActiveThreadDump.

private List<TActiveThreadDump> toTActiveThreadDump(Collection<ThreadDump> activeTraceInfoList) {
    final List<TActiveThreadDump> result = new ArrayList<TActiveThreadDump>(activeTraceInfoList.size());
    for (ThreadDump threadDump : activeTraceInfoList) {
        TActiveThreadDump tActiveThreadDump = createTActiveThreadDump(threadDump);
        result.add(tActiveThreadDump);
    }
    return result;
}
Also used : TCmdActiveThreadDump(com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadDump) TThreadDump(com.navercorp.pinpoint.thrift.dto.command.TThreadDump) TActiveThreadDump(com.navercorp.pinpoint.thrift.dto.command.TActiveThreadDump) ArrayList(java.util.ArrayList) TActiveThreadDump(com.navercorp.pinpoint.thrift.dto.command.TActiveThreadDump)

Example 5 with TActiveThreadDump

use of com.navercorp.pinpoint.thrift.dto.command.TActiveThreadDump in project pinpoint by naver.

the class ActiveThreadDumpService method requestCommandService.

@Override
public TBase<?, ?> requestCommandService(TBase<?, ?> tBase) {
    TCmdActiveThreadDump request = (TCmdActiveThreadDump) tBase;
    List<TActiveThreadDump> activeThreadDumpList = getActiveThreadDumpList(request);
    TCmdActiveThreadDumpRes response = new TCmdActiveThreadDumpRes();
    response.setType(JAVA);
    response.setSubType(JvmUtils.getType().name());
    response.setVersion(JvmUtils.getVersion().name());
    response.setThreadDumps(activeThreadDumpList);
    return response;
}
Also used : TCmdActiveThreadDump(com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadDump) TCmdActiveThreadDumpRes(com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadDumpRes) TActiveThreadDump(com.navercorp.pinpoint.thrift.dto.command.TActiveThreadDump)

Aggregations

TActiveThreadDump (com.navercorp.pinpoint.thrift.dto.command.TActiveThreadDump)13 TCmdActiveThreadDump (com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadDump)6 TCmdActiveThreadDumpRes (com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadDumpRes)5 TThreadDump (com.navercorp.pinpoint.thrift.dto.command.TThreadDump)4 ArrayList (java.util.ArrayList)4 ThreadDumpMetricSnapshot (com.navercorp.pinpoint.profiler.monitor.metric.deadlock.ThreadDumpMetricSnapshot)3 AgentActiveThreadDumpFactory (com.navercorp.pinpoint.web.vo.AgentActiveThreadDumpFactory)3 ActiveTraceSnapshot (com.navercorp.pinpoint.profiler.context.active.ActiveTraceSnapshot)2 PinpointRouteResponse (com.navercorp.pinpoint.web.cluster.PinpointRouteResponse)2 AgentActiveThreadDumpList (com.navercorp.pinpoint.web.vo.AgentActiveThreadDumpList)2 AgentInfo (com.navercorp.pinpoint.web.vo.AgentInfo)2 ThreadInfo (java.lang.management.ThreadInfo)2 TException (org.apache.thrift.TException)2 ActiveTraceInfo (com.navercorp.pinpoint.profiler.context.active.ActiveTraceInfo)1 UnsampledActiveTraceSnapshot (com.navercorp.pinpoint.profiler.context.active.UnsampledActiveTraceSnapshot)1 CodeResult (com.navercorp.pinpoint.web.vo.CodeResult)1 Test (org.junit.Test)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1