Search in sources :

Example 1 with ServerInstanceList

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

the class LinkSerializer method writeAgentId.

private void writeAgentId(String fieldName, Node node, JsonGenerator jgen) throws IOException {
    if (node.getServiceType().isWas()) {
        jgen.writeFieldName(fieldName);
        jgen.writeStartArray();
        ServerInstanceList serverInstanceList = node.getServerInstanceList();
        if (serverInstanceList != null) {
            for (String agentId : serverInstanceList.getAgentIdList()) {
                jgen.writeObject(agentId);
            }
        }
        jgen.writeEndArray();
    }
}
Also used : ServerInstanceList(com.navercorp.pinpoint.web.applicationmap.ServerInstanceList)

Example 2 with ServerInstanceList

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

the class ServerInstanceListSerializer method serialize.

@Override
public void serialize(ServerInstanceList serverInstanceList, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException {
    jgen.writeStartObject();
    Map<String, List<ServerInstance>> map = serverInstanceList.getServerInstanceList();
    for (Map.Entry<String, List<ServerInstance>> entry : map.entrySet()) {
        jgen.writeFieldName(entry.getKey());
        jgen.writeStartObject();
        jgen.writeStringField("name", entry.getKey());
        jgen.writeStringField("status", null);
        if (matcherGroupList != null) {
            jgen.writeFieldName("linkList");
            jgen.writeStartArray();
            for (MatcherGroup matcherGroup : matcherGroupList) {
                if (matcherGroup.ismatchingType(entry.getValue().get(0))) {
                    LinkInfo linkInfo = matcherGroup.makeLinkInfo(entry.getValue().get(0));
                    jgen.writeStartObject();
                    jgen.writeStringField("linkName", linkInfo.getLinkName());
                    jgen.writeStringField("linkURL", linkInfo.getLinkUrl());
                    jgen.writeStringField("linkType", linkInfo.getLinktype());
                    jgen.writeEndObject();
                }
            }
            jgen.writeEndArray();
        }
        jgen.writeFieldName("instanceList");
        writeInstanceList(jgen, entry.getValue());
        jgen.writeEndObject();
    }
    jgen.writeEndObject();
}
Also used : MatcherGroup(com.navercorp.pinpoint.web.applicationmap.link.MatcherGroup) ServerInstanceList(com.navercorp.pinpoint.web.applicationmap.ServerInstanceList) List(java.util.List) LinkInfo(com.navercorp.pinpoint.web.applicationmap.link.LinkInfo) Map(java.util.Map)

Example 3 with ServerInstanceList

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

the class NodeSerializer method serialize.

@Override
public void serialize(Node node, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException {
    jgen.writeStartObject();
    //        jgen.writeStringField("id", node.getNodeName());
    // necessary for go.js
    jgen.writeStringField("key", node.getNodeName());
    // for go.js
    jgen.writeStringField("applicationName", node.getApplicationTextName());
    // necessary for go.js
    jgen.writeStringField("category", node.getServiceType().toString());
    jgen.writeStringField("serviceType", node.getServiceType().toString());
    final ServiceType serviceType = node.getApplication().getServiceType();
    //        if (serviceType.isUser()) {
    //            jgen.writeStringField("fig", "Ellipse");
    //        } else if(serviceType.isWas()) {
    //            jgen.writeStringField("fig", "RoundedRectangle");
    //        } else {
    //            jgen.writeStringField("fig", "Rectangle");
    //        }
    jgen.writeStringField("serviceTypeCode", Short.toString(serviceType.getCode()));
    //        jgen.writeStringField("terminal", Boolean.toString(serviceType.isTerminal()));
    // for go.js
    jgen.writeBooleanField("isWas", serviceType.isWas());
    jgen.writeBooleanField("isQueue", serviceType.isQueue());
    jgen.writeBooleanField("isAuthorized", node.isAuthorized());
    writeHistogram(jgen, node);
    if (node.getServiceType().isUnknown()) {
        writeEmptyObject(jgen, "serverList");
        jgen.writeNumberField("instanceCount", 0);
    } else {
        final ServerInstanceList serverInstanceList = node.getServerInstanceList();
        if (serverInstanceList != null) {
            jgen.writeObjectField("serverList", serverInstanceList);
            jgen.writeNumberField("instanceCount", serverInstanceList.getInstanceCount());
        } else {
            writeEmptyObject(jgen, "serverList");
            jgen.writeNumberField("instanceCount", 0);
        }
    }
    jgen.writeEndObject();
}
Also used : ServiceType(com.navercorp.pinpoint.common.trace.ServiceType) ServerInstanceList(com.navercorp.pinpoint.web.applicationmap.ServerInstanceList)

Example 4 with ServerInstanceList

use of com.navercorp.pinpoint.web.applicationmap.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.ServerInstanceList) AgentInfo(com.navercorp.pinpoint.web.vo.AgentInfo) ServerBuilder(com.navercorp.pinpoint.web.applicationmap.ServerBuilder) HashSet(java.util.HashSet) Test(org.junit.Test) ServerInstanceListTest(com.navercorp.pinpoint.web.applicationmap.ServerInstanceListTest)

Aggregations

ServerInstanceList (com.navercorp.pinpoint.web.applicationmap.ServerInstanceList)4 ServiceType (com.navercorp.pinpoint.common.trace.ServiceType)1 ServerBuilder (com.navercorp.pinpoint.web.applicationmap.ServerBuilder)1 ServerInstanceListTest (com.navercorp.pinpoint.web.applicationmap.ServerInstanceListTest)1 LinkInfo (com.navercorp.pinpoint.web.applicationmap.link.LinkInfo)1 MatcherGroup (com.navercorp.pinpoint.web.applicationmap.link.MatcherGroup)1 AgentInfo (com.navercorp.pinpoint.web.vo.AgentInfo)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Test (org.junit.Test)1