From f7427f7f8042e9cd2cd69cce09e8440323bb8fca Mon Sep 17 00:00:00 2001 From: emeroad Date: Mon, 3 Jun 2024 19:38:15 +0900 Subject: [PATCH] [#11050] NodeHistogram --- .../controller/MapController.java | 23 +++-- .../histogram/ApplicationTimeHistogram.java | 7 -- .../nodes/NodeHistogramSummary.java | 48 +++------- .../view/NodeHistogramSummaryView.java | 72 +++++++++++++++ .../controller/ResponseTimeController.java | 33 ++++--- .../view/NodeHistogramSummarySerializer.java | 92 ------------------- .../web/view/histogram/HistogramView.java | 14 +++ .../view/histogram/ServerHistogramView.java | 10 ++ 8 files changed, 144 insertions(+), 155 deletions(-) create mode 100644 web/src/main/java/com/navercorp/pinpoint/web/applicationmap/view/NodeHistogramSummaryView.java delete mode 100644 web/src/main/java/com/navercorp/pinpoint/web/view/NodeHistogramSummarySerializer.java diff --git a/web/src/main/java/com/navercorp/pinpoint/web/applicationmap/controller/MapController.java b/web/src/main/java/com/navercorp/pinpoint/web/applicationmap/controller/MapController.java index 245073bbc09dc..56df122008914 100644 --- a/web/src/main/java/com/navercorp/pinpoint/web/applicationmap/controller/MapController.java +++ b/web/src/main/java/com/navercorp/pinpoint/web/applicationmap/controller/MapController.java @@ -31,6 +31,7 @@ import com.navercorp.pinpoint.web.applicationmap.service.MapServiceOption; import com.navercorp.pinpoint.web.applicationmap.service.ResponseTimeHistogramService; import com.navercorp.pinpoint.web.applicationmap.service.ResponseTimeHistogramServiceOption; +import com.navercorp.pinpoint.web.applicationmap.view.NodeHistogramSummaryView; import com.navercorp.pinpoint.web.component.ApplicationFactory; import com.navercorp.pinpoint.web.validation.NullOrNotBlank; import com.navercorp.pinpoint.web.view.ApplicationTimeHistogramViewModel; @@ -213,7 +214,7 @@ public ApplicationTimeHistogramViewModel getResponseTimeHistogramData( } @PostMapping(value = "/getResponseTimeHistogramDataV2") - public NodeHistogramSummary postResponseTimeHistogramDataV2( + public NodeHistogramSummaryView postResponseTimeHistogramDataV2( @RequestParam("applicationName") @NotBlank String applicationName, @RequestParam("serviceTypeCode") Short serviceTypeCode, @RequestParam("from") @PositiveOrZero long from, @@ -239,14 +240,21 @@ public NodeHistogramSummary postResponseTimeHistogramDataV2( .build(); final NodeHistogramSummary nodeHistogramSummary = responseTimeHistogramService.selectNodeHistogramData(option); + TimeHistogramFormat format = histogramFormat(useLoadHistogramFormat); + + return new NodeHistogramSummaryView(nodeHistogramSummary, nodeHistogramSummary.getServerGroupList(), format); + } + + private TimeHistogramFormat histogramFormat(boolean useLoadHistogramFormat) { if (useLoadHistogramFormat) { - nodeHistogramSummary.setTimeHistogramFormat(TimeHistogramFormat.V2); + return TimeHistogramFormat.V2; + } else { + return TimeHistogramFormat.V1; } - return nodeHistogramSummary; } @GetMapping(value = "/getResponseTimeHistogramDataV2") - public NodeHistogramSummary getResponseTimeHistogramDataV2( + public NodeHistogramSummaryView getResponseTimeHistogramDataV2( @RequestParam("applicationName") @NotBlank String applicationName, @RequestParam("serviceTypeCode") Short serviceTypeCode, @RequestParam("from") @PositiveOrZero long from, @@ -286,10 +294,9 @@ public NodeHistogramSummary getResponseTimeHistogramDataV2( .build(); final NodeHistogramSummary nodeHistogramSummary = responseTimeHistogramService.selectNodeHistogramData(option); - if (useLoadHistogramFormat) { - nodeHistogramSummary.setTimeHistogramFormat(TimeHistogramFormat.V2); - } - return nodeHistogramSummary; + + final TimeHistogramFormat format = getTimeHistogramFormat(useLoadHistogramFormat); + return new NodeHistogramSummaryView(nodeHistogramSummary, nodeHistogramSummary.getServerGroupList(), format); } private List toApplications(List applicationNames, List serviceTypeCodes) { diff --git a/web/src/main/java/com/navercorp/pinpoint/web/applicationmap/histogram/ApplicationTimeHistogram.java b/web/src/main/java/com/navercorp/pinpoint/web/applicationmap/histogram/ApplicationTimeHistogram.java index 01a86ad747cb4..d7365f2ee4d93 100644 --- a/web/src/main/java/com/navercorp/pinpoint/web/applicationmap/histogram/ApplicationTimeHistogram.java +++ b/web/src/main/java/com/navercorp/pinpoint/web/applicationmap/histogram/ApplicationTimeHistogram.java @@ -16,10 +16,7 @@ package com.navercorp.pinpoint.web.applicationmap.histogram; -import com.navercorp.pinpoint.web.view.TimeSeries.TimeSeriesView; import com.navercorp.pinpoint.web.view.TimeViewModel; -import com.navercorp.pinpoint.web.view.histogram.TimeHistogramChartBuilder; -import com.navercorp.pinpoint.web.view.histogram.TimeHistogramType; import com.navercorp.pinpoint.web.vo.Application; import java.util.Collections; @@ -47,10 +44,6 @@ public List createViewModel(TimeHistogramFormat timeHistogramForm return format.build(application, histogramList); } - public TimeSeriesView createTimeSeriesView(TimeHistogramType timeHistogramType) { - return new TimeHistogramChartBuilder(histogramList).build(timeHistogramType); - } - public List getHistogramList() { return histogramList; } diff --git a/web/src/main/java/com/navercorp/pinpoint/web/applicationmap/nodes/NodeHistogramSummary.java b/web/src/main/java/com/navercorp/pinpoint/web/applicationmap/nodes/NodeHistogramSummary.java index 33764b8772a72..fca63e901e012 100644 --- a/web/src/main/java/com/navercorp/pinpoint/web/applicationmap/nodes/NodeHistogramSummary.java +++ b/web/src/main/java/com/navercorp/pinpoint/web/applicationmap/nodes/NodeHistogramSummary.java @@ -16,31 +16,22 @@ package com.navercorp.pinpoint.web.applicationmap.nodes; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.navercorp.pinpoint.web.applicationmap.histogram.ApplicationTimeHistogram; import com.navercorp.pinpoint.web.applicationmap.histogram.Histogram; import com.navercorp.pinpoint.web.applicationmap.histogram.NodeHistogram; -import com.navercorp.pinpoint.web.applicationmap.histogram.TimeHistogram; -import com.navercorp.pinpoint.web.applicationmap.histogram.TimeHistogramFormat; -import com.navercorp.pinpoint.web.view.NodeHistogramSummarySerializer; -import com.navercorp.pinpoint.web.view.TimeSeries.TimeSeriesView; -import com.navercorp.pinpoint.web.view.histogram.HistogramView; -import com.navercorp.pinpoint.web.view.histogram.ServerHistogramView; -import com.navercorp.pinpoint.web.view.histogram.TimeHistogramType; import com.navercorp.pinpoint.web.vo.Application; -import java.util.List; import java.util.Objects; /** * @author HyunGil Jeong */ -@JsonSerialize(using = NodeHistogramSummarySerializer.class) +//@JsonSerialize(using = NodeHistogramSummarySerializer.class) public class NodeHistogramSummary { private final Application application; private final ServerGroupList serverGroupList; private final NodeHistogram nodeHistogram; - private TimeHistogramFormat timeHistogramFormat = TimeHistogramFormat.V1; public NodeHistogramSummary(Application application, ServerGroupList serverGroupList, NodeHistogram nodeHistogram) { this.application = Objects.requireNonNull(application, "application"); @@ -48,6 +39,10 @@ public NodeHistogramSummary(Application application, ServerGroupList serverGroup this.nodeHistogram = Objects.requireNonNull(nodeHistogram, "nodeHistogram"); } + public Application getApplication() { + return application; + } + public ServerGroupList getServerGroupList() { return serverGroupList; } @@ -60,35 +55,14 @@ public Histogram getHistogram() { return nodeHistogram.getApplicationHistogram(); } - public TimeSeriesView getNodeTimeHistogram(TimeHistogramType timeHistogramType) { - return nodeHistogram.getApplicationTimeHistogram().createTimeSeriesView(timeHistogramType); - } - - public TimeHistogramFormat getTimeHistogramFormat() { - return timeHistogramFormat; - } - - public void setTimeHistogramFormat(TimeHistogramFormat timeHistogramFormat) { - this.timeHistogramFormat = timeHistogramFormat; - } - - public HistogramView getHistogramView() { - String nodeName = NodeName.toNodeName(application.getName(), application.getServiceType()); - Histogram applicationHistogram = nodeHistogram.getApplicationHistogram(); - List histogramList = nodeHistogram.getApplicationTimeHistogram().getHistogramList(); - return new HistogramView(nodeName, applicationHistogram, histogramList); - } - - public ServerHistogramView getAgentHistogramView() { - return new ServerHistogramView(NodeName.of(application), nodeHistogram, serverGroupList); + public ApplicationTimeHistogram getApplicationTimeHistogram() { + return nodeHistogram.getApplicationTimeHistogram(); } @Override public String toString() { - final StringBuilder sb = new StringBuilder("NodeHistogramSummary{"); - sb.append("serverGroupList=").append(serverGroupList); - sb.append(", nodeHistogram=").append(nodeHistogram); - sb.append('}'); - return sb.toString(); + return "NodeHistogramSummary{" + "serverGroupList=" + serverGroupList + + ", nodeHistogram=" + nodeHistogram + + '}'; } } diff --git a/web/src/main/java/com/navercorp/pinpoint/web/applicationmap/view/NodeHistogramSummaryView.java b/web/src/main/java/com/navercorp/pinpoint/web/applicationmap/view/NodeHistogramSummaryView.java new file mode 100644 index 0000000000000..835d66221a2ae --- /dev/null +++ b/web/src/main/java/com/navercorp/pinpoint/web/applicationmap/view/NodeHistogramSummaryView.java @@ -0,0 +1,72 @@ +package com.navercorp.pinpoint.web.applicationmap.view; + +import com.navercorp.pinpoint.common.server.util.json.JsonFields; +import com.navercorp.pinpoint.web.applicationmap.histogram.ApplicationTimeHistogram; +import com.navercorp.pinpoint.web.applicationmap.histogram.Histogram; +import com.navercorp.pinpoint.web.applicationmap.histogram.NodeHistogram; +import com.navercorp.pinpoint.web.applicationmap.histogram.TimeHistogramFormat; +import com.navercorp.pinpoint.web.applicationmap.nodes.NodeHistogramSummary; +import com.navercorp.pinpoint.web.applicationmap.nodes.ServerGroupList; +import com.navercorp.pinpoint.web.view.TimeViewModel; +import com.navercorp.pinpoint.web.view.id.AgentNameView; +import com.navercorp.pinpoint.web.vo.ResponseTimeStatics; + +import java.util.List; +import java.util.Map; +import java.util.Objects; + +public class NodeHistogramSummaryView { + + private final NodeHistogramSummary nodeHistogramSummary; + private final NodeHistogram nodeHistogram; + private final TimeHistogramFormat format; + + private final ServerGroupList serverGroupList; + + public NodeHistogramSummaryView(NodeHistogramSummary nodeHistogramSummary, ServerGroupList serverGroupList, TimeHistogramFormat format) { + this.nodeHistogramSummary = Objects.requireNonNull(nodeHistogramSummary, "nodeHistogramSummary"); + this.nodeHistogram = nodeHistogramSummary.getNodeHistogram(); + + this.serverGroupList = Objects.requireNonNull(serverGroupList, "serverGroupList"); + + this.format = Objects.requireNonNull(format, "format"); + } + + public long getCurrentServerTime() { + return System.currentTimeMillis(); + } + + public ServerGroupList getServerList() { + return serverGroupList; + } + + public ResponseTimeStatics getResponseStatistics() { + return ResponseTimeStatics.fromHistogram(nodeHistogram.getApplicationHistogram()); + } + + public Histogram getHistogram() { + return nodeHistogram.getApplicationHistogram(); + } + + public Map getAgentHistogram() { + return nodeHistogram.getAgentHistogramMap(); + } + + public Map getAgentResponseStatistics() { + return nodeHistogram.getAgentResponseStatisticsMap(); + } + + + public List getTimeSeriesHistogram() { + ApplicationTimeHistogram applicationTimeHistogram = nodeHistogramSummary.getApplicationTimeHistogram(); + if (applicationTimeHistogram == null) { + return List.of(); + } + return applicationTimeHistogram.createViewModel(format); + } + + public JsonFields> getAgentTimeSeriesHistogram() { + return nodeHistogram.getAgentTimeHistogram().createViewModel(format); + } +} + diff --git a/web/src/main/java/com/navercorp/pinpoint/web/authorization/controller/ResponseTimeController.java b/web/src/main/java/com/navercorp/pinpoint/web/authorization/controller/ResponseTimeController.java index a01ded8390f93..fdd6897e83b46 100644 --- a/web/src/main/java/com/navercorp/pinpoint/web/authorization/controller/ResponseTimeController.java +++ b/web/src/main/java/com/navercorp/pinpoint/web/authorization/controller/ResponseTimeController.java @@ -26,9 +26,10 @@ import com.navercorp.pinpoint.web.applicationmap.service.ResponseTimeHistogramService; import com.navercorp.pinpoint.web.applicationmap.service.ResponseTimeHistogramServiceOption; import com.navercorp.pinpoint.web.component.ApplicationFactory; -import com.navercorp.pinpoint.web.view.TimeSeries.TimeSeriesView; import com.navercorp.pinpoint.web.view.histogram.HistogramView; import com.navercorp.pinpoint.web.view.histogram.ServerHistogramView; +import com.navercorp.pinpoint.web.view.histogram.TimeHistogramChart; +import com.navercorp.pinpoint.web.view.histogram.TimeHistogramChartBuilder; import com.navercorp.pinpoint.web.view.histogram.TimeHistogramType; import com.navercorp.pinpoint.web.vo.Application; import com.navercorp.pinpoint.web.vo.ApplicationPair; @@ -83,7 +84,7 @@ public ServerHistogramView getWasServerHistogramData( .setUseStatisticsAgentState(false) //set useStatisticsAgentState to false for agent data .build(); NodeHistogramSummary nodeHistogramSummary = responseTimeHistogramService.selectNodeHistogramData(option); - return nodeHistogramSummary.getAgentHistogramView(); + return ServerHistogramView.view(nodeHistogramSummary); } @GetMapping(value = "/getWas/histogram") @@ -118,7 +119,7 @@ public ResponseTimeStatics getWasResponseTimeStatistics( } @GetMapping(value = "/getWas/{type}/chart") - public TimeSeriesView getWasTimeHistogramChart( + public TimeHistogramChart getWasTimeHistogramChart( @RequestParam("applicationName") @NotBlank String applicationName, @RequestParam(value = "serviceTypeCode", required = false) Short serviceTypeCode, @RequestParam(value = "serviceTypeName", required = false) @NotBlank String serviceTypeName, @@ -135,7 +136,9 @@ public TimeSeriesView getWasTimeHistogramChart( .setUseStatisticsAgentState(true) .build(); NodeHistogramSummary nodeHistogramSummary = responseTimeHistogramService.selectNodeHistogramData(option); - return nodeHistogramSummary.getNodeTimeHistogram(timeHistogramType); + ApplicationTimeHistogram applicationTimeHistogram = nodeHistogramSummary.getApplicationTimeHistogram(); + + return chartView(applicationTimeHistogram, timeHistogramType); } @GetMapping(value = "/getWas/histogramData") @@ -154,7 +157,7 @@ public HistogramView getWasHistogramData( .setUseStatisticsAgentState(true) .build(); NodeHistogramSummary nodeHistogramSummary = responseTimeHistogramService.selectNodeHistogramData(option); - return nodeHistogramSummary.getHistogramView(); + return HistogramView.view(nodeHistogramSummary); } private ResponseTimeHistogramServiceOption.Builder createWasOptionBuilder(Application application, Range range) { @@ -181,7 +184,7 @@ public ServerHistogramView postNodeServerHistogramData( .setUseStatisticsAgentState(false) //set useStatisticsAgentState to false for agent data .build(); NodeHistogramSummary nodeHistogramSummary = responseTimeHistogramService.selectNodeHistogramData(option); - return nodeHistogramSummary.getAgentHistogramView(); + return ServerHistogramView.view(nodeHistogramSummary); } @PostMapping(value = "/getNode/histogramData") @@ -202,11 +205,11 @@ public HistogramView postNodeHistogramData( .build(); NodeHistogramSummary nodeHistogramSummary = responseTimeHistogramService.selectNodeHistogramData(option); - return nodeHistogramSummary.getHistogramView(); + return HistogramView.view(nodeHistogramSummary); } @PostMapping(value = "/getNode/{type}/chart") - public TimeSeriesView postNodeTimeHistogramChart( + public TimeHistogramChart postNodeTimeHistogramChart( @RequestParam("applicationName") @NotBlank String applicationName, @RequestParam(value = "serviceTypeCode", required = false) Short serviceTypeCode, @RequestParam(value = "serviceTypeName", required = false) @NotBlank String serviceTypeName, @@ -225,7 +228,14 @@ public TimeSeriesView postNodeTimeHistogramChart( .build(); NodeHistogramSummary nodeHistogramSummary = responseTimeHistogramService.selectNodeHistogramData(option); - return nodeHistogramSummary.getNodeTimeHistogram(timeHistogramType); + ApplicationTimeHistogram applicationTimeHistogram = nodeHistogramSummary.getApplicationTimeHistogram(); + + return chartView(applicationTimeHistogram, timeHistogramType); + } + + private TimeHistogramChart chartView(ApplicationTimeHistogram applicationTimeHistogram, TimeHistogramType timeHistogramType) { + return new TimeHistogramChartBuilder(applicationTimeHistogram.getHistogramList()) + .build(timeHistogramType); } @GetMapping(value = "/getLink/histogramData") @@ -259,7 +269,7 @@ public HistogramView newHistogramView(LinkHistogramSummary summary) { } @GetMapping(value = "/getLink/{type}/chart") - public TimeSeriesView getLinkTimeHistogramChart( + public TimeHistogramChart getLinkTimeHistogramChart( @RequestParam("fromApplicationName") @NotBlank String fromApplicationName, @RequestParam(value = "fromServiceTypeCode", required = false) Short fromServiceTypeCode, @RequestParam(value = "fromServiceTypeName", required = false) @NotBlank String fromServiceTypeName, @@ -281,7 +291,8 @@ public TimeSeriesView getLinkTimeHistogramChart( responseTimeHistogramService.selectLinkHistogramData(fromApplication, toApplication, range); ApplicationTimeHistogram histogram = linkHistogramSummary.getLinkApplicationTimeHistogram(); - return histogram.createTimeSeriesView(timeHistogramType); + + return chartView(histogram, timeHistogramType); } private ResponseTimeHistogramServiceOption.Builder createOptionBuilder(Application application, Range range, diff --git a/web/src/main/java/com/navercorp/pinpoint/web/view/NodeHistogramSummarySerializer.java b/web/src/main/java/com/navercorp/pinpoint/web/view/NodeHistogramSummarySerializer.java deleted file mode 100644 index 025e8327a2574..0000000000000 --- a/web/src/main/java/com/navercorp/pinpoint/web/view/NodeHistogramSummarySerializer.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright 2017 NAVER Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.navercorp.pinpoint.web.view; - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.navercorp.pinpoint.common.server.util.json.JacksonWriterUtils; -import com.navercorp.pinpoint.common.server.util.json.JsonFields; -import com.navercorp.pinpoint.web.applicationmap.histogram.AgentTimeHistogram; -import com.navercorp.pinpoint.web.applicationmap.histogram.ApplicationTimeHistogram; -import com.navercorp.pinpoint.web.applicationmap.histogram.Histogram; -import com.navercorp.pinpoint.web.applicationmap.histogram.NodeHistogram; -import com.navercorp.pinpoint.web.applicationmap.histogram.TimeHistogramFormat; -import com.navercorp.pinpoint.web.applicationmap.nodes.NodeHistogramSummary; -import com.navercorp.pinpoint.web.applicationmap.nodes.ServerGroupList; -import com.navercorp.pinpoint.web.view.id.AgentNameView; -import com.navercorp.pinpoint.web.vo.ResponseTimeStatics; - -import java.io.IOException; -import java.util.List; -import java.util.Map; - -/** - * @author HyunGil Jeong - */ -public class NodeHistogramSummarySerializer extends JsonSerializer { - - @Override - public void serialize(NodeHistogramSummary nodeHistogramSummary, JsonGenerator jgen, SerializerProvider serializers) throws IOException { - jgen.writeStartObject(); - jgen.writeNumberField("currentServerTime", new ServerTime().getCurrentServerTime()); - - ServerGroupList serverGroupList = nodeHistogramSummary.getServerGroupList(); - jgen.writeObjectField("serverList", serverGroupList); - - - writeHistogram(jgen, nodeHistogramSummary); - - jgen.writeEndObject(); - } - - private void writeHistogram(JsonGenerator jgen, NodeHistogramSummary nodeHistogramSummary) throws IOException { - NodeHistogram nodeHistogram = nodeHistogramSummary.getNodeHistogram(); - Histogram applicationHistogram = nodeHistogram.getApplicationHistogram(); - ResponseTimeStatics responseTimeStatics = ResponseTimeStatics.fromHistogram(applicationHistogram); - jgen.writeObjectField(ResponseTimeStatics.RESPONSE_STATISTICS, responseTimeStatics); - if (applicationHistogram == null) { - JacksonWriterUtils.writeEmptyObject(jgen, "histogram"); - } else { - jgen.writeObjectField("histogram", applicationHistogram); - } - Map agentHistogramMap = nodeHistogram.getAgentHistogramMap(); - if (agentHistogramMap == null) { - JacksonWriterUtils.writeEmptyObject(jgen, "agentHistogram"); - JacksonWriterUtils.writeEmptyObject(jgen, ResponseTimeStatics.AGENT_RESPONSE_STATISTICS); - } else { - jgen.writeObjectField("agentHistogram", agentHistogramMap); - jgen.writeObjectField(ResponseTimeStatics.AGENT_RESPONSE_STATISTICS, nodeHistogram.getAgentResponseStatisticsMap()); - } - - final TimeHistogramFormat format = nodeHistogramSummary.getTimeHistogramFormat(); - - ApplicationTimeHistogram applicationTimeHistogram = nodeHistogram.getApplicationTimeHistogram(); - List applicationTimeSeriesHistogram = applicationTimeHistogram.createViewModel(format); - if (applicationTimeSeriesHistogram == null) { - JacksonWriterUtils.writeEmptyArray(jgen, "timeSeriesHistogram"); - } else { - jgen.writeObjectField("timeSeriesHistogram", applicationTimeSeriesHistogram); - } - - AgentTimeHistogram agentTimeHistogram = nodeHistogram.getAgentTimeHistogram(); - JsonFields> agentFields = agentTimeHistogram.createViewModel(format); - jgen.writeFieldName(NodeSerializer.AGENT_TIME_SERIES_HISTOGRAM); - jgen.writeObject(agentFields); - } - -} diff --git a/web/src/main/java/com/navercorp/pinpoint/web/view/histogram/HistogramView.java b/web/src/main/java/com/navercorp/pinpoint/web/view/histogram/HistogramView.java index a49715a5fda2d..006198654d5cd 100644 --- a/web/src/main/java/com/navercorp/pinpoint/web/view/histogram/HistogramView.java +++ b/web/src/main/java/com/navercorp/pinpoint/web/view/histogram/HistogramView.java @@ -21,7 +21,10 @@ import com.navercorp.pinpoint.web.applicationmap.histogram.ApdexScore; import com.navercorp.pinpoint.web.applicationmap.histogram.Histogram; import com.navercorp.pinpoint.web.applicationmap.histogram.TimeHistogram; +import com.navercorp.pinpoint.web.applicationmap.nodes.NodeHistogramSummary; +import com.navercorp.pinpoint.web.applicationmap.nodes.NodeName; import com.navercorp.pinpoint.web.view.TimeSeries.TimeSeriesView; +import com.navercorp.pinpoint.web.vo.Application; import com.navercorp.pinpoint.web.vo.ResponseTimeStatics; import java.util.List; @@ -69,4 +72,15 @@ public TimeSeriesView getLoadStatisticsChart() { TimeHistogramChartBuilder builder = new TimeHistogramChartBuilder(sortedTimeHistograms); return builder.build(TimeHistogramType.loadStatistics); } + + + + public static HistogramView view(NodeHistogramSummary summary) { + Application application = summary.getApplication(); + String nodeName = NodeName.toNodeName(application.getName(), application.getServiceType()); + Histogram applicationHistogram = summary.getNodeHistogram().getApplicationHistogram(); + List histogramList = summary.getNodeHistogram().getApplicationTimeHistogram().getHistogramList(); + + return new HistogramView(nodeName, applicationHistogram, histogramList); + } } diff --git a/web/src/main/java/com/navercorp/pinpoint/web/view/histogram/ServerHistogramView.java b/web/src/main/java/com/navercorp/pinpoint/web/view/histogram/ServerHistogramView.java index 58fd50505b6bd..486e1757f6554 100644 --- a/web/src/main/java/com/navercorp/pinpoint/web/view/histogram/ServerHistogramView.java +++ b/web/src/main/java/com/navercorp/pinpoint/web/view/histogram/ServerHistogramView.java @@ -19,8 +19,10 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.navercorp.pinpoint.web.applicationmap.histogram.NodeHistogram; +import com.navercorp.pinpoint.web.applicationmap.nodes.NodeHistogramSummary; import com.navercorp.pinpoint.web.applicationmap.nodes.NodeName; import com.navercorp.pinpoint.web.applicationmap.nodes.ServerGroupList; +import com.navercorp.pinpoint.web.vo.Application; import java.util.List; import java.util.Objects; @@ -30,6 +32,14 @@ public class ServerHistogramView { private final List agentHistogramList; private final ServerGroupList serverGroupList; + public static ServerHistogramView view(NodeHistogramSummary summary) { + Application application = summary.getApplication(); + String key = NodeName.toNodeName(application.getName(), application.getServiceType()); + List agentHistogramList = summary.getNodeHistogram().createAgentHistogramViewList(); + ServerGroupList serverGroupList = summary.getServerGroupList(); + return new ServerHistogramView(key, agentHistogramList, serverGroupList); + } + public ServerHistogramView(String key, List agentHistogramList, ServerGroupList serverGroupList) { this.key = Objects.requireNonNull(key, "key"); this.agentHistogramList = Objects.requireNonNull(agentHistogramList, "agentHistogramList");