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