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());
}
}
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);
}
}
}
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);
}
}
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;
}
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());
}
Aggregations