Search in sources :

Example 1 with TActiveThreadLightDump

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

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

the class ActiveThreadLightDumpService method createActiveThreadDump.

private TActiveThreadLightDump createActiveThreadDump(ActiveTraceInfo activeTraceInfo, TThreadLightDump threadDump) {
    TActiveThreadLightDump activeThreadDump = new TActiveThreadLightDump();
    activeThreadDump.setStartTime(activeTraceInfo.getStartTime());
    activeThreadDump.setLocalTraceId(activeTraceInfo.getLocalTraceId());
    activeThreadDump.setThreadDump(threadDump);
    if (activeTraceInfo.isSampled()) {
        activeThreadDump.setSampled(true);
        activeThreadDump.setTransactionId(activeTraceInfo.getTransactionId());
        activeThreadDump.setEntryPoint(activeTraceInfo.getEntryPoint());
    }
    return activeThreadDump;
}
Also used : TActiveThreadLightDump(com.navercorp.pinpoint.thrift.dto.command.TActiveThreadLightDump)

Example 3 with TActiveThreadLightDump

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

the class ActiveThreadLightDumpService method toTActiveThreadLightDump.

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

Example 4 with TActiveThreadLightDump

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

the class ActiveThreadLightDumpService method createActiveThreadDump.

private TActiveThreadLightDump createActiveThreadDump(ThreadDump threadDump) {
    final ActiveTraceSnapshot activeTraceInfo = threadDump.getActiveTraceSnapshot();
    final ThreadInfo threadInfo = threadDump.getThreadInfo();
    TThreadLightDump tThreadLightDump = createTThreadLightDump(threadInfo);
    TActiveThreadLightDump activeThreadDump = new TActiveThreadLightDump();
    activeThreadDump.setStartTime(activeTraceInfo.getStartTime());
    activeThreadDump.setLocalTraceId(activeTraceInfo.getLocalTransactionId());
    activeThreadDump.setThreadDump(tThreadLightDump);
    if (activeTraceInfo.isSampled()) {
        activeThreadDump.setSampled(true);
        activeThreadDump.setTransactionId(activeTraceInfo.getTransactionId());
        activeThreadDump.setEntryPoint(activeTraceInfo.getEntryPoint());
    }
    return activeThreadDump;
}
Also used : ThreadInfo(java.lang.management.ThreadInfo) ActiveTraceSnapshot(com.navercorp.pinpoint.profiler.context.active.ActiveTraceSnapshot) TThreadLightDump(com.navercorp.pinpoint.thrift.dto.command.TThreadLightDump) TActiveThreadLightDump(com.navercorp.pinpoint.thrift.dto.command.TActiveThreadLightDump)

Example 5 with TActiveThreadLightDump

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

the class AgentCommandController method getActiveThreadLightDump.

@GetMapping(value = "/activeThreadLightDump")
public CodeResult 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 new CodeResult(CODE_FAIL, "Disable activeThreadDump option. 'config.enable.activeThreadDump=false'");
    }
    AgentInfo agentInfo = agentService.getAgentInfo(applicationName, agentId);
    if (agentInfo == null) {
        return new CodeResult(CODE_FAIL, 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 new CodeResult(CODE_SUCCESS, responseData);
            }
        }
        return handleFailedResponse(pinpointRouteResponse);
    } catch (TException e) {
        return new CodeResult(CODE_FAIL, e.getMessage());
    }
}
Also used : AgentActiveThreadDumpList(com.navercorp.pinpoint.web.vo.AgentActiveThreadDumpList) TException(org.apache.thrift.TException) TCmdActiveThreadLightDump(com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadLightDump) CodeResult(com.navercorp.pinpoint.web.vo.CodeResult) 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) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Aggregations

TActiveThreadLightDump (com.navercorp.pinpoint.thrift.dto.command.TActiveThreadLightDump)12 TCmdActiveThreadLightDump (com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadLightDump)5 TCmdActiveThreadLightDumpRes (com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadLightDumpRes)5 ArrayList (java.util.ArrayList)3 ActiveTraceSnapshot (com.navercorp.pinpoint.profiler.context.active.ActiveTraceSnapshot)2 PinpointRouteResponse (com.navercorp.pinpoint.web.cluster.PinpointRouteResponse)2 AgentActiveThreadDumpFactory (com.navercorp.pinpoint.web.vo.AgentActiveThreadDumpFactory)2 AgentActiveThreadDumpList (com.navercorp.pinpoint.web.vo.AgentActiveThreadDumpList)2 AgentInfo (com.navercorp.pinpoint.web.vo.AgentInfo)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 TThreadLightDump (com.navercorp.pinpoint.thrift.dto.command.TThreadLightDump)1 CodeResult (com.navercorp.pinpoint.web.vo.CodeResult)1 ThreadInfo (java.lang.management.ThreadInfo)1 Test (org.junit.Test)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1