Search in sources :

Example 21 with AgentInfo

use of com.navercorp.pinpoint.web.vo.AgentInfo in project pinpoint by naver.

the class CommandController method echo.

@RequestMapping(value = "/echo", method = RequestMethod.GET)
public ModelAndView echo(@RequestParam("applicationName") String applicationName, @RequestParam("agentId") String agentId, @RequestParam("startTimeStamp") long startTimeStamp, @RequestParam("message") String message) throws TException {
    AgentInfo agentInfo = agentService.getAgentInfo(applicationName, agentId, startTimeStamp);
    if (agentInfo == null) {
        return createResponse(false, String.format("Can't find suitable PinpointServer(%s/%s/%d).", applicationName, agentId, startTimeStamp));
    }
    TCommandEcho echo = new TCommandEcho();
    echo.setMessage(message);
    try {
        PinpointRouteResponse pinpointRouteResponse = agentService.invoke(agentInfo, echo);
        if (pinpointRouteResponse != null && pinpointRouteResponse.getRouteResult() == TRouteResult.OK) {
            TBase<?, ?> result = pinpointRouteResponse.getResponse();
            if (result == null) {
                return createResponse(false, "result null.");
            } else if (result instanceof TCommandEcho) {
                return createResponse(true, ((TCommandEcho) result).getMessage());
            } else if (result instanceof TResult) {
                return createResponse(false, ((TResult) result).getMessage());
            } else {
                return createResponse(false, result.toString());
            }
        } else {
            return createResponse(false, "unknown");
        }
    } catch (TException e) {
        return createResponse(false, e.getMessage());
    }
}
Also used : TException(org.apache.thrift.TException) TCommandEcho(com.navercorp.pinpoint.thrift.dto.command.TCommandEcho) AgentInfo(com.navercorp.pinpoint.web.vo.AgentInfo) PinpointRouteResponse(com.navercorp.pinpoint.web.cluster.PinpointRouteResponse) TResult(com.navercorp.pinpoint.thrift.dto.TResult) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 22 with AgentInfo

use of com.navercorp.pinpoint.web.vo.AgentInfo in project pinpoint by naver.

the class HbaseAgentLifeCycleDao method populateAgentStatuses.

@Override
public void populateAgentStatuses(Collection<AgentInfo> agentInfos, long timestamp) {
    if (CollectionUtils.isEmpty(agentInfos)) {
        return;
    }
    List<Scan> scans = new ArrayList<>(agentInfos.size());
    for (AgentInfo agentInfo : agentInfos) {
        if (agentInfo != null) {
            final String agentId = agentInfo.getAgentId();
            // startTimestamp is stored in reverse order
            final long toTimestamp = agentInfo.getStartTimestamp();
            final long fromTimestamp = toTimestamp - 1;
            scans.add(createScan(agentId, fromTimestamp, toTimestamp));
        }
    }
    List<AgentLifeCycleBo> agentLifeCycles = this.hbaseOperations2.findParallel(HBaseTables.AGENT_LIFECYCLE, scans, new MostRecentAgentLifeCycleResultsExtractor(this.agentLifeCycleMapper, timestamp));
    int idx = 0;
    for (AgentInfo agentInfo : agentInfos) {
        if (agentInfo != null) {
            AgentStatus agentStatus = createAgentStatus(agentInfo.getAgentId(), agentLifeCycles.get(idx++));
            agentInfo.setStatus(agentStatus);
        }
    }
}
Also used : AgentStatus(com.navercorp.pinpoint.web.vo.AgentStatus) ArrayList(java.util.ArrayList) Scan(org.apache.hadoop.hbase.client.Scan) AgentInfo(com.navercorp.pinpoint.web.vo.AgentInfo) AgentLifeCycleBo(com.navercorp.pinpoint.common.server.bo.AgentLifeCycleBo)

Example 23 with AgentInfo

use of com.navercorp.pinpoint.web.vo.AgentInfo in project pinpoint by naver.

the class ApplicationMapBuilder method build.

/**
     * Returns an application map with a single node containing the application's agents that were running.
     */
