use of com.navercorp.pinpoint.web.vo.AgentInfo in project pinpoint by naver.
the class ActiveThreadCountResponseAggregator method addWebSocketSession.
@Override
public void addWebSocketSession(WebSocketSession webSocketSession) {
if (webSocketSession == null) {
return;
}
logger.info("addWebSocketSession. applicationName:{}, webSocketSession:{}", applicationName, webSocketSession);
List<AgentInfo> agentInfoList = agentService.getRecentAgentInfoList(applicationName);
synchronized (workerManagingLock) {
if (isStopped) {
return;
}
for (AgentInfo agentInfo : agentInfoList) {
AgentStatus agentStatus = agentInfo.getStatus();
if (agentStatus != null && agentStatus.getState() != AgentLifeCycleState.UNKNOWN) {
activeWorker(agentInfo);
} else if (agentService.isConnected(agentInfo)) {
activeWorker(agentInfo);
}
}
boolean added = webSocketSessions.add(webSocketSession);
if (added && webSocketSessions.size() == 1) {
workerActiveManager.startAgentCheckJob();
}
}
}
use of com.navercorp.pinpoint.web.vo.AgentInfo in project pinpoint by naver.
the class AgentInfoServiceImpl method getApplicationAgentList.
@Override
public ApplicationAgentList getApplicationAgentList(ApplicationAgentList.Key applicationAgentListKey, String applicationName, long timestamp) {
if (applicationName == null) {
throw new NullPointerException("applicationName must not be null");
}
if (applicationAgentListKey == null) {
throw new NullPointerException("applicationAgentListKey must not be null");
}
final List<String> agentIdList = this.applicationIndexDao.selectAgentIds(applicationName);
if (logger.isDebugEnabled()) {
logger.debug("agentIdList={}", agentIdList);
}
if (CollectionUtils.isEmpty(agentIdList)) {
logger.debug("agentIdList is empty. applicationName={}", applicationName);
return new ApplicationAgentList(new TreeMap<String, List<AgentInfo>>());
}
// key = hostname
// value= list fo agentinfo
SortedMap<String, List<AgentInfo>> result = new TreeMap<>();
List<AgentInfo> agentInfos = this.agentInfoDao.getAgentInfos(agentIdList, timestamp);
this.agentLifeCycleDao.populateAgentStatuses(agentInfos, timestamp);
for (AgentInfo agentInfo : agentInfos) {
if (agentInfo != null) {
String hostname = applicationAgentListKey.getKey(agentInfo);
if (result.containsKey(hostname)) {
result.get(hostname).add(agentInfo);
} else {
List<AgentInfo> list = new ArrayList<>();
list.add(agentInfo);
result.put(hostname, list);
}
}
}
for (List<AgentInfo> agentInfoList : result.values()) {
Collections.sort(agentInfoList, AgentInfo.AGENT_NAME_ASC_COMPARATOR);
}
logger.info("getApplicationAgentList={}", result);
return new ApplicationAgentList(result);
}
use of com.navercorp.pinpoint.web.vo.AgentInfo in project pinpoint by naver.
the class AgentServiceImpl method getAgentInfo.
@Override
public AgentInfo getAgentInfo(String applicationName, String agentId, long startTimeStamp, boolean checkDB) {
if (checkDB) {
long currentTime = System.currentTimeMillis();
Set<AgentInfo> agentInfos = agentInfoService.getAgentsByApplicationName(applicationName, currentTime);
for (AgentInfo agentInfo : agentInfos) {
if (agentInfo == null) {
continue;
}
if (!agentInfo.getApplicationName().equals(applicationName)) {
continue;
}
if (!agentInfo.getAgentId().equals(agentId)) {
continue;
}
if (agentInfo.getStartTimestamp() != startTimeStamp) {
continue;
}
return agentInfo;
}
return null;
} else {
AgentInfo agentInfo = new AgentInfo();
agentInfo.setApplicationName(applicationName);
agentInfo.setAgentId(agentId);
agentInfo.setStartTimestamp(startTimeStamp);
return agentInfo;
}
}
use of com.navercorp.pinpoint.web.vo.AgentInfo 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.AgentInfo 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());
}
}
Aggregations