use of com.navercorp.pinpoint.web.vo.AgentActiveThreadDumpList 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.web.vo.AgentActiveThreadDumpList 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.web.vo.AgentActiveThreadDumpList in project pinpoint by naver.
the class AgentActiveThreadDumpListSerializerTest method serializeTest.
@Test
public void serializeTest() throws Exception {
ThreadInfo[] allThreadInfo = ThreadMXBeanUtils.dumpAllThread();
AgentActiveThreadDumpList activeThreadDumpList = createThreadDumpList(allThreadInfo);
String jsonValue = mapper.writeValueAsString(activeThreadDumpList);
List list = mapper.readValue(jsonValue, List.class);
Assert.assertTrue(CollectionUtils.isNotEmpty(list));
Map map = (Map) list.get(0);
Assert.assertTrue(map.containsKey("threadId"));
Assert.assertTrue(map.containsKey("threadName"));
Assert.assertTrue(map.containsKey("threadState"));
Assert.assertTrue(map.containsKey("startTime"));
Assert.assertTrue(map.containsKey("execTime"));
Assert.assertTrue(map.containsKey("localTraceId"));
Assert.assertTrue(map.containsKey("sampled"));
Assert.assertTrue(map.containsKey("transactionId"));
Assert.assertTrue(map.containsKey("entryPoint"));
Assert.assertTrue(map.containsKey("detailMessage"));
}
Aggregations