public ApplicationMap build(Application application, AgentInfoService agentInfoService) {
    NodeList nodeList = new NodeList();
    LinkList emptyLinkList = new LinkList();
    Node node = new Node(application);
    Set<AgentInfo> agentInfos = agentInfoService.getAgentsByApplicationName(application.getName(), range.getTo());
    Set<AgentInfo> runningAgents = new HashSet<>();
    for (AgentInfo agentInfo : agentInfos) {
        if (isAgentRunning(agentInfo)) {
            runningAgents.add(agentInfo);
        }
    }
    if (runningAgents.isEmpty()) {
        return new DefaultApplicationMap(range, nodeList, emptyLinkList);
    } else {
        ServerBuilder serverBuilder = new ServerBuilder();
        serverBuilder.addAgentInfo(runningAgents);
        ServerInstanceList serverInstanceList = serverBuilder.build();
        node.setServerInstanceList(serverInstanceList);
        node.setNodeHistogram(new NodeHistogram(application, range));
        nodeList.addNode(node);
        return new DefaultApplicationMap(range, nodeList, emptyLinkList);
    }
}
Also used : AgentInfo(com.navercorp.pinpoint.web.vo.AgentInfo) NodeHistogram(com.navercorp.pinpoint.web.applicationmap.histogram.NodeHistogram) HashSet(java.util.HashSet)

Example 24 with AgentInfo

use of com.navercorp.pinpoint.web.vo.AgentInfo in project pinpoint by naver.

the class ServerBuilder method buildPhysicalServer.

public ServerInstanceList buildPhysicalServer(final Set<AgentInfo> agentSet) {
    final ServerInstanceList serverInstanceList = new ServerInstanceList();
    for (AgentInfo agent : agentSet) {
        final ServerInstance serverInstance = new ServerInstance(agent);
        serverInstanceList.addServerInstance(serverInstance);
    }
    return serverInstanceList;
}
Also used : AgentInfo(com.navercorp.pinpoint.web.vo.AgentInfo)

Example 25 with AgentInfo

use of com.navercorp.pinpoint.web.vo.AgentInfo in project pinpoint by naver.

the class AgentInfoMapper method mapRow.

@Override
public AgentInfo mapRow(Result result, int rowNum) throws Exception {
    byte[] rowKey = result.getRow();
    String agentId = BytesUtils.safeTrim(BytesUtils.toString(rowKey, 0, PinpointConstants.AGENT_NAME_MAX_LEN));
    long reverseStartTime = BytesUtils.bytesToLong(rowKey, HBaseTables.AGENT_NAME_MAX_LEN);
    long startTime = TimeUtils.recoveryTimeMillis(reverseStartTime);
    byte[] serializedAgentInfo = result.getValue(HBaseTables.AGENTINFO_CF_INFO, HBaseTables.AGENTINFO_CF_INFO_IDENTIFIER);
    byte[] serializedServerMetaData = result.getValue(HBaseTables.AGENTINFO_CF_INFO, HBaseTables.AGENTINFO_CF_INFO_SERVER_META_DATA);
    byte[] serializedJvmInfo = result.getValue(HBaseTables.AGENTINFO_CF_INFO, HBaseTables.AGENTINFO_CF_INFO_JVM);
    final AgentInfoBo.Builder agentInfoBoBuilder = createBuilderFromValue(serializedAgentInfo);
    agentInfoBoBuilder.setAgentId(agentId);
    agentInfoBoBuilder.setStartTime(startTime);
    if (serializedServerMetaData != null) {
        agentInfoBoBuilder.setServerMetaData(new ServerMetaDataBo.Builder(serializedServerMetaData).build());
    }
    if (serializedJvmInfo != null) {
        agentInfoBoBuilder.setJvmInfo(new JvmInfoBo(serializedJvmInfo));
    }
    return new AgentInfo(agentInfoBoBuilder.build());
}
Also used : AgentInfoBo(com.navercorp.pinpoint.common.server.bo.AgentInfoBo) JvmInfoBo(com.navercorp.pinpoint.common.server.bo.JvmInfoBo) AgentInfo(com.navercorp.pinpoint.web.vo.AgentInfo)

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