diff --git a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/chart/DefaultUriStatChartType.java b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/chart/DefaultUriStatChartType.java index c0dfe9432ab1..1c62a51050c1 100644 --- a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/chart/DefaultUriStatChartType.java +++ b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/chart/DefaultUriStatChartType.java @@ -18,6 +18,7 @@ package com.navercorp.pinpoint.uristat.web.chart; import com.navercorp.pinpoint.uristat.web.dao.UriStatChartDao; +import com.navercorp.pinpoint.uristat.web.dao.UriStatSummaryDao; import java.util.List; import java.util.Objects; @@ -28,11 +29,18 @@ public class DefaultUriStatChartType implements UriStatChartType { private final List fieldNames; private final UriStatChartDao chartDao; + private final UriStatSummaryDao summaryDao; - public DefaultUriStatChartType(String type, List fieldNames, UriStatChartDao chartDao) { + public DefaultUriStatChartType( + String type, + List fieldNames, + UriStatChartDao chartDao, + UriStatSummaryDao summaryDao + ) { this.type = Objects.requireNonNull(type, "type"); this.fieldNames = Objects.requireNonNull(fieldNames, "fieldNames"); this.chartDao = Objects.requireNonNull(chartDao, "chartDao"); + this.summaryDao = Objects.requireNonNull(summaryDao, "summaryDao"); } @Override @@ -50,12 +58,18 @@ public UriStatChartDao getChartDao() { return chartDao; } + @Override + public UriStatSummaryDao getSummaryDao() { + return summaryDao; + } + @Override public String toString() { return "UriStatChartType{" + "type='" + type + '\'' + ", fieldNames=" + fieldNames + ", chartDao=" + chartDao.getClass().getSimpleName() + + ", summaryDao=" + summaryDao.getClass().getSimpleName() + '}'; } } diff --git a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/chart/UriStatChartType.java b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/chart/UriStatChartType.java index 99431d6ecde4..8ec86b6c24cb 100644 --- a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/chart/UriStatChartType.java +++ b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/chart/UriStatChartType.java @@ -1,6 +1,7 @@ package com.navercorp.pinpoint.uristat.web.chart; import com.navercorp.pinpoint.uristat.web.dao.UriStatChartDao; +import com.navercorp.pinpoint.uristat.web.dao.UriStatSummaryDao; import java.util.List; @@ -10,5 +11,7 @@ public interface UriStatChartType { UriStatChartDao getChartDao(); + UriStatSummaryDao getSummaryDao(); + String getType(); } \ No newline at end of file diff --git a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/chart/UriStatChartTypeFactory.java b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/chart/UriStatChartTypeFactory.java index c2090ce35ae4..54228d918908 100644 --- a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/chart/UriStatChartTypeFactory.java +++ b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/chart/UriStatChartTypeFactory.java @@ -4,6 +4,7 @@ import java.util.Arrays; import java.util.Map; +import java.util.NoSuchElementException; import java.util.Objects; import java.util.function.Function; import java.util.stream.Collectors; @@ -24,7 +25,7 @@ public UriStatChartType valueOf(String type) { final UriStatChartType uriStatChartType = uriStatCharts.get(type); if (uriStatChartType == null) { - throw new RuntimeException("Invalid uri stat chart type: " + type); + throw new NoSuchElementException("Invalid uri stat chart type: " + type); } return uriStatChartType; } diff --git a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/config/UriRegistryHandler.java b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/config/UriRegistryHandler.java index 7007dd40ddb8..9572d1a517cd 100644 --- a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/config/UriRegistryHandler.java +++ b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/config/UriRegistryHandler.java @@ -1,11 +1,7 @@ package com.navercorp.pinpoint.uristat.web.config; import com.navercorp.pinpoint.mybatis.MyBatisRegistryHandler; -import com.navercorp.pinpoint.uristat.web.entity.ApdexChartEntity; -import com.navercorp.pinpoint.uristat.web.entity.ChartCommonEntity; -import com.navercorp.pinpoint.uristat.web.entity.FailureChartEntity; -import com.navercorp.pinpoint.uristat.web.entity.LatencyChartEntity; -import com.navercorp.pinpoint.uristat.web.entity.TotalChartEntity; +import com.navercorp.pinpoint.uristat.web.entity.UriStatChartEntity; import com.navercorp.pinpoint.uristat.web.entity.UriStatSummaryEntity; import com.navercorp.pinpoint.uristat.web.model.UriStatChartValue; import com.navercorp.pinpoint.uristat.web.model.UriStatSummary; @@ -19,11 +15,7 @@ public class UriRegistryHandler implements MyBatisRegistryHandler { public void registerTypeAlias(TypeAliasRegistry typeAliasRegistry) { typeAliasRegistry.registerAlias(UriStatChartValue.class); typeAliasRegistry.registerAlias(UriStatSummary.class); - typeAliasRegistry.registerAlias(ApdexChartEntity.class); - typeAliasRegistry.registerAlias(ChartCommonEntity.class); - typeAliasRegistry.registerAlias(FailureChartEntity.class); - typeAliasRegistry.registerAlias(LatencyChartEntity.class); - typeAliasRegistry.registerAlias(TotalChartEntity.class); + typeAliasRegistry.registerAlias(UriStatChartEntity.class); typeAliasRegistry.registerAlias(UriStatSummaryEntity.class); typeAliasRegistry.registerAlias(UriStatSummaryQueryParameter.class); typeAliasRegistry.registerAlias(UriStatChartQueryParameter.class); diff --git a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/config/UriStatChartTypeConfiguration.java b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/config/UriStatChartTypeConfiguration.java index fe048cfbac7d..38de17f41681 100644 --- a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/config/UriStatChartTypeConfiguration.java +++ b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/config/UriStatChartTypeConfiguration.java @@ -21,6 +21,7 @@ import com.navercorp.pinpoint.uristat.web.chart.UriStatChartType; import com.navercorp.pinpoint.uristat.web.chart.UriStatChartTypeFactory; import com.navercorp.pinpoint.uristat.web.dao.UriStatChartDao; +import com.navercorp.pinpoint.uristat.web.dao.UriStatSummaryDao; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -35,25 +36,37 @@ public class UriStatChartTypeConfiguration { ); @Bean - public UriStatChartType uriStatTotalChart(@Qualifier("pinotTotalCountChartDao") UriStatChartDao chartDao) { - return new DefaultUriStatChartType("total", HISTOGRAM_FIELD, chartDao); + public UriStatChartType uriStatTotalChart( + @Qualifier("pinotTotalCountChartDao") UriStatChartDao chartDao, + @Qualifier("pinotTotalSummaryDao") UriStatSummaryDao summaryDao + ) { + return new DefaultUriStatChartType("total", HISTOGRAM_FIELD, chartDao, summaryDao); } @Bean - public UriStatChartType uriStatFailureChart(@Qualifier("pinotFailureCountChartDao") UriStatChartDao chartDao) { - return new DefaultUriStatChartType("failure", HISTOGRAM_FIELD, chartDao); + public UriStatChartType uriStatFailureChart( + @Qualifier("pinotFailureCountChartDao") UriStatChartDao chartDao, + @Qualifier("pinotFailureSummaryDao") UriStatSummaryDao summaryDao + ) { + return new DefaultUriStatChartType("failure", HISTOGRAM_FIELD, chartDao, summaryDao); } @Bean - public UriStatChartType uriStatLatencyChart(@Qualifier("pinotLatencyChartDao") UriStatChartDao chartDao) { + public UriStatChartType uriStatLatencyChart( + @Qualifier("pinotLatencyChartDao") UriStatChartDao chartDao, + @Qualifier("pinotLatencySummaryDao") UriStatSummaryDao summaryDao + ) { List field = List.of("avg", "max"); - return new DefaultUriStatChartType("latency", field, chartDao); + return new DefaultUriStatChartType("latency", field, chartDao, summaryDao); } @Bean - public UriStatChartType uriStatApdexChart(@Qualifier("pinotApdexChartDao") UriStatChartDao chartDao) { + public UriStatChartType uriStatApdexChart( + @Qualifier("pinotApdexChartDao") UriStatChartDao chartDao, + @Qualifier("pinotApdexSummaryDao") UriStatSummaryDao summaryDao + ) { List field = List.of("apdex"); - return new DefaultUriStatChartType("apdex", field, chartDao); + return new DefaultUriStatChartType("apdex", field, chartDao, summaryDao); } diff --git a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/controller/UriStatController.java b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/controller/UriStatController.java index 265ae411c90f..b2884e7194f9 100644 --- a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/controller/UriStatController.java +++ b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/controller/UriStatController.java @@ -25,12 +25,14 @@ import com.navercorp.pinpoint.pinot.tenant.TenantProvider; import com.navercorp.pinpoint.uristat.web.chart.UriStatChartType; import com.navercorp.pinpoint.uristat.web.chart.UriStatChartTypeFactory; +import com.navercorp.pinpoint.uristat.web.mapper.ModelToViewMapper; import com.navercorp.pinpoint.uristat.web.model.UriStatChartValue; import com.navercorp.pinpoint.uristat.web.model.UriStatSummary; import com.navercorp.pinpoint.uristat.web.service.UriStatChartService; import com.navercorp.pinpoint.uristat.web.service.UriStatSummaryService; import com.navercorp.pinpoint.uristat.web.util.UriStatChartQueryParameter; import com.navercorp.pinpoint.uristat.web.util.UriStatSummaryQueryParameter; +import com.navercorp.pinpoint.uristat.web.view.UriStatSummaryView; import com.navercorp.pinpoint.uristat.web.view.UriStatView; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.web.bind.annotation.GetMapping; @@ -39,6 +41,7 @@ import org.springframework.web.bind.annotation.RestController; import java.util.List; +import java.util.NoSuchElementException; import java.util.Objects; import java.util.concurrent.TimeUnit; @@ -50,18 +53,24 @@ public class UriStatController { private final UriStatChartService uriStatChartService; private final UriStatChartTypeFactory chartTypeFactory; private static final TimeWindowSampler DEFAULT_TIME_WINDOW_SAMPLER = new TimeWindowSlotCentricSampler(30000L, 200); + private static final TimeWindowSampler ROUGH_TIME_WINDOW_SAMPLER = new TimeWindowSlotCentricSampler(30000L, 10); private final RangeValidator rangeValidator; + private final ModelToViewMapper mapper; - public UriStatController(UriStatSummaryService uriStatService, - UriStatChartService uriStatChartService, - TenantProvider tenantProvider, - UriStatChartTypeFactory chartTypeFactory, - @Qualifier("rangeValidator30d") RangeValidator rangeValidator) { + public UriStatController( + UriStatSummaryService uriStatService, + UriStatChartService uriStatChartService, + TenantProvider tenantProvider, + UriStatChartTypeFactory chartTypeFactory, + @Qualifier("rangeValidator30d") RangeValidator rangeValidator, + ModelToViewMapper mapper + ) { this.uriStatService = Objects.requireNonNull(uriStatService); this.uriStatChartService = Objects.requireNonNull(uriStatChartService); this.chartTypeFactory = Objects.requireNonNull(chartTypeFactory); this.tenantProvider = Objects.requireNonNull(tenantProvider, "tenantProvider"); this.rangeValidator = Objects.requireNonNull(rangeValidator, "rangeValidator"); + this.mapper = Objects.requireNonNull(mapper, "mapper"); } private Range checkTimeRange(long from, long to) { @@ -71,27 +80,44 @@ private Range checkTimeRange(long from, long to) { } @GetMapping("/summary") - public List getUriStatPagedSummary( + public List getUriStatPagedSummary( @RequestParam("applicationName") String applicationName, @RequestParam(value = "agentId", required = false) String agentId, @RequestParam("from") long from, @RequestParam("to") long to, @RequestParam("orderby") String column, @RequestParam("isDesc") boolean isDesc, - @RequestParam("count") int count + @RequestParam("count") int count, + @RequestParam(value = "type", required = false) String type ) { Range range = checkTimeRange(from, to); + TimeWindow timeWindow = new TimeWindow(range, ROUGH_TIME_WINDOW_SAMPLER); + UriStatSummaryQueryParameter query = new UriStatSummaryQueryParameter.Builder() .setTenantId(tenantProvider.getTenantId()) .setApplicationName(applicationName) .setAgentId(agentId) .setRange(range) + .setTimeSize((int) timeWindow.getWindowSlotSize()) + .setTimePrecision(TimePrecision.newTimePrecision(TimeUnit.MILLISECONDS, (int) timeWindow.getWindowSlotSize())) .setOrderby(column) .setDesc(isDesc) .setLimit(count) .build(); - return uriStatService.getUriStatPagedSummary(query); + if (type == null) { + List summaries = uriStatService.getUriStatPagedSummary(query); + return summaries.stream() + .map(mapper::toSummaryView + ).toList(); + } else { + UriStatChartType chartType = chartTypeFactory.valueOf(type.toLowerCase()); + List summaries = uriStatService.getUriStatMiniChart(chartType, query); + return summaries.stream() + .map((UriStatSummary e) + -> mapper.toSummaryView(e, timeWindow, chartType) + ).toList(); + } } @GetMapping("/chart") diff --git a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/dao/PinotApdexChartDao.java b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/dao/PinotApdexChartDao.java index f54df7ef4d59..eed99de603dd 100644 --- a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/dao/PinotApdexChartDao.java +++ b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/dao/PinotApdexChartDao.java @@ -1,6 +1,6 @@ package com.navercorp.pinpoint.uristat.web.dao; -import com.navercorp.pinpoint.uristat.web.entity.ApdexChartEntity; +import com.navercorp.pinpoint.uristat.web.entity.UriStatChartEntity; import com.navercorp.pinpoint.uristat.web.mapper.EntityToModelMapper; import com.navercorp.pinpoint.uristat.web.model.UriStatChartValue; import com.navercorp.pinpoint.uristat.web.util.UriStatChartQueryParameter; @@ -29,9 +29,9 @@ public PinotApdexChartDao( @Override public List getChartData(UriStatChartQueryParameter queryParameter) { - List entities = sqlPinotSessionTemplate.selectList(NAMESPACE + SELECT_APDEX_CHART, queryParameter); + List entities = sqlPinotSessionTemplate.selectList(NAMESPACE + SELECT_APDEX_CHART, queryParameter); return entities.stream() - .map(mapper::toModel + .map(mapper::toApdexChart ).toList(); } } diff --git a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/dao/PinotApdexSummaryDao.java b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/dao/PinotApdexSummaryDao.java new file mode 100644 index 000000000000..6c31c9ad4914 --- /dev/null +++ b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/dao/PinotApdexSummaryDao.java @@ -0,0 +1,63 @@ +/* + * Copyright 2025 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.uristat.web.dao; + +import com.navercorp.pinpoint.uristat.web.entity.UriStatSummaryEntity; +import com.navercorp.pinpoint.uristat.web.mapper.EntityToModelMapper; +import com.navercorp.pinpoint.uristat.web.mapper.MapperUtils; +import com.navercorp.pinpoint.uristat.web.model.UriStatSummary; +import com.navercorp.pinpoint.uristat.web.util.UriStatSummaryQueryParameter; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.mybatis.spring.SqlSessionTemplate; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * @author intr3p1d + */ +@Repository +public class PinotApdexSummaryDao implements UriStatSummaryDao { + + private final Logger logger = LogManager.getLogger(this.getClass()); + + private static final String NAMESPACE = PinotUriStatSummaryDao.class.getName() + "."; + private static final String URI_STAT_SUMMARY_APDEX = "uriStatSummaryApdex"; + private final SqlSessionTemplate sqlPinotSessionTemplate; + private final EntityToModelMapper mapper; + + public PinotApdexSummaryDao( + @Qualifier("uriStatPinotSessionTemplate") SqlSessionTemplate sqlPinotSessionTemplate, + EntityToModelMapper mapper + ) { + this.sqlPinotSessionTemplate = sqlPinotSessionTemplate; + this.mapper = mapper; + } + + @Override + public List getUriStatPagedSummary(UriStatSummaryQueryParameter uriStatQueryParameter) { + List entities = sqlPinotSessionTemplate.selectList( + NAMESPACE + URI_STAT_SUMMARY_APDEX, uriStatQueryParameter + ); + List> listOfEntities = MapperUtils.groupByUriAndVersion(entities, uriStatQueryParameter.getLimit()); + return listOfEntities.stream() + .map(mapper::toApdexSummary + ).toList(); + } + +} diff --git a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/dao/PinotFailureCountChartDao.java b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/dao/PinotFailureCountChartDao.java index 0404d58e1b3b..5cdc0a7a72f6 100644 --- a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/dao/PinotFailureCountChartDao.java +++ b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/dao/PinotFailureCountChartDao.java @@ -1,6 +1,6 @@ package com.navercorp.pinpoint.uristat.web.dao; -import com.navercorp.pinpoint.uristat.web.entity.FailureChartEntity; +import com.navercorp.pinpoint.uristat.web.entity.UriStatChartEntity; import com.navercorp.pinpoint.uristat.web.mapper.EntityToModelMapper; import com.navercorp.pinpoint.uristat.web.model.UriStatChartValue; import com.navercorp.pinpoint.uristat.web.util.UriStatChartQueryParameter; @@ -29,9 +29,9 @@ public PinotFailureCountChartDao( @Override public List getChartData(UriStatChartQueryParameter queryParameter) { - List entities = sqlPinotSessionTemplate.selectList(NAMESPACE + SELECT_FAILURE_CHART, queryParameter); + List entities = sqlPinotSessionTemplate.selectList(NAMESPACE + SELECT_FAILURE_CHART, queryParameter); return entities.stream() - .map(mapper::toModel + .map(mapper::toFailureChart ).toList(); } } diff --git a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/dao/PinotFailureSummaryDao.java b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/dao/PinotFailureSummaryDao.java new file mode 100644 index 000000000000..34cfde499567 --- /dev/null +++ b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/dao/PinotFailureSummaryDao.java @@ -0,0 +1,62 @@ +/* + * Copyright 2025 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.uristat.web.dao; + +import com.navercorp.pinpoint.uristat.web.entity.UriStatSummaryEntity; +import com.navercorp.pinpoint.uristat.web.mapper.EntityToModelMapper; +import com.navercorp.pinpoint.uristat.web.mapper.MapperUtils; +import com.navercorp.pinpoint.uristat.web.model.UriStatSummary; +import com.navercorp.pinpoint.uristat.web.util.UriStatSummaryQueryParameter; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.mybatis.spring.SqlSessionTemplate; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * @author intr3p1d + */ +@Repository +public class PinotFailureSummaryDao implements UriStatSummaryDao { + + private final Logger logger = LogManager.getLogger(this.getClass()); + + private static final String NAMESPACE = PinotUriStatSummaryDao.class.getName() + "."; + private static final String URI_STAT_SUMMARY_FAILURE = "uriStatSummaryFailure"; + private final SqlSessionTemplate sqlPinotSessionTemplate; + private final EntityToModelMapper mapper; + + public PinotFailureSummaryDao( + @Qualifier("uriStatPinotSessionTemplate") SqlSessionTemplate sqlPinotSessionTemplate, + EntityToModelMapper mapper + ) { + this.sqlPinotSessionTemplate = sqlPinotSessionTemplate; + this.mapper = mapper; + } + + @Override + public List getUriStatPagedSummary(UriStatSummaryQueryParameter uriStatQueryParameter) { + List entities = sqlPinotSessionTemplate.selectList( + NAMESPACE + URI_STAT_SUMMARY_FAILURE, uriStatQueryParameter + ); + List> listOfEntities = MapperUtils.groupByUriAndVersion(entities, uriStatQueryParameter.getLimit()); + return listOfEntities.stream() + .map(mapper::toFailureSummary + ).toList(); + } +} diff --git a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/dao/PinotLatencyChartDao.java b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/dao/PinotLatencyChartDao.java index 5290954f1349..2d7726b53777 100644 --- a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/dao/PinotLatencyChartDao.java +++ b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/dao/PinotLatencyChartDao.java @@ -1,6 +1,6 @@ package com.navercorp.pinpoint.uristat.web.dao; -import com.navercorp.pinpoint.uristat.web.entity.LatencyChartEntity; +import com.navercorp.pinpoint.uristat.web.entity.UriStatChartEntity; import com.navercorp.pinpoint.uristat.web.mapper.EntityToModelMapper; import com.navercorp.pinpoint.uristat.web.model.UriStatChartValue; import com.navercorp.pinpoint.uristat.web.util.UriStatChartQueryParameter; @@ -29,9 +29,9 @@ public PinotLatencyChartDao( @Override public List getChartData(UriStatChartQueryParameter queryParameter) { - List entities = sqlPinotSessionTemplate.selectList(NAMESPACE + SELECT_LATENCY_CHART, queryParameter); + List entities = sqlPinotSessionTemplate.selectList(NAMESPACE + SELECT_LATENCY_CHART, queryParameter); return entities.stream() - .map(mapper::toModel + .map(mapper::toLatencyChart ).toList(); } diff --git a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/dao/PinotLatencySummaryDao.java b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/dao/PinotLatencySummaryDao.java new file mode 100644 index 000000000000..8726bd0c7d1e --- /dev/null +++ b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/dao/PinotLatencySummaryDao.java @@ -0,0 +1,63 @@ +/* + * Copyright 2025 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.uristat.web.dao; + +import com.navercorp.pinpoint.uristat.web.entity.UriStatSummaryEntity; +import com.navercorp.pinpoint.uristat.web.mapper.EntityToModelMapper; +import com.navercorp.pinpoint.uristat.web.mapper.MapperUtils; +import com.navercorp.pinpoint.uristat.web.model.UriStatSummary; +import com.navercorp.pinpoint.uristat.web.util.UriStatSummaryQueryParameter; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.mybatis.spring.SqlSessionTemplate; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * @author intr3p1d + */ +@Repository +public class PinotLatencySummaryDao implements UriStatSummaryDao { + + private final Logger logger = LogManager.getLogger(this.getClass()); + + private static final String NAMESPACE = PinotUriStatSummaryDao.class.getName() + "."; + private static final String URI_STAT_SUMMARY_LATENCY = "uriStatSummaryLatency"; + private final SqlSessionTemplate sqlPinotSessionTemplate; + private final EntityToModelMapper mapper; + + public PinotLatencySummaryDao( + @Qualifier("uriStatPinotSessionTemplate") SqlSessionTemplate sqlPinotSessionTemplate, + EntityToModelMapper mapper + ) { + this.sqlPinotSessionTemplate = sqlPinotSessionTemplate; + this.mapper = mapper; + } + + @Override + public List getUriStatPagedSummary(UriStatSummaryQueryParameter uriStatQueryParameter) { + List entities = sqlPinotSessionTemplate.selectList( + NAMESPACE + URI_STAT_SUMMARY_LATENCY, uriStatQueryParameter + ); + List> listOfEntities = MapperUtils.groupByUriAndVersion(entities, uriStatQueryParameter.getLimit()); + return listOfEntities.stream() + .map(mapper::toLatencySummary + ).toList(); + } + +} diff --git a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/dao/PinotTotalCountChartDao.java b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/dao/PinotTotalCountChartDao.java index b88ff204efcc..b18a119866ed 100644 --- a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/dao/PinotTotalCountChartDao.java +++ b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/dao/PinotTotalCountChartDao.java @@ -1,6 +1,6 @@ package com.navercorp.pinpoint.uristat.web.dao; -import com.navercorp.pinpoint.uristat.web.entity.TotalChartEntity; +import com.navercorp.pinpoint.uristat.web.entity.UriStatChartEntity; import com.navercorp.pinpoint.uristat.web.mapper.EntityToModelMapper; import com.navercorp.pinpoint.uristat.web.model.UriStatChartValue; import com.navercorp.pinpoint.uristat.web.util.UriStatChartQueryParameter; @@ -30,9 +30,9 @@ public PinotTotalCountChartDao( @Override public List getChartData(UriStatChartQueryParameter queryParameter) { - List entities = sqlPinotSessionTemplate.selectList(NAMESPACE + SELECT_TOTAL_CHART, queryParameter); + List entities = sqlPinotSessionTemplate.selectList(NAMESPACE + SELECT_TOTAL_CHART, queryParameter); return entities.stream() - .map(mapper::toModel + .map(mapper::toTotalChart ).toList(); } } diff --git a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/dao/PinotTotalSummaryDao.java b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/dao/PinotTotalSummaryDao.java new file mode 100644 index 000000000000..bcea6e31ceeb --- /dev/null +++ b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/dao/PinotTotalSummaryDao.java @@ -0,0 +1,63 @@ +/* + * Copyright 2025 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.uristat.web.dao; + +import com.navercorp.pinpoint.uristat.web.entity.UriStatSummaryEntity; +import com.navercorp.pinpoint.uristat.web.mapper.EntityToModelMapper; +import com.navercorp.pinpoint.uristat.web.mapper.MapperUtils; +import com.navercorp.pinpoint.uristat.web.model.UriStatSummary; +import com.navercorp.pinpoint.uristat.web.util.UriStatSummaryQueryParameter; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.mybatis.spring.SqlSessionTemplate; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Repository; + +import java.util.List; +import java.util.Objects; + +/** + * @author intr3p1d + */ +@Repository +public class PinotTotalSummaryDao implements UriStatSummaryDao { + + private final Logger logger = LogManager.getLogger(this.getClass()); + + private static final String NAMESPACE = PinotUriStatSummaryDao.class.getName() + "."; + private static final String URI_STAT_SUMMARY_TOTAL = "uriStatSummaryTotal"; + private final SqlSessionTemplate sqlPinotSessionTemplate; + private final EntityToModelMapper mapper; + + public PinotTotalSummaryDao( + @Qualifier("uriStatPinotSessionTemplate") SqlSessionTemplate sqlPinotSessionTemplate, + EntityToModelMapper mapper + ) { + this.sqlPinotSessionTemplate = Objects.requireNonNull(sqlPinotSessionTemplate, "sqlPinotSessionTemplate"); + this.mapper = Objects.requireNonNull(mapper, "mapper"); + } + + @Override + public List getUriStatPagedSummary(UriStatSummaryQueryParameter queryParameter) { + List entities = sqlPinotSessionTemplate.selectList( + NAMESPACE + URI_STAT_SUMMARY_TOTAL, queryParameter + ); + List> listOfEntities = MapperUtils.groupByUriAndVersion(entities, queryParameter.getLimit()); + return listOfEntities.stream() + .map(mapper::toTotalSummary + ).toList(); + } +} diff --git a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/entity/ApdexChartEntity.java b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/entity/ApdexChartEntity.java deleted file mode 100644 index ee4fe31fdf20..000000000000 --- a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/entity/ApdexChartEntity.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2024 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.uristat.web.entity; - -/** - * @author intr3p1d - */ -public class ApdexChartEntity extends ChartCommonEntity { - private Double apdexRaw; - private Double count; - - public ApdexChartEntity() { - } - - public Double getApdexRaw() { - return apdexRaw; - } - - public void setApdexRaw(Double apdexRaw) { - this.apdexRaw = apdexRaw; - } - - public Double getCount() { - return count; - } - - public void setCount(Double count) { - this.count = count; - } -} diff --git a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/entity/ChartCommonEntity.java b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/entity/ChartCommonEntity.java deleted file mode 100644 index cba88217e3ed..000000000000 --- a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/entity/ChartCommonEntity.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2024 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.uristat.web.entity; - -/** - * @author intr3p1d - */ -public class ChartCommonEntity { - - private long timestamp; - private String version; - - public ChartCommonEntity() { - } - - public long getTimestamp() { - return timestamp; - } - - public void setTimestamp(long timestamp) { - this.timestamp = timestamp; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } -} diff --git a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/entity/FailureChartEntity.java b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/entity/FailureChartEntity.java deleted file mode 100644 index a2172a01e62b..000000000000 --- a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/entity/FailureChartEntity.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright 2024 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.uristat.web.entity; - -/** - * @author intr3p1d - */ -public class FailureChartEntity extends ChartCommonEntity { - private Double fail0; - private Double fail1; - private Double fail2; - private Double fail3; - private Double fail4; - private Double fail5; - private Double fail6; - private Double fail7; - - public FailureChartEntity() { - } - - public Double getFail0() { - return fail0; - } - - public void setFail0(Double fail0) { - this.fail0 = fail0; - } - - public Double getFail1() { - return fail1; - } - - public void setFail1(Double fail1) { - this.fail1 = fail1; - } - - public Double getFail2() { - return fail2; - } - - public void setFail2(Double fail2) { - this.fail2 = fail2; - } - - public Double getFail3() { - return fail3; - } - - public void setFail3(Double fail3) { - this.fail3 = fail3; - } - - public Double getFail4() { - return fail4; - } - - public void setFail4(Double fail4) { - this.fail4 = fail4; - } - - public Double getFail5() { - return fail5; - } - - public void setFail5(Double fail5) { - this.fail5 = fail5; - } - - public Double getFail6() { - return fail6; - } - - public void setFail6(Double fail6) { - this.fail6 = fail6; - } - - public Double getFail7() { - return fail7; - } - - public void setFail7(Double fail7) { - this.fail7 = fail7; - } -} diff --git a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/entity/LatencyChartEntity.java b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/entity/LatencyChartEntity.java deleted file mode 100644 index ff7f271614fc..000000000000 --- a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/entity/LatencyChartEntity.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2024 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.uristat.web.entity; - -/** - * @author intr3p1d - */ -public class LatencyChartEntity extends ChartCommonEntity { - private Double totalTimeMs; - private Double maxLatencyMs; - private Double count; - - public LatencyChartEntity() { - } - - public Double getTotalTimeMs() { - return totalTimeMs; - } - - public void setTotalTimeMs(Double totalTimeMs) { - this.totalTimeMs = totalTimeMs; - } - - public Double getMaxLatencyMs() { - return maxLatencyMs; - } - - public void setMaxLatencyMs(Double maxLatencyMs) { - this.maxLatencyMs = maxLatencyMs; - } - - public Double getCount() { - return count; - } - - public void setCount(Double count) { - this.count = count; - } -} diff --git a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/entity/TotalChartEntity.java b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/entity/TotalChartEntity.java deleted file mode 100644 index cd5a49eec676..000000000000 --- a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/entity/TotalChartEntity.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright 2024 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.uristat.web.entity; - -/** - * @author intr3p1d - */ -public class TotalChartEntity extends ChartCommonEntity { - - private Double tot0; - private Double tot1; - private Double tot2; - private Double tot3; - private Double tot4; - private Double tot5; - private Double tot6; - private Double tot7; - - public TotalChartEntity() { - } - - public Double getTot0() { - return tot0; - } - - public void setTot0(Double tot0) { - this.tot0 = tot0; - } - - public Double getTot1() { - return tot1; - } - - public void setTot1(Double tot1) { - this.tot1 = tot1; - } - - public Double getTot2() { - return tot2; - } - - public void setTot2(Double tot2) { - this.tot2 = tot2; - } - - public Double getTot3() { - return tot3; - } - - public void setTot3(Double tot3) { - this.tot3 = tot3; - } - - public Double getTot4() { - return tot4; - } - - public void setTot4(Double tot4) { - this.tot4 = tot4; - } - - public Double getTot5() { - return tot5; - } - - public void setTot5(Double tot5) { - this.tot5 = tot5; - } - - public Double getTot6() { - return tot6; - } - - public void setTot6(Double tot6) { - this.tot6 = tot6; - } - - public Double getTot7() { - return tot7; - } - - public void setTot7(Double tot7) { - this.tot7 = tot7; - } -} diff --git a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/entity/UriStatChartEntity.java b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/entity/UriStatChartEntity.java new file mode 100644 index 000000000000..e7c55a57e555 --- /dev/null +++ b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/entity/UriStatChartEntity.java @@ -0,0 +1,233 @@ +/* + * Copyright 2025 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.uristat.web.entity; + +/** + * @author intr3p1d + */ +public class UriStatChartEntity { + + // total + private Double tot0; + private Double tot1; + private Double tot2; + private Double tot3; + private Double tot4; + private Double tot5; + private Double tot6; + private Double tot7; + + // fail + private Double fail0; + private Double fail1; + private Double fail2; + private Double fail3; + private Double fail4; + private Double fail5; + private Double fail6; + private Double fail7; + + // latency + private Double totalTimeMs; + private Double maxLatencyMs; + private Double count; + + // apdex + private Double apdexRaw; + + // common + private long timestamp; + private String version; + + public UriStatChartEntity() { + } + + public Double getTot0() { + return tot0; + } + + public void setTot0(Double tot0) { + this.tot0 = tot0; + } + + public Double getTot1() { + return tot1; + } + + public void setTot1(Double tot1) { + this.tot1 = tot1; + } + + public Double getTot2() { + return tot2; + } + + public void setTot2(Double tot2) { + this.tot2 = tot2; + } + + public Double getTot3() { + return tot3; + } + + public void setTot3(Double tot3) { + this.tot3 = tot3; + } + + public Double getTot4() { + return tot4; + } + + public void setTot4(Double tot4) { + this.tot4 = tot4; + } + + public Double getTot5() { + return tot5; + } + + public void setTot5(Double tot5) { + this.tot5 = tot5; + } + + public Double getTot6() { + return tot6; + } + + public void setTot6(Double tot6) { + this.tot6 = tot6; + } + + public Double getTot7() { + return tot7; + } + + public void setTot7(Double tot7) { + this.tot7 = tot7; + } + + public Double getFail0() { + return fail0; + } + + public void setFail0(Double fail0) { + this.fail0 = fail0; + } + + public Double getFail1() { + return fail1; + } + + public void setFail1(Double fail1) { + this.fail1 = fail1; + } + + public Double getFail2() { + return fail2; + } + + public void setFail2(Double fail2) { + this.fail2 = fail2; + } + + public Double getFail3() { + return fail3; + } + + public void setFail3(Double fail3) { + this.fail3 = fail3; + } + + public Double getFail4() { + return fail4; + } + + public void setFail4(Double fail4) { + this.fail4 = fail4; + } + + public Double getFail5() { + return fail5; + } + + public void setFail5(Double fail5) { + this.fail5 = fail5; + } + + public Double getFail6() { + return fail6; + } + + public void setFail6(Double fail6) { + this.fail6 = fail6; + } + + public Double getFail7() { + return fail7; + } + + public void setFail7(Double fail7) { + this.fail7 = fail7; + } + + public Double getTotalTimeMs() { + return totalTimeMs; + } + + public void setTotalTimeMs(Double totalTimeMs) { + this.totalTimeMs = totalTimeMs; + } + + public Double getMaxLatencyMs() { + return maxLatencyMs; + } + + public void setMaxLatencyMs(Double maxLatencyMs) { + this.maxLatencyMs = maxLatencyMs; + } + + public Double getCount() { + return count; + } + + public void setCount(Double count) { + this.count = count; + } + + public Double getApdexRaw() { + return apdexRaw; + } + + public void setApdexRaw(Double apdexRaw) { + this.apdexRaw = apdexRaw; + } + + public long getTimestamp() { + return timestamp; + } + + public void setTimestamp(long timestamp) { + this.timestamp = timestamp; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } +} diff --git a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/entity/UriStatSummaryEntity.java b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/entity/UriStatSummaryEntity.java index af97a54e249a..0cd11f4686a1 100644 --- a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/entity/UriStatSummaryEntity.java +++ b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/entity/UriStatSummaryEntity.java @@ -18,7 +18,7 @@ /** * @author intr3p1d */ -public class UriStatSummaryEntity { +public class UriStatSummaryEntity extends UriStatChartEntity { private String uri; private Double apdexRaw; private Double totalCount; diff --git a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/mapper/EntityToModelMapper.java b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/mapper/EntityToModelMapper.java index f4a2f5ea85c3..d2af092f1ddb 100644 --- a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/mapper/EntityToModelMapper.java +++ b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/mapper/EntityToModelMapper.java @@ -16,12 +16,8 @@ package com.navercorp.pinpoint.uristat.web.mapper; import com.google.common.primitives.Doubles; -import com.navercorp.pinpoint.common.server.mapper.MapStructUtils; import com.navercorp.pinpoint.common.util.MathUtils; -import com.navercorp.pinpoint.uristat.web.entity.ApdexChartEntity; -import com.navercorp.pinpoint.uristat.web.entity.FailureChartEntity; -import com.navercorp.pinpoint.uristat.web.entity.LatencyChartEntity; -import com.navercorp.pinpoint.uristat.web.entity.TotalChartEntity; +import com.navercorp.pinpoint.uristat.web.entity.UriStatChartEntity; import com.navercorp.pinpoint.uristat.web.entity.UriStatSummaryEntity; import com.navercorp.pinpoint.uristat.web.model.UriStatChartValue; import com.navercorp.pinpoint.uristat.web.model.UriStatSummary; @@ -34,28 +30,56 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.List; +import java.util.function.Function; /** * @author intr3p1d */ @Mapper( injectionStrategy = InjectionStrategy.CONSTRUCTOR, - collectionMappingStrategy = CollectionMappingStrategy.ADDER_PREFERRED + collectionMappingStrategy = CollectionMappingStrategy.ADDER_PREFERRED, + uses = {MapperUtils.class} ) public interface EntityToModelMapper { + + @Retention(RetentionPolicy.CLASS) @Mapping(target = "apdex", source = "entity", qualifiedByName = "toApdex") @Mapping(target = "avgTimeMs", source = "entity", qualifiedByName = "toAvgTimeMs") + public @interface ToStatSummary { + } + + @ToStatSummary + @Mapping(target = "chartValue", ignore = true) UriStatSummary toModel(UriStatSummaryEntity entity); - @Named("toApdex") - default Double toApdex(UriStatSummaryEntity entity) { - return MathUtils.average(entity.getApdexRaw(), entity.getTotalCount()); + default UriStatSummary toTotalSummary(List entity) { + return mergeSummary(entity, this::toTotalChart); + } + + default UriStatSummary toFailureSummary(List entity) { + return mergeSummary(entity, this::toFailureChart); + } + + default UriStatSummary toLatencySummary(List entity) { + return mergeSummary(entity, this::toLatencyChart); + } + + default UriStatSummary toApdexSummary(List entity) { + return mergeSummary(entity, this::toApdexChart); } - @Named("toAvgTimeMs") - default Double toAvgTimeMs(UriStatSummaryEntity entity) { - return MathUtils.average(entity.getTotalTimeMs(), entity.getTotalCount()); + default UriStatSummary mergeSummary( + List entities, + Function mapper + ) { + UriStatSummaryEntity mergedEntity = entities.get(0); + List chartValues = entities.stream() + .map(mapper) + .toList(); + UriStatSummary summary = toModel(mergedEntity); + summary.setChartValue(chartValues); + return summary; } @Retention(RetentionPolicy.CLASS) @@ -65,60 +89,32 @@ default Double toAvgTimeMs(UriStatSummaryEntity entity) { } @ToChartValue + @Named("toTotalChart") @Mapping(target = "chartType", constant = "bar") @Mapping(target = "unit", constant = "count") @Mapping(target = "values", source = "entity", qualifiedByName = "toTotalHistogram") - UriStatChartValue toModel(TotalChartEntity entity); + UriStatChartValue toTotalChart(UriStatChartEntity entity); @ToChartValue + @Named("toFailureChart") @Mapping(target = "chartType", constant = "bar") @Mapping(target = "unit", constant = "count") @Mapping(target = "values", source = "entity", qualifiedByName = "toFailureHistogram") - UriStatChartValue toModel(FailureChartEntity entity); + UriStatChartValue toFailureChart(UriStatChartEntity entity); @ToChartValue + @Named("toLatencyChart") @Mapping(target = "chartType", constant = "line") @Mapping(target = "unit", constant = "ms") @Mapping(target = "values", source = "entity", qualifiedByName = "toLatency") - UriStatChartValue toModel(LatencyChartEntity entity); + UriStatChartValue toLatencyChart(UriStatChartEntity entity); @ToChartValue + @Named("toApdexChart") @Mapping(target = "chartType", constant = "line") @Mapping(target = "unit", constant = "") @Mapping(target = "values", source = "entity", qualifiedByName = "toApdexList") - UriStatChartValue toModel(ApdexChartEntity entity); - - @Named("toTotalHistogram") - default List toTotalHistogram(TotalChartEntity entity) { - return toHistogram( - entity.getTot0(), entity.getTot1(), entity.getTot2(), entity.getTot3(), - entity.getTot4(), entity.getTot5(), entity.getTot6(), entity.getTot7() - ); - } - - @Named("toFailureHistogram") - default List toFailureHistogram(FailureChartEntity entity) { - return toHistogram( - entity.getFail0(), entity.getFail1(), entity.getFail2(), entity.getFail3(), - entity.getFail4(), entity.getFail5(), entity.getFail6(), entity.getFail7() - ); - } - - default List toHistogram( - Double hist0, Double hist1, Double hist2, Double hist3, - Double hist4, Double hist5, Double hist6, Double hist7 - ) { - return Doubles.asList(hist0, hist1, hist2, hist3, hist4, hist5, hist6, hist7); - } + UriStatChartValue toApdexChart(UriStatChartEntity entity); - @Named("toLatency") - default List toLatency(LatencyChartEntity entity) { - return Doubles.asList((entity.getCount() == 0) ? -1 : (entity.getTotalTimeMs() / entity.getCount()), entity.getMaxLatencyMs()); - } - - @Named("toApdexList") - default List toApdexList(ApdexChartEntity entity) { - return Doubles.asList((entity.getCount() == 0) ? -1 : (entity.getApdexRaw() / entity.getCount())); - } } diff --git a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/mapper/MapperConfig.java b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/mapper/MapperConfig.java index 5ea6e478ec4d..bf14af7edda8 100644 --- a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/mapper/MapperConfig.java +++ b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/mapper/MapperConfig.java @@ -29,4 +29,9 @@ public class MapperConfig { EntityToModelMapper entityToModelMapper() { return Mappers.getMapper(EntityToModelMapper.class); } + + @Bean + ModelToViewMapper modelToViewMapper() { + return Mappers.getMapper(ModelToViewMapper.class); + } } diff --git a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/mapper/MapperUtils.java b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/mapper/MapperUtils.java new file mode 100644 index 000000000000..56a2b39bc832 --- /dev/null +++ b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/mapper/MapperUtils.java @@ -0,0 +1,94 @@ +/* + * Copyright 2025 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.uristat.web.mapper; + +import com.google.common.primitives.Doubles; +import com.navercorp.pinpoint.common.util.MathUtils; +import com.navercorp.pinpoint.uristat.web.entity.UriStatChartEntity; +import com.navercorp.pinpoint.uristat.web.entity.UriStatSummaryEntity; +import com.navercorp.pinpoint.uristat.web.model.UriStatChartValue; +import org.mapstruct.Named; + +import java.util.LinkedHashMap; +import java.util.List; +import java.util.function.Function; +import java.util.stream.Collectors; + +/** + * @author intr3p1d + */ +public class MapperUtils { + public static List> groupByUriAndVersion( + List entities, + long originalLimit + ) { + // Use LinkedHashMap to preserve the order of the entities as much as possible + List> grouped = entities.stream() + .collect( + Collectors.groupingBy( + entity -> entity.getUri() + entity.getVersion(), LinkedHashMap::new, Collectors.toList() + ) + ).values().stream().toList(); + return subList(grouped, originalLimit); + } + + static List subList(List list, long limit) { + return list.subList(0, (int) Math.min(list.size(), limit)); + } + + @Named("toApdex") + public static Double toApdex(UriStatSummaryEntity entity) { + return MathUtils.average(entity.getApdexRaw(), entity.getTotalCount()); + } + + @Named("toAvgTimeMs") + public static Double toAvgTimeMs(UriStatSummaryEntity entity) { + return MathUtils.average(entity.getTotalTimeMs(), entity.getTotalCount()); + } + + @Named("toTotalHistogram") + public static List toTotalHistogram(UriStatChartEntity entity) { + return toHistogram( + entity.getTot0(), entity.getTot1(), entity.getTot2(), entity.getTot3(), + entity.getTot4(), entity.getTot5(), entity.getTot6(), entity.getTot7() + ); + } + + @Named("toFailureHistogram") + public static List toFailureHistogram(UriStatChartEntity entity) { + return toHistogram( + entity.getFail0(), entity.getFail1(), entity.getFail2(), entity.getFail3(), + entity.getFail4(), entity.getFail5(), entity.getFail6(), entity.getFail7() + ); + } + + public static List toHistogram( + Double hist0, Double hist1, Double hist2, Double hist3, + Double hist4, Double hist5, Double hist6, Double hist7 + ) { + return Doubles.asList(hist0, hist1, hist2, hist3, hist4, hist5, hist6, hist7); + } + + @Named("toLatency") + public static List toLatency(UriStatChartEntity entity) { + return Doubles.asList((entity.getCount() == 0) ? -1 : (entity.getTotalTimeMs() / entity.getCount()), entity.getMaxLatencyMs()); + } + + @Named("toApdexList") + public static List toApdexList(UriStatChartEntity entity) { + return Doubles.asList((entity.getCount() == 0) ? -1 : (entity.getApdexRaw() / entity.getCount())); + } +} diff --git a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/mapper/ModelToViewMapper.java b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/mapper/ModelToViewMapper.java new file mode 100644 index 000000000000..7876fdbaaff8 --- /dev/null +++ b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/mapper/ModelToViewMapper.java @@ -0,0 +1,55 @@ +/* + * Copyright 2025 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.uristat.web.mapper; + +import com.navercorp.pinpoint.common.server.util.timewindow.TimeWindow; +import com.navercorp.pinpoint.uristat.web.chart.UriStatChartType; +import com.navercorp.pinpoint.uristat.web.model.UriStatSummary; +import com.navercorp.pinpoint.uristat.web.view.UriStatSummaryView; +import com.navercorp.pinpoint.uristat.web.view.UriStatView; +import org.mapstruct.CollectionMappingStrategy; +import org.mapstruct.InjectionStrategy; +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; + +/** + * @author intr3p1d + */ +@Mapper( + injectionStrategy = InjectionStrategy.CONSTRUCTOR, + collectionMappingStrategy = CollectionMappingStrategy.ADDER_PREFERRED, + uses = {MapperUtils.class} +) +public interface ModelToViewMapper { + + default UriStatSummaryView toSummaryView( + UriStatSummary model, TimeWindow timeWindow, UriStatChartType chartType + ) { + UriStatView uriStatView = toChartView(model, timeWindow, chartType); + UriStatSummaryView miniChartView = this.toSummaryView(model); + miniChartView.setChart(uriStatView); + return miniChartView; + } + + @Mapping(target = "chart", ignore = true) + UriStatSummaryView toSummaryView(UriStatSummary model); + + default UriStatView toChartView( + UriStatSummary model, TimeWindow timeWindow, UriStatChartType chartType + ) { + return new UriStatView(model.getUri(), timeWindow, model.getChartValue(), chartType); + } +} diff --git a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/model/UriStatSummary.java b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/model/UriStatSummary.java index 7f883dbcb37d..54d7c6cc3af6 100644 --- a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/model/UriStatSummary.java +++ b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/model/UriStatSummary.java @@ -16,7 +16,7 @@ package com.navercorp.pinpoint.uristat.web.model; -import com.navercorp.pinpoint.common.util.MathUtils; +import java.util.List; public class UriStatSummary { private String uri; @@ -27,6 +27,8 @@ public class UriStatSummary { private Double apdex; private String version; + private List chartValue; + public UriStatSummary() { } @@ -85,4 +87,12 @@ public String getVersion() { public void setVersion(String version) { this.version = version; } + + public List getChartValue() { + return chartValue; + } + + public void setChartValue(List chartValue) { + this.chartValue = chartValue; + } } diff --git a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/service/UriStatSummaryService.java b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/service/UriStatSummaryService.java index d4bf2d58a6fd..a7a6690b8662 100644 --- a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/service/UriStatSummaryService.java +++ b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/service/UriStatSummaryService.java @@ -16,6 +16,7 @@ package com.navercorp.pinpoint.uristat.web.service; +import com.navercorp.pinpoint.uristat.web.chart.UriStatChartType; import com.navercorp.pinpoint.uristat.web.model.UriStatSummary; import com.navercorp.pinpoint.uristat.web.util.UriStatSummaryQueryParameter; @@ -23,4 +24,5 @@ public interface UriStatSummaryService { List getUriStatPagedSummary(UriStatSummaryQueryParameter queryParameter); + List getUriStatMiniChart(UriStatChartType type, UriStatSummaryQueryParameter queryParameter); } diff --git a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/service/UriStatSummaryServiceImpl.java b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/service/UriStatSummaryServiceImpl.java index e6bd2aacfdec..2b625e159c7b 100644 --- a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/service/UriStatSummaryServiceImpl.java +++ b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/service/UriStatSummaryServiceImpl.java @@ -16,9 +16,11 @@ package com.navercorp.pinpoint.uristat.web.service; +import com.navercorp.pinpoint.uristat.web.chart.UriStatChartType; import com.navercorp.pinpoint.uristat.web.dao.UriStatSummaryDao; import com.navercorp.pinpoint.uristat.web.model.UriStatSummary; import com.navercorp.pinpoint.uristat.web.util.UriStatSummaryQueryParameter; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Service; import java.util.List; @@ -29,7 +31,9 @@ public class UriStatSummaryServiceImpl implements UriStatSummaryService { private final UriStatSummaryDao uriStatSummaryDao; - public UriStatSummaryServiceImpl(UriStatSummaryDao uriStatDao) { + public UriStatSummaryServiceImpl( + @Qualifier("pinotUriStatSummaryDao") UriStatSummaryDao uriStatDao + ) { this.uriStatSummaryDao = Objects.requireNonNull(uriStatDao); } @@ -37,4 +41,9 @@ public UriStatSummaryServiceImpl(UriStatSummaryDao uriStatDao) { public List getUriStatPagedSummary(UriStatSummaryQueryParameter queryParameter) { return uriStatSummaryDao.getUriStatPagedSummary(queryParameter); } + + @Override + public List getUriStatMiniChart(UriStatChartType type, UriStatSummaryQueryParameter queryParameter) { + return type.getSummaryDao().getUriStatPagedSummary(queryParameter); + } } diff --git a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/util/UriStatSummaryQueryParameter.java b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/util/UriStatSummaryQueryParameter.java index 2f874e36d356..96d505e5a1cc 100644 --- a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/util/UriStatSummaryQueryParameter.java +++ b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/util/UriStatSummaryQueryParameter.java @@ -31,6 +31,7 @@ public class UriStatSummaryQueryParameter extends QueryParameter { private final String agentId; private final OrderBy orderBy; private final String isDesc; + private final long tenTimesLimit; public String getTenantId() { return tenantId; @@ -105,6 +106,7 @@ protected UriStatSummaryQueryParameter(Builder builder) { this.agentId = builder.agentId; this.orderBy = builder.orderBy; this.isDesc = builder.isDesc; + this.tenTimesLimit = builder.getLimit() * 10; } public static class Builder extends QueryParameter.Builder { diff --git a/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/view/UriStatSummaryView.java b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/view/UriStatSummaryView.java new file mode 100644 index 000000000000..785fb125080e --- /dev/null +++ b/uristat/uristat-web/src/main/java/com/navercorp/pinpoint/uristat/web/view/UriStatSummaryView.java @@ -0,0 +1,102 @@ +/* + * Copyright 2025 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.uristat.web.view; + +import com.fasterxml.jackson.annotation.JsonInclude; + +/** + * @author intr3p1d + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UriStatSummaryView { + + private String uri; + private Double totalCount; + private Double failureCount; + private Double maxTimeMs; + private Double avgTimeMs; + private Double apdex; + private String version; + + UriStatView chart; + + public UriStatSummaryView() { + } + + public String getUri() { + return uri; + } + + public void setUri(String uri) { + this.uri = uri; + } + + public Double getTotalCount() { + return totalCount; + } + + public void setTotalCount(Double totalCount) { + this.totalCount = totalCount; + } + + public Double getFailureCount() { + return failureCount; + } + + public void setFailureCount(Double failureCount) { + this.failureCount = failureCount; + } + + public Double getMaxTimeMs() { + return maxTimeMs; + } + + public void setMaxTimeMs(Double maxTimeMs) { + this.maxTimeMs = maxTimeMs; + } + + public Double getAvgTimeMs() { + return avgTimeMs; + } + + public void setAvgTimeMs(Double avgTimeMs) { + this.avgTimeMs = avgTimeMs; + } + + public Double getApdex() { + return apdex; + } + + public void setApdex(Double apdex) { + this.apdex = apdex; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public UriStatView getChart() { + return chart; + } + + public void setChart(UriStatView chart) { + this.chart = chart; + } +} diff --git a/uristat/uristat-web/src/main/resources/mapper/uristat/UriStatChartMapper.xml b/uristat/uristat-web/src/main/resources/mapper/uristat/UriStatChartMapper.xml index 17556981d2be..9da431787226 100644 --- a/uristat/uristat-web/src/main/resources/mapper/uristat/UriStatChartMapper.xml +++ b/uristat/uristat-web/src/main/resources/mapper/uristat/UriStatChartMapper.xml @@ -1,19 +1,10 @@ - + - - - - - - - - - - SELECT DATETIME_CONVERT("timestamp", '1:MILLISECONDS:EPOCH', '1:MILLISECONDS:EPOCH', '#{timePrecision.timeSize}:${timePrecision.timeUnit}') as "timestamp", @@ -40,7 +31,7 @@ LIMIT ${limit} - SELECT DATETIME_CONVERT("timestamp", '1:MILLISECONDS:EPOCH', '1:MILLISECONDS:EPOCH', '#{timePrecision.timeSize}:${timePrecision.timeUnit}') as "timestamp", @@ -67,7 +58,7 @@ LIMIT ${limit} - SELECT DATETIME_CONVERT("timestamp", '1:MILLISECONDS:EPOCH', '1:MILLISECONDS:EPOCH', '#{timePrecision.timeSize}:${timePrecision.timeUnit}') as "timestamp", @@ -88,7 +79,7 @@ LIMIT ${limit} - SELECT DATETIME_CONVERT("timestamp", '1:MILLISECONDS:EPOCH', '1:MILLISECONDS:EPOCH', '#{timePrecision.timeSize}:${timePrecision.timeUnit}') as "timestamp", diff --git a/uristat/uristat-web/src/main/resources/mapper/uristat/UriStatSummaryMapper.xml b/uristat/uristat-web/src/main/resources/mapper/uristat/UriStatSummaryMapper.xml index 581cdb86c94c..97aefe2ccbc3 100644 --- a/uristat/uristat-web/src/main/resources/mapper/uristat/UriStatSummaryMapper.xml +++ b/uristat/uristat-web/src/main/resources/mapper/uristat/UriStatSummaryMapper.xml @@ -24,4 +24,90 @@ ORDER BY ${orderBy} ${isDesc} LIMIT #{limit} + + + SET useMultiStageEngine = true; + + + + sum(tot0) as tot0, + sum(tot1) as tot1, + sum(tot2) as tot2, + sum(tot3) as tot3, + sum(tot4) as tot4, + sum(tot5) as tot5, + sum(tot6) as tot6, + sum(tot7) as tot7, + + + + sum(fail0) as fail0, + sum(fail1) as fail1, + sum(fail2) as fail2, + sum(fail3) as fail3, + sum(fail4) as fail4, + sum(fail5) as fail5, + sum(fail6) as fail6, + sum(fail7) as fail7, + + + + sum("count") as "count", + + + + max(maxLatencyMs) as maxLatencyMs, + sum("count") as "count", + + + + DATETIMECONVERT("timestamp", '1:MILLISECONDS:EPOCH', '1:MILLISECONDS:EPOCH', + '#{timePrecision.timeSize}:${timePrecision.timeUnit}') as "timestamp", + uri, + sum(sum(apdexRaw)) OVER (PARTITION BY uri, version) as apdexRaw, + sum(sum("count")) OVER (PARTITION BY uri, version) as totalCount, + max(max(maxLatencyMs)) OVER (PARTITION BY uri, version) as maxTimeMs, + sum(sum(totalTimeMs)) OVER (PARTITION BY uri, version) as totalTimeMs, + sum(sum(failureCount)) OVER (PARTITION BY uri, version) as failureCount, + version + FROM uriStat + WHERE tenantId = #{tenantId} + AND applicationName = #{applicationName} + + AND agentId = #{agentId} + + AND "timestamp" BETWEEN #{range.from} AND #{range.to} + GROUP BY "timestamp", uri, version + ORDER BY ${orderBy} ${isDesc} + LIMIT #{tenTimesLimit} + + + + + + + + + + diff --git a/uristat/uristat-web/src/test/java/com/navercorp/pinpoint/uristat/web/mapper/EntityToModelMapperTest.java b/uristat/uristat-web/src/test/java/com/navercorp/pinpoint/uristat/web/mapper/EntityToModelMapperTest.java index 82d62e685e2d..ca8f98df05dd 100644 --- a/uristat/uristat-web/src/test/java/com/navercorp/pinpoint/uristat/web/mapper/EntityToModelMapperTest.java +++ b/uristat/uristat-web/src/test/java/com/navercorp/pinpoint/uristat/web/mapper/EntityToModelMapperTest.java @@ -1,9 +1,6 @@ package com.navercorp.pinpoint.uristat.web.mapper; -import com.navercorp.pinpoint.uristat.web.entity.ApdexChartEntity; -import com.navercorp.pinpoint.uristat.web.entity.FailureChartEntity; -import com.navercorp.pinpoint.uristat.web.entity.LatencyChartEntity; -import com.navercorp.pinpoint.uristat.web.entity.TotalChartEntity; +import com.navercorp.pinpoint.uristat.web.entity.UriStatChartEntity; import com.navercorp.pinpoint.uristat.web.entity.UriStatSummaryEntity; import com.navercorp.pinpoint.uristat.web.model.UriStatChartValue; import com.navercorp.pinpoint.uristat.web.model.UriStatSummary; @@ -43,7 +40,7 @@ void toModel() { @Test void testTotalEntityToModel() { - TotalChartEntity entity = new TotalChartEntity(); + UriStatChartEntity entity = new UriStatChartEntity(); entity.setTimestamp(1000); entity.setVersion("version"); entity.setTot0(10.0); @@ -55,7 +52,7 @@ void testTotalEntityToModel() { entity.setTot6(70.0); entity.setTot7(80.0); - UriStatChartValue model = mapper.toModel(entity); + UriStatChartValue model = mapper.toTotalChart(entity); assertEquals(entity.getTimestamp(), model.getTimestamp()); assertEquals(entity.getVersion(), model.getVersion()); @@ -74,7 +71,7 @@ void testTotalEntityToModel() { @Test void testFailureEntityToModel() { - FailureChartEntity entity = new FailureChartEntity(); + UriStatChartEntity entity = new UriStatChartEntity(); entity.setTimestamp(1000); entity.setVersion("version"); entity.setFail0(10.0); @@ -86,7 +83,7 @@ void testFailureEntityToModel() { entity.setFail6(70.0); entity.setFail7(80.0); - UriStatChartValue model = mapper.toModel(entity); + UriStatChartValue model = mapper.toFailureChart(entity); assertEquals(entity.getTimestamp(), model.getTimestamp()); assertEquals(entity.getVersion(), model.getVersion()); @@ -105,14 +102,14 @@ void testFailureEntityToModel() { @Test void testLatencyEntityToModel() { - LatencyChartEntity entity = new LatencyChartEntity(); + UriStatChartEntity entity = new UriStatChartEntity(); entity.setTimestamp(1000); entity.setVersion("version"); entity.setTotalTimeMs(1200.0); entity.setMaxLatencyMs(500.0); entity.setCount(3.0); - UriStatChartValue model = mapper.toModel(entity); + UriStatChartValue model = mapper.toLatencyChart(entity); assertEquals(entity.getTimestamp(), model.getTimestamp()); assertEquals(entity.getVersion(), model.getVersion()); @@ -125,13 +122,13 @@ void testLatencyEntityToModel() { @Test void testApdexEntityToModel() { - ApdexChartEntity entity = new ApdexChartEntity(); + UriStatChartEntity entity = new UriStatChartEntity(); entity.setTimestamp(1000); entity.setVersion("version"); entity.setApdexRaw(50.0); entity.setCount(100.0); - UriStatChartValue model = mapper.toModel(entity); + UriStatChartValue model = mapper.toApdexChart(entity); assertEquals(entity.getTimestamp(), model.getTimestamp()); assertEquals(entity.getVersion(), model.getVersion());