use of com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadLightDump in project pinpoint by naver.
the class ActiveThreadLightDumpServiceTest 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);
TCmdActiveThreadLightDump tCmdActiveThreadDump = createRequest(0, threadNameList, localTraceIdList);
ActiveThreadLightDumpService service = createService(activeTraceInfoList);
TCmdActiveThreadLightDumpRes response = (TCmdActiveThreadLightDumpRes) service.requestCommandService(tCmdActiveThreadDump);
Assert.assertEquals(targetThreadNameSize + targetTraceIdSize, response.getThreadDumpsSize());
} finally {
clearResource(waitingJobList);
}
}
use of com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadLightDump 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());
}
}
use of com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadLightDump 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;
}
use of com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadLightDump in project pinpoint by naver.
the class ActiveThreadLightDumpServiceTest 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);
TCmdActiveThreadLightDump tCmdActiveThreadDump = createRequest(limit, null, null);
ActiveThreadLightDumpService service = createService(activeTraceInfoList);
TCmdActiveThreadLightDumpRes response = (TCmdActiveThreadLightDumpRes) service.requestCommandService(tCmdActiveThreadDump);
Assert.assertEquals(limit, response.getThreadDumpsSize());
for (TActiveThreadLightDump dump : response.getThreadDumps()) {
Assert.assertTrue(oldTimeList.contains(dump.getStartTime()));
}
} finally {
clearResource(waitingJobList);
}
}
use of com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadLightDump in project pinpoint by naver.
the class ActiveThreadLightDumpServiceTest method basicFunctionTest2.
@Test
public void basicFunctionTest2() throws Exception {
List<WaitingJob> waitingJobList = createWaitingJobList(CREATE_SIZE);
try {
List<ActiveTraceInfo> activeTraceInfoList = createMockActiveTraceInfoList(CREATE_SIZE, DEFAULT_TIME_MILLIS, TIME_DIFF_INTERVAL, waitingJobList);
TCmdActiveThreadLightDump tCmdActiveThreadDump = createRequest(0, null, Arrays.asList(1L));
ActiveThreadLightDumpService service = createService(activeTraceInfoList);
TCmdActiveThreadLightDumpRes response = (TCmdActiveThreadLightDumpRes) service.requestCommandService(tCmdActiveThreadDump);
Assert.assertEquals(1, response.getThreadDumpsSize());
} finally {
clearResource(waitingJobList);
}
}
Aggregations