Search in sources :

Example 1 with TCmdActiveThreadDump

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

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

the class ActiveThreadDumpServiceTest method basicFunctionTest5.

@Test
public void basicFunctionTest5() throws Exception {
    List<WaitingJob> waitingJobList = createWaitingJobList(CREATE_SIZE);
    try {
        List<ActiveTraceInfo> activeTraceInfoList = createMockActiveTraceInfoList(CREATE_SIZE, DEFAULT_TIME_MILLIS, TIME_DIFF_INTERVAL, waitingJobList);
        int limit = 3;
        List<Long> oldTimeList = getOldTimeList(limit);
        TCmdActiveThreadDump tCmdActiveThreadDump = createRequest(limit, null, null);
        ActiveThreadDumpService service = createService(activeTraceInfoList);
        TCmdActiveThreadDumpRes response = (TCmdActiveThreadDumpRes) service.requestCommandService(tCmdActiveThreadDump);
        Assert.assertEquals(limit, response.getThreadDumpsSize());
        for (TActiveThreadDump dump : response.getThreadDumps()) {
            Assert.assertTrue(oldTimeList.contains(dump.getStartTime()));
        }
    } finally {
        clearResource(waitingJobList);
    }
}
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) ActiveTraceInfo(com.navercorp.pinpoint.profiler.context.active.ActiveTraceInfo) Test(org.junit.Test)

Example 3 with TCmdActiveThreadDump

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

the class ActiveThreadDumpServiceTest method basicFunctionTest3.

@Test
public void basicFunctionTest3() throws Exception {
    List<WaitingJob> waitingJobList = createWaitingJobList(CREATE_SIZE);
    try {
        int targetThreadNameSize = 3;
        List<ActiveTraceInfo> activeTraceInfoList = createMockActiveTraceInfoList(CREATE_SIZE, DEFAULT_TIME_MILLIS, TIME_DIFF_INTERVAL, waitingJobList);
        List<String> threadNameList = extractThreadNameList(activeTraceInfoList, targetThreadNameSize);
        TCmdActiveThreadDump tCmdActiveThreadDump = createRequest(0, threadNameList, null);
        ActiveThreadDumpService service = createService(activeTraceInfoList);
        TCmdActiveThreadDumpRes response = (TCmdActiveThreadDumpRes) service.requestCommandService(tCmdActiveThreadDump);
        Assert.assertEquals(3, response.getThreadDumpsSize());
    } finally {
        clearResource(waitingJobList);
    }
}
Also used : TCmdActiveThreadDump(com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadDump) TCmdActiveThreadDumpRes(com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadDumpRes) ActiveTraceInfo(com.navercorp.pinpoint.profiler.context.active.ActiveTraceInfo) Test(org.junit.Test)

Example 4 with TCmdActiveThreadDump

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

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

the class ActiveThreadDumpServiceTest method basicFunctionTest4.

@Test
public void basicFunctionTest4() throws Exception {
    List<WaitingJob> waitingJobList = createWaitingJobList(CREATE_SIZE);
    try {
        List<ActiveTraceInfo> activeTraceInfoList = createMockActiveTraceInfoList(CREATE_SIZE, DEFAULT_TIME_MILLIS, TIME_DIFF_INTERVAL, waitingJobList);
        List<ActiveTraceInfo> copied = shuffle(activeTraceInfoList);
        int targetThreadNameSize = 3;
        List<String> threadNameList = extractThreadNameList(copied.subList(0, targetThreadNameSize), targetThreadNameSize);
        int targetTraceIdSize = 3;
        List<Long> localTraceIdList = extractLocalTraceIdList(copied.subList(targetThreadNameSize, CREATE_SIZE), targetTraceIdSize);
        TCmdActiveThreadDump tCmdActiveThreadDump = createRequest(0, threadNameList, localTraceIdList);
        ActiveThreadDumpService service = createService(activeTraceInfoList);
        TCmdActiveThreadDumpRes response = (TCmdActiveThreadDumpRes) service.requestCommandService(tCmdActiveThreadDump);
        Assert.assertEquals(targetThreadNameSize + targetTraceIdSize, response.getThreadDumpsSize());
    } finally {
        clearResource(waitingJobList);
    }
}
Also used : TCmdActiveThreadDump(com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadDump) TCmdActiveThreadDumpRes(com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadDumpRes) ActiveTraceInfo(com.navercorp.pinpoint.profiler.context.active.ActiveTraceInfo) Test(org.junit.Test)

Aggregations

TCmdActiveThreadDump (com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadDump)6 TCmdActiveThreadDumpRes (com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadDumpRes)6 ActiveTraceInfo (com.navercorp.pinpoint.profiler.context.active.ActiveTraceInfo)4 Test (org.junit.Test)4 TActiveThreadDump (com.navercorp.pinpoint.thrift.dto.command.TActiveThreadDump)3 PinpointRouteResponse (com.navercorp.pinpoint.web.cluster.PinpointRouteResponse)1 AgentActiveThreadDumpFactory (com.navercorp.pinpoint.web.vo.AgentActiveThreadDumpFactory)1 AgentActiveThreadDumpList (com.navercorp.pinpoint.web.vo.AgentActiveThreadDumpList)1 AgentInfo (com.navercorp.pinpoint.web.vo.AgentInfo)1 TException (org.apache.thrift.TException)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1