Search in sources :

Example 1 with ServerBuilder

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

Example 2 with ServerBuilder

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);
}
Also used : ServerInstanceList(com.navercorp.pinpoint.web.applicationmap.nodes.ServerInstanceList) AgentInfo(com.navercorp.pinpoint.web.vo.AgentInfo) ServerBuilder(com.navercorp.pinpoint.web.applicationmap.nodes.ServerBuilder) HashSet(java.util.HashSet) Test(org.junit.Test) ServerInstanceListTest(com.navercorp.pinpoint.web.applicationmap.ServerInstanceListTest)

Example 3 with ServerBuilder

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"));
}
Also used : ServerInstanceList(com.navercorp.pinpoint.web.applicationmap.nodes.ServerInstanceList) AgentInfo(com.navercorp.pinpoint.web.vo.AgentInfo) ServerBuilder(com.navercorp.pinpoint.web.applicationmap.nodes.ServerBuilder) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 4 with ServerBuilder

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();
}
Also used : ServerInstanceList(com.navercorp.pinpoint.web.applicationmap.nodes.ServerInstanceList) AgentInfo(com.navercorp.pinpoint.web.vo.AgentInfo) NodeHistogram(com.navercorp.pinpoint.web.applicationmap.histogram.NodeHistogram) ServerBuilder(com.navercorp.pinpoint.web.applicationmap.nodes.ServerBuilder) HashSet(java.util.HashSet)

Aggregations

ServerBuilder (com.navercorp.pinpoint.web.applicationmap.nodes.ServerBuilder)4 ServerInstanceList (com.navercorp.pinpoint.web.applicationmap.nodes.ServerInstanceList)4 AgentInfo (com.navercorp.pinpoint.web.vo.AgentInfo)4 HashSet (java.util.HashSet)3 Test (org.junit.Test)2 ServerInstanceListTest (com.navercorp.pinpoint.web.applicationmap.ServerInstanceListTest)1 NodeHistogram (com.navercorp.pinpoint.web.applicationmap.histogram.NodeHistogram)1 Application (com.navercorp.pinpoint.web.vo.Application)1