Search in sources :

Example 11 with ServerInstanceList

use of com.navercorp.pinpoint.web.applicationmap.nodes.ServerInstanceList 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 12 with ServerInstanceList

use of com.navercorp.pinpoint.web.applicationmap.nodes.ServerInstanceList in project pinpoint by naver.

the class NodeSerializer method writeServerInstanceList.

private void writeServerInstanceList(JsonGenerator jgen, Node node) throws IOException {
    ServerInstanceList serverInstanceList = node.getServerInstanceList();
    if (node.getServiceType().isUnknown()) {
        serverInstanceList = null;
    }
    final String agentIdNameMapKey = "agentIdNameMap";
    if (serverInstanceList == null) {
        jgen.writeNumberField("instanceCount", 0);
        jgen.writeNumberField("instanceErrorCount", 0);
        writeEmptyArray(jgen, "agentIds");
        writeEmptyObject(jgen, agentIdNameMapKey);
        if (NodeType.DETAILED == node.getNodeType()) {
            writeEmptyObject(jgen, "serverList");
        }
    } else {
        jgen.writeNumberField("instanceCount", serverInstanceList.getInstanceCount());
        long instanceErrorCount = 0;
        NodeHistogram nodeHistogram = node.getNodeHistogram();
        if (nodeHistogram != null) {
            Map<String, Histogram> agentHistogramMap = node.getNodeHistogram().getAgentHistogramMap();
            if (agentHistogramMap != null) {
                instanceErrorCount = agentHistogramMap.values().stream().filter(agentHistogram -> agentHistogram.getTotalErrorCount() > 0).count();
            }
        }
        jgen.writeNumberField("instanceErrorCount", instanceErrorCount);
        jgen.writeArrayFieldStart("agentIds");
        for (String agentId : serverInstanceList.getAgentIdList()) {
            jgen.writeString(agentId);
        }
        jgen.writeEndArray();
        jgen.writeObjectFieldStart(agentIdNameMapKey);
        for (Map.Entry<String, String> entry : serverInstanceList.getAgentIdNameMap().entrySet()) {
            jgen.writeStringField(entry.getKey(), entry.getValue());
        }
        jgen.writeEndObject();
        if (NodeType.DETAILED == node.getNodeType()) {
            jgen.writeObjectField("serverList", serverInstanceList);
        }
    }
}
Also used : Histogram(com.navercorp.pinpoint.web.applicationmap.histogram.Histogram) NodeHistogram(com.navercorp.pinpoint.web.applicationmap.histogram.NodeHistogram) ServerInstanceList(com.navercorp.pinpoint.web.applicationmap.nodes.ServerInstanceList) NodeHistogram(com.navercorp.pinpoint.web.applicationmap.histogram.NodeHistogram) Map(java.util.Map)

Example 13 with ServerInstanceList

use of com.navercorp.pinpoint.web.applicationmap.nodes.ServerInstanceList 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 14 with ServerInstanceList

use of com.navercorp.pinpoint.web.applicationmap.nodes.ServerInstanceList 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)

Example 15 with ServerInstanceList

use of com.navercorp.pinpoint.web.applicationmap.nodes.ServerInstanceList in project pinpoint by naver.

the class NodeHistogramSummarySerializer method serialize.

@Override
public void serialize(NodeHistogramSummary nodeHistogramSummary, JsonGenerator jgen, SerializerProvider serializers) throws IOException, JsonProcessingException {
    jgen.writeStartObject();
    jgen.writeNumberField("currentServerTime", new ServerTime().getCurrentServerTime());
    ServerInstanceList serverInstanceList = nodeHistogramSummary.getServerInstanceList();
    jgen.writeObjectField("serverList", serverInstanceList);
    writeHistogram(jgen, nodeHistogramSummary);
    jgen.writeEndObject();
}
Also used : ServerInstanceList(com.navercorp.pinpoint.web.applicationmap.nodes.ServerInstanceList)

Aggregations

ServerInstanceList (com.navercorp.pinpoint.web.applicationmap.nodes.ServerInstanceList)15 NodeHistogram (com.navercorp.pinpoint.web.applicationmap.histogram.NodeHistogram)4 Node (com.navercorp.pinpoint.web.applicationmap.nodes.Node)4 NodeList (com.navercorp.pinpoint.web.applicationmap.nodes.NodeList)4 ServerBuilder (com.navercorp.pinpoint.web.applicationmap.nodes.ServerBuilder)4 AgentInfo (com.navercorp.pinpoint.web.vo.AgentInfo)4 Application (com.navercorp.pinpoint.web.vo.Application)4 Test (org.junit.Test)4 LinkDataDuplexMap (com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataDuplexMap)3 HashSet (java.util.HashSet)3 Map (java.util.Map)3 ServiceType (com.navercorp.pinpoint.common.trace.ServiceType)2 NodeHistogramFactory (com.navercorp.pinpoint.web.applicationmap.appender.histogram.NodeHistogramFactory)2 LinkList (com.navercorp.pinpoint.web.applicationmap.link.LinkList)2 NodeHistogramSummary (com.navercorp.pinpoint.web.applicationmap.nodes.NodeHistogramSummary)2 Range (com.navercorp.pinpoint.web.vo.Range)2 ServerInstanceListTest (com.navercorp.pinpoint.web.applicationmap.ServerInstanceListTest)1 DefaultNodeHistogramFactory (com.navercorp.pinpoint.web.applicationmap.appender.histogram.DefaultNodeHistogramFactory)1 EmptyNodeHistogramFactory (com.navercorp.pinpoint.web.applicationmap.appender.histogram.EmptyNodeHistogramFactory)1 NodeHistogramAppender (com.navercorp.pinpoint.web.applicationmap.appender.histogram.NodeHistogramAppender)1