use of com.navercorp.pinpoint.web.applicationmap.nodes.ServerBuilder in project pinpoint by naver.
the class AgentInfoServerInstanceListDataSource method createServerInstanceList.
public ServerInstanceList createServerInstanceList(Node node, long timestamp) {
Objects.requireNonNull(node, "node");
if (timestamp < 0) {
return new ServerInstanceList();
}
Application application = node.getApplication();
Set<AgentInfo> agentInfos = agentInfoService.getAgentsByApplicationNameWithoutStatus(application.getName(), timestamp);
if (CollectionUtils.isEmpty(agentInfos)) {
logger.warn("agentInfo not found. application:{}", application);
return new ServerInstanceList();
}
logger.debug("unfiltered agentInfos {}", agentInfos);
agentInfos = filterAgentInfos(agentInfos, timestamp, node);
logger.debug("add agentInfos {} : {}", application, agentInfos);
ServerBuilder builder = new ServerBuilder();
builder.addAgentInfo(agentInfos);
return builder.build();
}
use of com.navercorp.pinpoint.web.applicationmap.nodes.ServerBuilder in project pinpoint by naver.
the class ServerInstanceListSerializerTest method testSerialize.
@Test
public void testSerialize() throws Exception {
ObjectMapper mapper = createMapper();
AgentInfo agentInfo = ServerInstanceListTest.createAgentInfo("agentId1", "testHost");
Set<AgentInfo> agentInfoSet = new HashSet<>();
agentInfoSet.add(agentInfo);
ServerBuilder builder = new ServerBuilder();
builder.addAgentInfo(agentInfoSet);
ServerInstanceList serverInstanceList = builder.build();
ObjectWriter objectWriter = mapper.writerWithDefaultPrettyPrinter();
String json = objectWriter.writeValueAsString(serverInstanceList);
logger.debug(json);
}
use of com.navercorp.pinpoint.web.applicationmap.nodes.ServerBuilder in project pinpoint by naver.
the class ServerInstanceListTest method testGetAgentIdList.
@Test
public void testGetAgentIdList() {
AgentInfo agentInfo1 = createAgentInfo("agentId1", "testHost");
AgentInfo agentInfo2 = createAgentInfo("agentId2", "testHost");
Set<AgentInfo> agentInfoSet = new HashSet<>();
agentInfoSet.add(agentInfo1);
agentInfoSet.add(agentInfo2);
ServerBuilder builder = new ServerBuilder();
builder.addAgentInfo(agentInfoSet);
ServerInstanceList serverInstanceList = builder.build();
List<String> agentIdList = serverInstanceList.getAgentIdList();
MatcherAssert.assertThat(agentIdList, hasSize(2));
MatcherAssert.assertThat(agentIdList, hasItem("agentId1"));
MatcherAssert.assertThat(agentIdList, hasItem("agentId2"));
}
use of com.navercorp.pinpoint.web.applicationmap.nodes.ServerBuilder in project pinpoint by naver.
the class StatisticsServerInstanceListFactory method createWasNodeInstanceListFromHistogram.
ServerInstanceList createWasNodeInstanceListFromHistogram(Node wasNode, long timestamp) {
Objects.requireNonNull(wasNode, "wasNode");
if (timestamp < 0) {
return new ServerInstanceList();
}
final ServerBuilder builder = new ServerBuilder();
final Set<AgentInfo> agentInfoSet = new HashSet<>();
final NodeHistogram nodeHistogram = wasNode.getNodeHistogram();
if (nodeHistogram != null && nodeHistogram.getAgentHistogramMap() != null) {
for (String agentId : nodeHistogram.getAgentHistogramMap().keySet()) {
AgentInfo agentInfo = new AgentInfo();
agentInfo.setAgentId(agentId);
agentInfo.setHostName(agentId);
agentInfo.setIp("");
agentInfo.setServiceTypeCode(wasNode.getServiceType().getCode());
agentInfoSet.add(agentInfo);
}
}
builder.addAgentInfo(agentInfoSet);
return builder.build();
}
Aggregations