use of com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadDumpRes 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;
}
use of com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadDumpRes 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);
}
}
use of com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadDumpRes 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);
}
}
use of com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadDumpRes 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());
}
}
use of com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadDumpRes in project pinpoint by naver.
the class ActiveThreadDumpServiceTest method basicFunctionTest1.
@Test
public void basicFunctionTest1() throws Exception {
List<WaitingJob> waitingJobList = createWaitingJobList(CREATE_SIZE);
try {
List<ActiveTraceInfo> activeTraceInfoList = createMockActiveTraceInfoList(CREATE_SIZE, DEFAULT_TIME_MILLIS, TIME_DIFF_INTERVAL, waitingJobList);
ActiveThreadDumpService service = createService(activeTraceInfoList);
TCmdActiveThreadDumpRes response = (TCmdActiveThreadDumpRes) service.requestCommandService(createRequest(0, null, null));
Assert.assertEquals(CREATE_SIZE, response.getThreadDumpsSize());
} finally {
clearResource(waitingJobList);
}
}
Aggregations