Search in sources :

Example 1 with AgentInfo

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();
        }
    }
}
Also used : AgentStatus(com.navercorp.pinpoint.web.vo.AgentStatus) AgentInfo(com.navercorp.pinpoint.web.vo.AgentInfo)

Example 2 with AgentInfo

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);
}
Also used : ApplicationAgentList(com.navercorp.pinpoint.web.vo.ApplicationAgentList) ArrayList(java.util.ArrayList) ApplicationAgentList(com.navercorp.pinpoint.web.vo.ApplicationAgentList) ArrayList(java.util.ArrayList) ApplicationAgentHostList(com.navercorp.pinpoint.web.vo.ApplicationAgentHostList) List(java.util.List) AgentInfo(com.navercorp.pinpoint.web.vo.AgentInfo) TreeMap(java.util.TreeMap)

Example 3 with AgentInfo

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;
    }
}
Also used : AgentInfo(com.navercorp.pinpoint.web.vo.AgentInfo)

Example 4 with 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());
    }
}
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 AgentInfo

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());
    }
}
Also used : AgentActiveThreadDumpList(com.navercorp.pinpoint.web.vo.AgentActiveThreadDumpList) TException(org.apache.thrift.TException) TCmdActiveThreadLightDump(com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadLightDump) AgentActiveThreadDumpFactory(com.navercorp.pinpoint.web.vo.AgentActiveThreadDumpFactory) TCmdActiveThreadLightDumpRes(com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadLightDumpRes) AgentInfo(com.navercorp.pinpoint.web.vo.AgentInfo) PinpointRouteResponse(com.navercorp.pinpoint.web.cluster.PinpointRouteResponse) TActiveThreadLightDump(com.navercorp.pinpoint.thrift.dto.command.TActiveThreadLightDump) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

AgentInfo (com.navercorp.pinpoint.web.vo.AgentInfo)25 AgentStatus (com.navercorp.pinpoint.web.vo.AgentStatus)7 PinpointRouteResponse (com.navercorp.pinpoint.web.cluster.PinpointRouteResponse)5 HashSet (java.util.HashSet)5 Test (org.junit.Test)5 AgentLifeCycleBo (com.navercorp.pinpoint.common.server.bo.AgentLifeCycleBo)4 Scan (org.apache.hadoop.hbase.client.Scan)4 ResultsExtractor (com.navercorp.pinpoint.common.hbase.ResultsExtractor)3 AgentLifeCycleState (com.navercorp.pinpoint.common.server.util.AgentLifeCycleState)3 ArrayList (java.util.ArrayList)3 TableName (org.apache.hadoop.hbase.TableName)3 TException (org.apache.thrift.TException)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 AgentInfoBo (com.navercorp.pinpoint.common.server.bo.AgentInfoBo)2 NodeHistogram (com.navercorp.pinpoint.web.applicationmap.histogram.NodeHistogram)2 DefaultPinpointRouteResponse (com.navercorp.pinpoint.web.cluster.DefaultPinpointRouteResponse)2 FailedPinpointRouteResponse (com.navercorp.pinpoint.web.cluster.FailedPinpointRouteResponse)2 AgentActiveThreadDumpFactory (com.navercorp.pinpoint.web.vo.AgentActiveThreadDumpFactory)2 AgentActiveThreadDumpList (com.navercorp.pinpoint.web.vo.AgentActiveThreadDumpList)2 ApplicationAgentHostList (com.navercorp.pinpoint.web.vo.ApplicationAgentHostList)2