Search in sources :

Example 1 with TCmdActiveThreadLightDumpRes

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

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

Example 3 with TCmdActiveThreadLightDumpRes

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

the class CommandGrpcToThriftMessageConverter method buildTCmdActiveThreadLightDumpRes.

private TCmdActiveThreadLightDumpRes buildTCmdActiveThreadLightDumpRes(PCmdActiveThreadLightDumpRes pCmdActiveThreadLightDumpRes) {
    TCmdActiveThreadLightDumpRes tCmdActiveThreadLightDumpRes = new TCmdActiveThreadLightDumpRes();
    tCmdActiveThreadLightDumpRes.setVersion(pCmdActiveThreadLightDumpRes.getVersion());
    tCmdActiveThreadLightDumpRes.setType(pCmdActiveThreadLightDumpRes.getType());
    tCmdActiveThreadLightDumpRes.setSubType(pCmdActiveThreadLightDumpRes.getSubType());
    for (PActiveThreadLightDump pActiveThreadLightDump : pCmdActiveThreadLightDumpRes.getThreadDumpList()) {
        tCmdActiveThreadLightDumpRes.addToThreadDumps(buildTActiveThreadLightDump(pActiveThreadLightDump));
    }
    return tCmdActiveThreadLightDumpRes;
}
Also used : TCmdActiveThreadLightDumpRes(com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadLightDumpRes) PActiveThreadLightDump(com.navercorp.pinpoint.grpc.trace.PActiveThreadLightDump)

Example 4 with TCmdActiveThreadLightDumpRes

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

the class ActiveThreadLightDumpServiceTest method basicFunctionTest4.

@Test
public void basicFunctionTest4() throws Exception {
    List<WaitingJob> waitingJobList = this.waitingJobListFactory.createList(CREATE_SIZE, JOB_TIMEOUT);
    List<ActiveTraceSnapshot> activeTraceInfoList = createMockActiveTraceInfoList(CREATE_SIZE, DEFAULT_TIME_MILLIS, TIME_DIFF_INTERVAL, waitingJobList);
    List<ActiveTraceSnapshot> activeTraceSnapshotList = shuffle(activeTraceInfoList);
    int targetThreadNameSize = 3;
    List<String> threadNameList = extractThreadNameList(activeTraceSnapshotList.subList(0, targetThreadNameSize), targetThreadNameSize);
    int targetTraceIdSize = 3;
    List<Long> localTraceIdList = extractLocalTraceIdList(activeTraceSnapshotList.subList(targetThreadNameSize, CREATE_SIZE), targetTraceIdSize);
    TCmdActiveThreadLightDump tCmdActiveThreadDump = createRequest(0, threadNameList, localTraceIdList);
    ActiveThreadLightDumpService service = createService(activeTraceInfoList);
    TCmdActiveThreadLightDumpRes response = (TCmdActiveThreadLightDumpRes) service.requestCommandService(tCmdActiveThreadDump);
    Assert.assertEquals(targetThreadNameSize + targetTraceIdSize, response.getThreadDumpsSize());
}
Also used : TCmdActiveThreadLightDump(com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadLightDump) TCmdActiveThreadLightDumpRes(com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadLightDumpRes) UnsampledActiveTraceSnapshot(com.navercorp.pinpoint.profiler.context.active.UnsampledActiveTraceSnapshot) ActiveTraceSnapshot(com.navercorp.pinpoint.profiler.context.active.ActiveTraceSnapshot) Test(org.junit.Test)

Example 5 with TCmdActiveThreadLightDumpRes

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

the class ActiveThreadLightDumpService method requestCommandService.

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

Aggregations

TCmdActiveThreadLightDumpRes (com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadLightDumpRes)10 TCmdActiveThreadLightDump (com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadLightDump)8 ActiveTraceSnapshot (com.navercorp.pinpoint.profiler.context.active.ActiveTraceSnapshot)5 UnsampledActiveTraceSnapshot (com.navercorp.pinpoint.profiler.context.active.UnsampledActiveTraceSnapshot)5 TActiveThreadLightDump (com.navercorp.pinpoint.thrift.dto.command.TActiveThreadLightDump)5 Test (org.junit.Test)5 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 PActiveThreadLightDump (com.navercorp.pinpoint.grpc.trace.PActiveThreadLightDump)1 CodeResult (com.navercorp.pinpoint.web.vo.CodeResult)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1