From 4326081839287428c0ebed882d57ad3587e52610 Mon Sep 17 00:00:00 2001 From: "koo.taejin" Date: Wed, 29 Mar 2017 15:01:31 +0900 Subject: [PATCH] [#2496] Add datasource metric collection 1. Change to show the latest information (first -> latest) --- .../vo/stat/chart/DataSourceChartGroup.java | 21 ++++++------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/web/src/main/java/com/navercorp/pinpoint/web/vo/stat/chart/DataSourceChartGroup.java b/web/src/main/java/com/navercorp/pinpoint/web/vo/stat/chart/DataSourceChartGroup.java index 53b8b2d27e70..dd98299c4412 100644 --- a/web/src/main/java/com/navercorp/pinpoint/web/vo/stat/chart/DataSourceChartGroup.java +++ b/web/src/main/java/com/navercorp/pinpoint/web/vo/stat/chart/DataSourceChartGroup.java @@ -19,6 +19,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.navercorp.pinpoint.common.service.ServiceTypeRegistryService; import com.navercorp.pinpoint.common.util.CollectionUtils; +import com.navercorp.pinpoint.rpc.util.ListUtils; import com.navercorp.pinpoint.web.util.TimeWindow; import com.navercorp.pinpoint.web.view.DataSourceChartGroupSerializer; import com.navercorp.pinpoint.web.vo.chart.Chart; @@ -71,25 +72,15 @@ public DataSourceChartGroup(TimeWindow timeWindow, List sampl this.databaseName = UNCOLLECTED_STRING_VALUE; this.jdbcUrl = UNCOLLECTED_STRING_VALUE; } else { - SampledDataSource defaultDataSource = sampledDataSourceList.get(0); + SampledDataSource latestSampledDataSource = ListUtils.getLast(sampledDataSourceList); - this.id = defaultDataSource.getId(); - this.serviceTypeName = serviceTypeRegistryService.findServiceType(defaultDataSource.getServiceTypeCode()).getName(); - this.databaseName = extractDatabaseName(sampledDataSourceList); - this.jdbcUrl = defaultDataSource.getJdbcUrl(); + this.id = latestSampledDataSource.getId(); + this.serviceTypeName = serviceTypeRegistryService.findServiceType(latestSampledDataSource.getServiceTypeCode()).getName(); + this.databaseName = latestSampledDataSource.getDatabaseName(); + this.jdbcUrl = latestSampledDataSource.getJdbcUrl(); } } - private String extractDatabaseName(List sampledDataSourceList) { - for (SampledDataSource sampledDataSource : sampledDataSourceList) { - if (sampledDataSource != null && sampledDataSource.getDatabaseName() != null) { - return sampledDataSource.getDatabaseName(); - } - } - - return null; - } - @Override public Map getCharts() { return dataSourceCharts;